restoring values from managed bean

i have a page with the list of all rows that i want to display as a dataTable.

After the user clicks on the commandlink in the specified row, he gets redirected to a new page with detail information. On this second page there are two selectOneMenu components. The first one changes the values for the second one. When I click on the detail link i get a new page(with details) with the right values. But whenever i change the value in my first selectOneMenu and the form is submitted i get exception saying that the values for selectOneMenu are null. Could you please explain to me how to get this values set?

On my first jsp page i hava a datatable:

<h:dataTable id="travelTable"

value="#{travelDetailsView.travels}"

binding="#{travelDetailsView.travelDataTable}"

var="vartravelRow" >

....columns

<h:commandLink id="details" action="showTravel" actionListener="#{travelDetailsView.showTravel}" value="details" onmousedown="doSubmit()">

detail page:

<h:selectOneMenu id="hotelMenu" value="#{travelDetailsView.travelRow.hotelId}"

onchange="submit();" valueChangeListener="#{travelDetailsView.hotelValueChange}"><f:selectItem itemLabel="choose hotel" itemValue="0"/>

<f:selectItems value="#{travelDetailsView.travelRow.hotels}"/>

</h:selectOneMenu>

<h:selectOneMenu id="apartmentMenu" onchange="submit();" >

<f:selectItem itemLabel="choose apartment" itemValue="0"/>

<f:selectItems value="#{travelDetailsView.travelRow.selectedHotelRow.apartments}"/>

</h:selectOneMenu>

and coresponding managed-bean:

private TravelRow travelRow;

private DataModel travelModel =new ListDataModel();

private TravelDataJBean travelJBean=new TravelDataJBean();

private HtmlDataTable travelDataTable;

publicvoid showTravel(ActionEvent event)throws Exception{

travelRow=(TravelRow)travelModel.getRowData();

}

publicvoid hotelValueChange(ValueChangeEvent event){

Integer oldValue = (Integer) event.getOldValue();

Integer newValue = (Integer) event.getNewValue();

travelRow.setHotelId(newValue);

FacesContext context = FacesContext.getCurrentInstance();

context.renderResponse();

}

the problem is gone when the managed bean is session scoped but i want it to be request. I know that after changing the value in the hotelMenu the travelRow is somehow lost. So is there a solution to have it restored somehow?

[3553 byte] By [h0rn3ta] at [2007-11-27 7:30:17]
# 1

You really need session scope since you are trying to keep information across two separate transactions associated with the details page (initial render and then the subsequent command selection).

The other option is to cache your data object and let the bean in request scope go get it on each request. This is the largest JSF problem I always see encountered. There are a variety of work arounds most notable is JBoss Seam's conversational scope.

smurray_eriea at 2007-7-12 19:10:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...