I'm not sure which entry on the Wiki Dennis is referring to. The rowIndex property is only valid while the datatable is iterating over its rows. You can therefore access it from within action/actionListener methods attached to components within the table, but not later.
You therefore need to have some kind of action method associated with the commandLink which stores the value away for later use. A t:updateActionListener is useful for this. You'll find more info on this topic in the email archives. Regards, Simon On Wed, 2006-01-04 at 05:24 +0000, Dennis Byrne wrote: > There is a wiki article on this. My favorite is #2. > > >-----Original Message----- > >From: Tom Butler [mailto:[EMAIL PROTECTED] > >Sent: Wednesday, January 4, 2006 12:13 AM > >To: ''MyFaces Discussion'' > >Subject: RE: referencing a managed bean property problem > > > >Simon, > > > >I have a follow up question to this: I have a .jsf page that displays a > >datatable (listdatamodel) showing rows of names. At the end of each row I > >display a commandlink with the value 'select' that allows the user to select > >a name. After they select a name, I want to take them to a second page to > >show details for the selected value. > > > >Here is the commandlink from the first .jsf page: > > > ><h:commandLink action="selectprovider" value="#{messages['sort_select']}" /> > > > >On the second .jsf page, I access the same bean as was used for the first > >.jsf page - I want to access the row index that the user selected from the > >first page. Here's what I've tried and values I receive > >(searchproviders_bean = bean from 1st page; dm_searchresults = > >listdatamodel) > > > ><h:outputText value="#{searchproviders_bean.dm_searchresults.rowIndex}"/> > >Always returns -1 > > > ><h:outputText value="#{searchproviders_bean.dm_searchresults.rowCount}"/> > >Returns correct # of total rows > > > ><h:outputText > >value="#{searchproviders_bean.dm_searchresults.getRowIndex()}"/> > >Returns error - assume cannot call method > > > >What is the best way to pass the id of a selected row from a datatable to > >the second .jsf page? > > > >Thanks > >Tom > > > > > > > >-----Original Message----- > >From: Simon Kitching [mailto:[EMAIL PROTECTED] > >Sent: Tuesday, January 03, 2006 4:26 PM > >To: MyFaces Discussion > >Subject: Re: referencing a managed bean property problem > > > >Hi, > > > >I don't think that the syntax "#{savingsBean.recentBlogEntries[row]}" is > >allowed. EL doesn't support passing parameters to methods, just > >reading/writing *simple* properties. > > > >I presume your #{savingsBean.savingsList} method returns a List. > >You could add a method to your savingsBean that returns a ListDataModel > >instance rather than a List, and specify that in the h:dataTable's > >"value" attribute. You can then write a getRecentBlogEntries method > >which accesses that ListDataModel object to get the current rowData or > >rowIndex properties. These refer to the row currently being rendered at > >the time the getRecentBlogEntries method is invoked. > > > > > >Regards, > > > >Simon > > > >Alexandre Poitras wrote: > >> I can see one quick mistake: > >> #{savingsBean.recentBlogEntries[#{row}]} should be > >> #{savingsBean.recentBlogEntries[row]} > >> > >> On 1/3/06, Marco Mistroni <[EMAIL PROTECTED]> wrote: > >>> hello all, > >>> this code results in an error > >>> > >>> <f:view> > >>> <h:form id="savingsForm"> > >>> <h:dataTable value="#{savingsBean.savingsList}" var="row" > >border="1"> > >>> <h:column> > >>> <h:outputText value="#{row}"/> > >>> </h:column> > >>> <h:column> > >>> <h:inputText value="#{savingsBean.recentBlogEntries[#{row}]}"/> > >>> </h:column> > >>> </h:dataTable> > >>> <h:panelGroup> > >>> <h:commandButton id="submitInsert" action="#{savingsBean.insert}" > >>> value="Insert"/> > >>> </h:panelGroup> > >>> </h:form> > >>> </f:view> > >>> > >>> > >>> at this point > >>> > >>> <h:inputText value="#{savingsBean.recentBlogEntries[#{row}]}"/ > >>> > >>> recentBlogEntries is a Map. i tried, for hte sake of trying, to put in a > >>> List (savingsList, the one used for DataTable)all keys > >>> of the Map, and tried to generate inputText for the Map by passing the > >value > >>> of #{row} (which woul dbe the key of the map) > >>> > >>> it didnt work out..... is that impossible or is my syntax wrong somehow? > >>> > >>> thanks and regards > >>> marco > >> > >> > >> -- > >> Alexandre Poitras > >> Québec, Canada > >> > >> > > > > > >

