You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Simon Lessard <si...@gmail.com> on 2008/10/19 16:33:59 UTC

JSF 2.0 DataModel.iterator strategy

Hi all,

JSF 2.0 make DataModel implements Iterable. It's great, but implies adding
an iterator() method to DataModel and achieving that isn't all that great. I
see 3 ways:

1. Loops through all the row data and place it in an internal collection for
the iterator to use. I don't think that solution is viable as it prevent
lazy loading that could be used in some implementations.
2. Link the iterator to the model so that it use getRowCount, setRowIndex
and getRowData method. This method look good, but since looping alter the
row index, I see some potential thread safety issues. So that solution imply
making setRowIndex synchronized and have Iterator.next synchronize on the
model before extract the next value.
3. Ask the EG to add DataModel.getRowData(int index) to DataModel class.

I like 3, but will implement 2 until I can corrupt the EG into adding the
method. But first, does anyone see something I'm not?


Regards,

~ Simon

Re: JSF 2.0 DataModel.iterator strategy

Posted by Simon Lessard <si...@gmail.com>.
After some more thought, I think the iterator is meant to alter the current
rowIndex and not restore it after returning. The spec is SO crystal clear
about that...

On Sun, Oct 19, 2008 at 10:35 AM, Simon Lessard
<si...@gmail.com>wrote:

> Actually, I just figured setRowIndex is abstract so I don't think I can
> force synchronization, so I'm screwed... I need your imagination there guys.
>
>
> ~ Simon
>
>
> On Sun, Oct 19, 2008 at 10:33 AM, Simon Lessard <simon.lessard.3@gmail.com
> > wrote:
>
>> Hi all,
>>
>> JSF 2.0 make DataModel implements Iterable. It's great, but implies adding
>> an iterator() method to DataModel and achieving that isn't all that great. I
>> see 3 ways:
>>
>> 1. Loops through all the row data and place it in an internal collection
>> for the iterator to use. I don't think that solution is viable as it prevent
>> lazy loading that could be used in some implementations.
>> 2. Link the iterator to the model so that it use getRowCount, setRowIndex
>> and getRowData method. This method look good, but since looping alter the
>> row index, I see some potential thread safety issues. So that solution imply
>> making setRowIndex synchronized and have Iterator.next synchronize on the
>> model before extract the next value.
>> 3. Ask the EG to add DataModel.getRowData(int index) to DataModel class.
>>
>> I like 3, but will implement 2 until I can corrupt the EG into adding the
>> method. But first, does anyone see something I'm not?
>>
>>
>> Regards,
>>
>> ~ Simon
>>
>
>

Re: JSF 2.0 DataModel.iterator strategy

Posted by Simon Lessard <si...@gmail.com>.
Actually, I just figured setRowIndex is abstract so I don't think I can
force synchronization, so I'm screwed... I need your imagination there guys.


~ Simon

On Sun, Oct 19, 2008 at 10:33 AM, Simon Lessard
<si...@gmail.com>wrote:

> Hi all,
>
> JSF 2.0 make DataModel implements Iterable. It's great, but implies adding
> an iterator() method to DataModel and achieving that isn't all that great. I
> see 3 ways:
>
> 1. Loops through all the row data and place it in an internal collection
> for the iterator to use. I don't think that solution is viable as it prevent
> lazy loading that could be used in some implementations.
> 2. Link the iterator to the model so that it use getRowCount, setRowIndex
> and getRowData method. This method look good, but since looping alter the
> row index, I see some potential thread safety issues. So that solution imply
> making setRowIndex synchronized and have Iterator.next synchronize on the
> model before extract the next value.
> 3. Ask the EG to add DataModel.getRowData(int index) to DataModel class.
>
> I like 3, but will implement 2 until I can corrupt the EG into adding the
> method. But first, does anyone see something I'm not?
>
>
> Regards,
>
> ~ Simon
>