Volker Weber wrote:
Hi Susan,
Susan Cline wrote:
Hi,
Here's the use of the saveState in the FlightList.jsp
file:
<t:saveState value="#{flightConfig}" />
<t:saveState value="#{flight}" />
Within this page I'm using a datatable to get the
available flights in the flightConfig bean:
<t:dataTable id="data" styleClass="scrollerTable"
headerClass="standardTable_Header"
footerClass="standardTable_Header"
rowClasses="standardTable_Row1,standardTable_Row2"
columnClasses="standardTable_ColumnCentered,standardTable_ColumnCentered,standardTable_ColumnCentered,standardTable_ColumnCentered,standardTable_ColumnCentered"
var="flight" value="#{flightConfig.availableFlights}"
preserveDataModel="false" rows="5">
<h:column>
<h:commandLink action="#{flight.selectedFlight}" >
<h:outputText
value="#{flight.flightId}" />
</h:commandLink>
the saveState tag does not work for the datatables local variable
'flight'. This bean is set into request(?) by the datatable before
processing each row and i think it should removed after then.
Did you get an exception when accessing the 'flight' bean on your
CreditCard.jsp page?
Ahh .. I didn't see that #{flight} is the "row variable" for the table.
Yes, I agree with Volker that this won't work; that variable only exists
while the row is being rendered.
Are you trying to figure out which row was selected when the link was
clicked? If so, you can do this by accessing the table component or the
DataModel of that table from the #{flight.selectedFlight} method.
Is method #{flightConfig.availableFlights} returning a DataModel object?
If so, then in your #{flight.selectedFlight} method you just need to ask
that DataModel object what the current row is by calling getRowData() or
getRowIndex(). This works because the link is "immediate". The table
repeats the following for each row:
* set row index
* ask all children of the table to process themselves
When the row with the clicked link is processed, the action callback is
executed - and the table's rowIndex (and thus rowData) field is
referring to the row that is being processed.
If you're just returning a List from that method and allowing the table
component to automatically create a DataModel wrapper for the list then
you will instead need to get access to the table by specifying a
"binding" attribute, eg binding="#{flightConfig.table}". Method
FlightConfig.setTable(UIData component) will then be called so that your
backing bean gets a reference to the table component.
I hope this helps.
Regards,
Simon