jsr344-experts@javaserverfaces-spec-public.java.net

[jsr344-experts] Re: [jsr344-experts mirror] DataTables and input controls

From: Leonardo Uribe <lu4242_at_gmail.com>
Date: Fri, 14 Feb 2014 16:17:46 -0500

Hi

Unfortunately, "rowStatePreserved" was never included in ui:repeat, so
it was created this issue:

https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1230

There is still a problem related to the component row state and its
relation with the model. In few words, if you remove a row, since the
state is associated to the rowIndex, the state of the removed row is
passed to the next row and so on, breaking the state. Long time
ago, I did a solution to the problem in tomahawk adding some
attributes (rowKey and derivedRowKeyPrefix).

regards,

Leonardo Uribe

2014-02-14 16:03 GMT-05:00 Leonardo Uribe <lu4242_at_gmail.com>:
> Hi
>
> There is no need to call setRowIndex(...), but it is true all the
> magic happens inside it. Use invokeOnComponent(...) or visitTree(...)
> do the necessary calls to setRowIndex(...) of the method used to
> traverse between rows.
>
> The only thing to remember is the default algorithm used in the
> datatable component only saves 4 values of every child that implements
> EditableValueHolder interface:
>
> - value
> - localValueSet
> - valid
> - submittedValue
>
> All other attributes in the component are shared between rows. To
> overcome this problem, it was added a property called
> "rowStatePreserved" that uses state saving algorithm to save and
> restore the component state.
>
> Unfortunately, "rowStatePreserved" was never included in ui:repeat, so
> it was created this issue:
>
>
> regards,
>
> Leonardo Uribe
>
> 2014-02-14 10:16 GMT-05:00 Kito Mann <kito.mann_at_virtua.com>:
>>
>> On Fri, Feb 14, 2014 at 4:46 AM, arjan tijms <arjan.tijms_at_gmail.com> wrote:
>>>
>>> Hi,
>>>
>>>
>>> On Friday, February 14, 2014, Kito Mann <kito.mann_at_virtua.com> wrote:
>>>>
>>>> This is probably a stupid question, but can someone tell me how input
>>>> controls keep track or the proper values for the different life cycle
>>>> phrases when they're processed within a DataTable? Reading the code it's
>>>> clear how they are processed, but I don't quite understand where the per-row
>>>> values are handled since there is only one component that must handle all
>>>> rows.
>>>>
>>>
>>> From the top of my head I remember that the state corresponding to such
>>> single component is swapped in and out for each iteration over the data
>>> bound to the DataTable. It's a bit like the flyweight pattern. All the
>>> different component values corresponding to all rows are kept in a big state
>>> array that's managed by the DataTable.
>>
>>
>> I realized it was the flyweight pattern, but I couldn't find the actual code
>> where the state was being restored. I guess I should have just read through
>> all of UIData instead of stepping through the code -- all of the magic was
>> happening in setRowIndex(), which calls the methods for saving and restoring
>> state (at least in MyFaces).
>>
>> I'm basically just trying to figure out how to get the value of a component
>> inside of the DataTable inside of a method that's called after validation
>> has occurred. Looks like invokeOnComponent will do because it handles the
>> state management for the rows.
>>>
>>>
>>> Kind regards,
>>> Arjan Tijms
>>>
>>>
>>>>
>>>>
>>>>
>>>> --
>>>> ___
>>>>
>>>> Kito D. Mann | @kito99 | Author, JSF in Action
>>>> Virtua, Inc. | http://www.virtua.com | JSF/Java EE training and
>>>> consulting
>>>> http://www.JSFCentral.com | @jsfcentral
>>>> +1 203-998-0403
>>>>
>>>> * Listen to the Enterprise Java Newscast:
>>>> http://www.enterprisejavanews.com
>>>> * JSFCentral Interviews Podcast:
>>>> http://www.jsfcentral.com/resources/jsfcentralpodcasts/
>>>> * Sign up for the JSFCentral Newsletter:
>>>> http://oi.vresp.com/?fid=ac048d0e17
>>>>
>>