Hi,
This may be a basic question, but I've struggled with
this for a while so I'm hoping someone can help me.
I have a jsp, FlightList.jsp, that uses the saveState
tag
for a managed bean, flightConfig, and for a backing
bean, flight. Also, I'm pretty new to the terminology
as well: here when I say "managed bean" lest I am
using the term wrong is that "flightConfig" is in my
faces-config.xml file with a scope of request.
"flight" is not in my faces-config.xml although it is
serializable, and has one action method.
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>
I assign the variable "flight" to each row which
represents the backing bean, called FlightsBean,
represented by the "flight" in the saveState tag
above.
So the problem I am having is that when the
commandLink with the action flight.selectedFlight is
clicked it essentially just forwards the user to the
next page, called CreditCard.jsp.
CreditCard.jsp has this relevant code:
<t:saveState value="#{creditBean}" />
<t:saveState value="#{flight}" />
When I try to display a value from the flight
variable, representing the FlightsBean I get no
output:
<h:outputText value="this is the flight id:
#{flight.flightId}"></h:outputText>
Nothing appears for the flightId field of flight.
I thought that by using saveState the next page would
have access to the flight variable values?
As a workaround I put this code in the
selectedFlight() action method:
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put("selected-flight",this);
and then on the page where I want to display the
flight use this JSF-EL to display it:
<h:outputText id="flight_id"
value="#{sessionScope['selected-flight'].flightId}" />
Any comments about what is happening with the
saveState tag? Am I not using it correctly?
Also, is the way I am putting the flightBean into the
session object and retreiving it an okay way to do it?
Thanks,
Susan