wood burning stoves 2.0*
The moose likes JSF and the fly likes h:selectOneListbox - causing navigation to fail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:selectOneListbox - causing navigation to fail" Watch "h:selectOneListbox - causing navigation to fail" New topic
Author

h:selectOneListbox - causing navigation to fail

Ayan Afridi
Greenhorn

Joined: Jan 18, 2005
Posts: 24
Hi,
I have come across a peculiar problem that probably has to do with the JSF lifecycle. Someone here might have some more insight.

I have an update detail page which is updating to a table. In this page, there is a selectOneListBox, whose value is set by a function called getFlowClassification(). What this does is resolve a key to a name, because in the list box there are names, not keys. So for example:

<h:selectOneListbox id="listbox2" value="#{flowFactAction.flowFactBean.flowProductName}" >
<f:selectItems value="#{flowFactAction.adjustmentsInit.flowProducts}"/>
</h:selectOneListbox>

The list returned by "flowProducts" comtains Names, not keys, so that is why I need this function, so the selectOneListBox can have the correct name picked when entering this page.

This works fine - the problem is when I add a navigation button or link to go back to the list of items. ie:

<h:commandLink id="link1" action="#{flowFactAction.cancelUpdateMappingDetail}">
<hutputText id="text6" value="BACK TO LIST"></hutputText>
</h:commandLink>

When I click this link, it just brings me back to this current detail page, and doesnt bring me back to the datatable listing. If I remove the "value="#{flowFactAction.flowFactBean.flowProductName}" " from the selectOneListBox, voila - problem solved, and I can return to the list. But I need to have the value selected upon entry into the page.

Any idea what the hay is goin on?

-Ayan
Sergey Smirnov
Ranch Hand

Joined: May 29, 2003
Posts: 167
Most often, an undefined converter causes such problem, but not always.
First of all, try to determine the problem putting <h:messages /> somewhere on the page. If conversion problem exists, the message should be shown.
If nothing is shown try to understand on which phase the lifecicle is broken. You can do it phase listener tracker. Take the ready-to-use one from:
http://www.jsftutorials.net/faces-config/phaseTracker.html
The next steps should depends of the phase.
Ayan Afridi
Greenhorn

Joined: Jan 18, 2005
Posts: 24
I don't have a solution as to why I was experiencing this behavior, but I have achieved what I was looking for.

Basically I needed a list item to resolve to a key/id, and a key/id to resolve to a list item. I was unaware that the "SelectItem" class allows this functionality by its construction: new SelectItem(key, label)
So if you assign the value of the selectOneMen as the key, in the detail, the correct label will be highlighted, and upon save, the correct key will be saved.

-Ayan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: h:selectOneListbox - causing navigation to fail