selectOneListbox - strange problem - selectitems
Hello,
I have been playing with such a thing in selectOneListbox:
I encouter problem if I select an option in a selectOneListbox. In such a case, the page (bean) runs without any error or exception but it is terminated somewhere quite early (before the getSelectedItem() method or button_action() method come to processing) - and the page is displayed as if everything was ok...
If I fill in the form and skip the listbox (do not select anything), everything goes well!
Here is the jsp code:
<h:selectOneListbox id="name" size="7" styleClass="listbox" value="#{insert.selectedTaxon}" title="select one option">
<f:selectItems value="#{insert.taxons}"/>
</h:selectOneListbox>
[891 byte] By [
honzaa] at [2007-11-27 4:55:34]

# 1
The problem should not be with the selectItems because the items are displayed allright.
The problem might be in the setSelectedTaxon() setter because it is not called:
public void setSelectedTaxon(String taxon)
{
selectedTaxon = taxon;
}
But this seems to be allright too...
honzaa at 2007-7-12 10:10:32 >

# 7
Ok, now it seems to be working!
The problem was my setter/getter method was for the Type of Integer (I used a piece of code from RadioButtonList which I had already got work and it uses Integer).
Shame as I carefully read this http://java.sun.com/javaee/javaserverfaces/1.1/docs/tlddocs/h/selectOneListbox.html several times - mainly the paragraph related to the "value" attribute. It must be STRING.
But what is strange is that JSF accepted the Integer whereas e.g. SelectItem not (threw an error page). Perhaps due to toString() method which is quite "straightforward" in the case of Integer.
Thank you,
Jan
honzaa at 2007-7-12 10:10:33 >

# 8
Correction - message for the next generations :-):
Actually, the problem was in the SelectItem list! As I wrote in my previous post, the SelectOneListbox requires an object of type String as a value of the value attribute.
Therefore your SelectItem list (taxons in my case) must be of type [String, String].
I had [Integer, String] which was incorrect but no exception was thrown. Just while (automatic) validation.
honzaa at 2007-7-12 10:10:33 >
