You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by fischman_98 <mf...@powerconsultantsinc.com> on 2006/12/23 20:17:56 UTC
getRowIndex() = -1 when restoring saved view state
Upon restoring a view from a saved state (see:
http://www.nabble.com/How-can-i-manually-save-and-restore-a-view%27s-state--tf1258390.html#a3414026
manually save and restore a view's state (by: Nico Krijnen) I am seeing
something I don't understand....
I am binding a transient UIData variable to a <t:columns> tag. When the
view is restored, the isRowAvailable() equals true and the getRowCount
equals the number of rows (6 in my case)....but the getRowIndex equals -1
even though the <t:columns> is iterating through all six rows. (I know it's
iterating six times b/c I can see the call to navigatorBean.getMainItemCss
getting called six times - old school printlns!)
Anyone know the reason for this?
In the Managed Bean:
private transient UIData mainColumns;
In the .jsf
<t:dataTable var="mainMenu" cellpadding="0" cellspacing="0" border="0"
value="#{navigatorBean.navigatorBlankRow}">
<t:columns value="#{navigatorBean.navigatorMainItems}" var="mainItems"
styleClass="#{navigatorBean.mainItemCss}"
binding="#{navigatorBean.mainColumns}">
<t:commandLink value="#{mainItems.name}"
title="#{mainItems.label}"
onmouseover="expandcontent('sc#{navigatorBean.mainColumns.rowIndex}',
this)" />
</t:columns>
</t:dataTable>
--
View this message in context: http://www.nabble.com/getRowIndex%28%29-%3D--1-when-restoring-saved-view-state-tf2875166.html#a8036083
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: getRowIndex() = -1 when restoring saved view state
Posted by Mike Kienenberger <mk...@gmail.com>.
I thought that t:columns required that you have t:column elements
inside it, but I haven't used it in awhile. A quick look at the
examples doesn't show that.
I guess I'm wrong. Take a look at the source code for t:columns.
It's likely that the row index isn't being set correctly at that
particular phase. If so, please open a jira issue with either a
patch or standalone code that demonstrates the problem.
On 12/24/06, fischman_98 <mf...@powerconsultantsinc.com> wrote:
>
> Thanks for the response Mike, but the <t:commandLink> IS inside the
> <t:columns>, isn't it? (I re-pasted the example jsf) The UIData binding
> variable is getting a valid (and correct) row(column) index at all other
> times except when the view state is restored using the method (described in
> the original post).
>
> <t:dataTable var="mainMenu" cellpadding="0" cellspacing="0" border="0"
> value="#{navigatorBean.navigatorBlankRow}">
> <t:columns value="#{navigatorBean.navigatorMainItems}"
> var="mainItems"
> styleClass="#{navigatorBean.mainItemCss}"
> binding="#{navigatorBean.mainColumns}">
> <t:commandLink value="#{mainItems.name}"
> title="#{mainItems.label}"
>
> onmouseover="expandcontent('sc#{navigatorBean.mainColumns.rowIndex}', this)"
> />
> </t:columns>
> </t:dataTable>
>
> Off to do some last minute Christmas shopping...Merry Christmas to all!
>
> BTW - I did a hack this way to make it work...since the managed bean is
> request scoped, I declared a private int and initialize it to zero. I
> increment it inside the getMainItemCss() method and if it doesn't equal the
> rowIndex, I set the row index to the to the private int.
>
> private int i = 0;
>
> public String getMainItemCss() {
> ...
> if (mainColumns.getRowIndex() != i)
> mainColumns.setRowIndex(i);
> i++
> ...
>
>
>
>
>
>
>
>
>
> Mike Kienenberger wrote:
> >
> > The rowIndex (really columnIndex) in your example will always remain
> > at -1 because there are no t:column components under t:columns.
> >
> > Put your t:commandLink inside a t:column.
> >
> > On 12/23/06, fischman_98 <mf...@powerconsultantsinc.com> wrote:
> >>
> >> Upon restoring a view from a saved state (see:
> >> http://www.nabble.com/How-can-i-manually-save-and-restore-a-view%27s-state--tf1258390.html#a3414026
> >> manually save and restore a view's state (by: Nico Krijnen) I am seeing
> >> something I don't understand....
> >>
> >> I am binding a transient UIData variable to a <t:columns> tag. When the
> >> view is restored, the isRowAvailable() equals true and the getRowCount
> >> equals the number of rows (6 in my case)....but the getRowIndex equals -1
> >> even though the <t:columns> is iterating through all six rows. (I know
> >> it's
> >> iterating six times b/c I can see the call to
> >> navigatorBean.getMainItemCss
> >> getting called six times - old school printlns!)
> >>
> >> Anyone know the reason for this?
> >>
> >> In the Managed Bean:
> >>
> >> private transient UIData mainColumns;
> >>
> >> In the .jsf
> >>
> >> <t:dataTable var="mainMenu" cellpadding="0" cellspacing="0" border="0"
> >> value="#{navigatorBean.navigatorBlankRow}">
> >> <t:columns value="#{navigatorBean.navigatorMainItems}"
> >> var="mainItems"
> >> styleClass="#{navigatorBean.mainItemCss}"
> >> binding="#{navigatorBean.mainColumns}">
> >> <t:commandLink value="#{mainItems.name}"
> >> title="#{mainItems.label}"
> >>
> >> onmouseover="expandcontent('sc#{navigatorBean.mainColumns.rowIndex}',
> >> this)" />
> >> </t:columns>
> >> </t:dataTable>
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/getRowIndex%28%29-%3D--1-when-restoring-saved-view-state-tf2875166.html#a8036083
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/getRowIndex%28%29-%3D--1-when-restoring-saved-view-state-tf2875166.html#a8042761
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>
Re: getRowIndex() = -1 when restoring saved view state
Posted by fischman_98 <mf...@powerconsultantsinc.com>.
Thanks for the response Mike, but the <t:commandLink> IS inside the
<t:columns>, isn't it? (I re-pasted the example jsf) The UIData binding
variable is getting a valid (and correct) row(column) index at all other
times except when the view state is restored using the method (described in
the original post).
<t:dataTable var="mainMenu" cellpadding="0" cellspacing="0" border="0"
value="#{navigatorBean.navigatorBlankRow}">
<t:columns value="#{navigatorBean.navigatorMainItems}"
var="mainItems"
styleClass="#{navigatorBean.mainItemCss}"
binding="#{navigatorBean.mainColumns}">
<t:commandLink value="#{mainItems.name}"
title="#{mainItems.label}"
onmouseover="expandcontent('sc#{navigatorBean.mainColumns.rowIndex}', this)"
/>
</t:columns>
</t:dataTable>
Off to do some last minute Christmas shopping...Merry Christmas to all!
BTW - I did a hack this way to make it work...since the managed bean is
request scoped, I declared a private int and initialize it to zero. I
increment it inside the getMainItemCss() method and if it doesn't equal the
rowIndex, I set the row index to the to the private int.
private int i = 0;
public String getMainItemCss() {
...
if (mainColumns.getRowIndex() != i)
mainColumns.setRowIndex(i);
i++
...
Mike Kienenberger wrote:
>
> The rowIndex (really columnIndex) in your example will always remain
> at -1 because there are no t:column components under t:columns.
>
> Put your t:commandLink inside a t:column.
>
> On 12/23/06, fischman_98 <mf...@powerconsultantsinc.com> wrote:
>>
>> Upon restoring a view from a saved state (see:
>> http://www.nabble.com/How-can-i-manually-save-and-restore-a-view%27s-state--tf1258390.html#a3414026
>> manually save and restore a view's state (by: Nico Krijnen) I am seeing
>> something I don't understand....
>>
>> I am binding a transient UIData variable to a <t:columns> tag. When the
>> view is restored, the isRowAvailable() equals true and the getRowCount
>> equals the number of rows (6 in my case)....but the getRowIndex equals -1
>> even though the <t:columns> is iterating through all six rows. (I know
>> it's
>> iterating six times b/c I can see the call to
>> navigatorBean.getMainItemCss
>> getting called six times - old school printlns!)
>>
>> Anyone know the reason for this?
>>
>> In the Managed Bean:
>>
>> private transient UIData mainColumns;
>>
>> In the .jsf
>>
>> <t:dataTable var="mainMenu" cellpadding="0" cellspacing="0" border="0"
>> value="#{navigatorBean.navigatorBlankRow}">
>> <t:columns value="#{navigatorBean.navigatorMainItems}"
>> var="mainItems"
>> styleClass="#{navigatorBean.mainItemCss}"
>> binding="#{navigatorBean.mainColumns}">
>> <t:commandLink value="#{mainItems.name}"
>> title="#{mainItems.label}"
>>
>> onmouseover="expandcontent('sc#{navigatorBean.mainColumns.rowIndex}',
>> this)" />
>> </t:columns>
>> </t:dataTable>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/getRowIndex%28%29-%3D--1-when-restoring-saved-view-state-tf2875166.html#a8036083
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/getRowIndex%28%29-%3D--1-when-restoring-saved-view-state-tf2875166.html#a8042761
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: getRowIndex() = -1 when restoring saved view state
Posted by Mike Kienenberger <mk...@gmail.com>.
The rowIndex (really columnIndex) in your example will always remain
at -1 because there are no t:column components under t:columns.
Put your t:commandLink inside a t:column.
On 12/23/06, fischman_98 <mf...@powerconsultantsinc.com> wrote:
>
> Upon restoring a view from a saved state (see:
> http://www.nabble.com/How-can-i-manually-save-and-restore-a-view%27s-state--tf1258390.html#a3414026
> manually save and restore a view's state (by: Nico Krijnen) I am seeing
> something I don't understand....
>
> I am binding a transient UIData variable to a <t:columns> tag. When the
> view is restored, the isRowAvailable() equals true and the getRowCount
> equals the number of rows (6 in my case)....but the getRowIndex equals -1
> even though the <t:columns> is iterating through all six rows. (I know it's
> iterating six times b/c I can see the call to navigatorBean.getMainItemCss
> getting called six times - old school printlns!)
>
> Anyone know the reason for this?
>
> In the Managed Bean:
>
> private transient UIData mainColumns;
>
> In the .jsf
>
> <t:dataTable var="mainMenu" cellpadding="0" cellspacing="0" border="0"
> value="#{navigatorBean.navigatorBlankRow}">
> <t:columns value="#{navigatorBean.navigatorMainItems}" var="mainItems"
> styleClass="#{navigatorBean.mainItemCss}"
> binding="#{navigatorBean.mainColumns}">
> <t:commandLink value="#{mainItems.name}"
> title="#{mainItems.label}"
> onmouseover="expandcontent('sc#{navigatorBean.mainColumns.rowIndex}',
> this)" />
> </t:columns>
> </t:dataTable>
>
> --
> View this message in context: http://www.nabble.com/getRowIndex%28%29-%3D--1-when-restoring-saved-view-state-tf2875166.html#a8036083
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>