Hello again List,

I have a listbox (SelectSingleListbox) containing items. Beneath this
list are comandLinks to add/remove these items and move them up/down.
This is working correctly.

Next to the list I have a form, which reflects the selected item's
properties, including name and description. The description is what
appears in the list and the name is not seen by the user, it's in a
hidden field. 

The list has onchange="submit()", and a ValueChangelListener attached.
It is immediate, so the event is processed before the fields' values are
looked at. The value change listener considers the value of the list's
selected item's name and the value of the hidden field, to determine
whether the change is a new item being selected in the list (in which
case the fields are cleared, thank you myfaces wiki, and in the render
phase are filled from the model), or if the change has been caused by
the user changing some fields and hitting save (in which case the fields
should not be cleared, and the values should be remembered into the
validation and model update phases). So far so good, this is working.

However, it requires the user to hit a save button. What I would prefer
would be if, when changing the selected item in the list, the fields'
values are applied to the old item, and then cleared and populated with
values from the new item. I'm having trouble seeing how this would fit
into the JSF lifecycle.

Effectively I would like this to happen:

    List containing A         Immediate value change            
    changed to B          ->  listener called, sets A  ->   
                              as value of list and         
                              bean property


    process validations       Update model updates
->  occurs on fields of   ->  values in A, but sets    -> 
    A (and presumably         selected item to B.                      
    for B  as an item
    in list)

->  clear fields          ->  render response
                              (fields show B's value)


If any validation errors occur, show A selected and A's values in the
fields. Should not interfere with the normal clicking on items in the
list, and manipulating them with links.

Is this too inconsistent and crazy? Should I be splitting process
validation/ update model each into two separate phases? Is that even
possible?

As far as I can see I have two avenues to pursue: do some sort of magic
in the value change listener to perform validations and process updates
then clear the fields, or have fields for every item's values, using css
to hide the ones that aren't relevant. The first option sounds
complicated. The second heavyweight.

Any ideas? JSF RI 1.1, trinidad and facelets, if it makes a difference.

Regards,
______________________________________________ 
Edward Steel - Consultant
t +44 (0) 1483 817222 | m +44 (0) 7939 657 259
a Detica | Surrey Research Park | Guildford | GU2 7YP | UK
______________________________________________ 
www.detica.com <http://www.detica.com/> 





This message should be regarded as confidential. If you have received this 
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy by 
an authorised signatory.  The contents of this email may relate to dealings 
with other companies within the Detica Group plc group of companies.

Detica Limited is registered in England under No: 1337451.

Registered offices: Surrey Research Park, Guildford, Surrey, GU2 7YP, England.


Reply via email to