Using JHeadstart 22.214.171.124 - is it possible to generate shuttle boxes for the simple task of updating records.
For example - in the leading list I want to see all employees with a status of 'ACTIVE'. In the trailing list I want to see all employees with a status of 'INACTIVE'. By shuttling employees between the two lists, the status of the employee should be updated accordingly. I know there are processShuttle class in JhsApplicationModuleImpl but this (and the App Def Editor) only really seem to cope with data where a parent-child relationship exists.
Is there any way to achieve this in JHeadstart (I recall years ago somehow using dummy parent VO's ?) - or am I best dropping back to ADF for this and then using templates to preserve the code
I have actually managed to get this working in JHeadstart - and with only a couple of lines of custom code needed - so I thought I would post the process I followed here in case anyone else is interested (and perhaps get some feedback from you on whether this method is ok to use, or indeed if it can be tweaked/improved on :)
So, for my testing I used the HR schema
1. Extended the EMPLOYEES table to add a new column EMPLOYEE_STATUS. Not null, set most to "INACTIVE", some to "RETIRED" and some to "ACTIVE"
2. Created Employee EO and Employees VO
3. Also created a new VO EmployeesToBeActivatedShuttle - based on Employee EO with a custom where clause of WHERE Employees.EMPLOYEE_STATUS in ('ACTIVE','INACTIVE') - as in my unselected list, I don't want to see employees with a status of "RETIRED"
4. Created a dummy parent VO EmployeeStatusActiveDummy - Read only VO with query "select 'ACTIVE' as emp_active_status from dual"
5. Created a view link between EmployeeStatusActiveDummy and Employees
6. In AppModule added EmployeeStatusActiveDummy and the child Employees VO (renamed ActiveEmployeesShuttle)
7. In JAG, created a group ActivateEmployees with Data Collection EmployeeStatusActiveDummy. Hide single attribute.
8. Created a dynamic domain for the unselected list using EmployeesToBeActivatedShuttle with EmployeeID as value and LastName as meaning
9. Created a child group ActiveEmployees using the Data Collection ActiveEmployeesShuttle. Set group to parent-shuttle, set the unselected list domain and relevant titles
As it stands, after generation this works perfect for showing just the INACTIVE employees in the leading shuttle and ACTIVE employees in the trailing shuttle. Also, moving employees from the INACTIVE to the ACTIVE shuttle also works as the existing processSelectedParentShuttleRow method in JhsApplicationModuleImpl simply updates the child attr (EmployeeStatus in this case) to the value of the parent attribute (hard coded as ACTIVE). What doesn't work out of the box is moving employees the other way (ie un-selecting them) as the standard processUnselectedParentShuttleRow method sets the child attr to null.
I simply overrode processShuttle in my AppModuleImpl, and depending on the value of the childVo ViewObject I replace the processUnselectedParentShuttleRow with a shuttle box specific one (processUnselectedEmpStatusActiveShuttleRow). In this I simply change the line setting the child attr from null to INACTIVE (in my real world case I am looking up another attribute on the row that holds the previous status and using this value to reset the current status).
And voila - JHeadstart generated shuttle updating the status of my records :)
Hopefully it will stand up to more testing !