the statusid property is an Integer.
What the wiki page suggests, is that the itemValue="#{3}" will return a
valueexpression with
the correct type. My issue seems to be that the valueExpression #{3}
type is actually not Integer, but Long.
Therefore I must use the converter.
I was expecting the #{3} to be of type Integer instead of Long..
With a Long statusid, you don't need to use the explicit converter when
using the #{3}.
What I really want is a way to express an Integer value with a
valueexpression, which in my oppinion
should be #{3}, and the Long value would be #{3L} just like in Java.
-safi
David Delbecq skrev:
does testBean.getStatusId() return a String or a Long? If you don't
specify manually a converter, then JSF will try to find a suitable
converter based on the type of the selectonemenu value (not the select
item value!).
To check submitted value validity, as far as i know, myfaces will
compare the selectItem itemValue converte as String with the submitted
string value. Maybe, without converter, value inside your html form
looks like <option value="[EMAIL PROTECTED]">...</option>?
En l'instant précis du 27/06/07 12:14, Safurudin Mahic s'exprimait en
ces termes:
Ok - I tried to implement the solution -
<h:selectOneMenu id="statusid"
value="#{testBean.statusid}">
<f:selectItem itemValue="#{0}"
itemLabel="Ikke paabegynt" />
<f:selectItem itemValue="#{1}"
itemLabel="Under arbeid" />
<f:selectItem itemValue="#{2}"
itemLabel="Kansellert" />
<f:selectItem itemValue="#{3}"
itemLabel="Utfort" />
<f:convertNumber integerOnly="true"/>
</h:selectOneMenu>
however, I still got the validation error when I didn't use the
explicit f:convertNumber.
I'm guessing the #{0} etc are integer valueexpressions, hence
returning the correct type to the value of
the selectonemenu. Wouldn't the expected behavior be that it works
without the explicit converter?
-safi
Cagatay Civici skrev:
Hi,
Sounds like;
http://wiki.apache.org/myfaces/Tomahawk_1%2e1%2e4_to_1%2e1%2e5
Cagatay
On 6/27/07, *Safurudin Mahic* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
I'm having problems getting a correct form submittal with a simple
selectOneMenu in the latest MyFaces and TomaHawk.
After issuing the command button, I'm getting "Validation Error
"statusid": Value is not a valid option."
The statusid is an Integer value on the backing bean.
In previous versions (1.1.1) this works fine. Doesn't
MyFaces/Tomahawk
in later versions autoconvert strings to integers where appropriate?
My form looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui=" http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core
<http://java.sun.com/jsf/core>"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:acegijsf="http://sourceforge.net/projects/jsf-comp/acegijsf
<http://sourceforge.net/projects/jsf-comp/acegijsf>"
xml:lang="en" lang="en">
<body>
<f:view>
<h:form>
<h:messages globalOnly="false" showDetail="true"
showSummary="true"/>
<h:selectOneMenu id="statusid"
value="#{testBean.statusid}"
styleClass="inputfield_long">
<f:selectItem itemValue="0"
itemLabel="Test1" />
<f:selectItem itemValue="1"
itemLabel="Test2" />
<f:selectItem itemValue="2"
itemLabel="Test3" />
<f:selectItem itemValue="3"
itemLabel="Test4" />
</h:selectOneMenu>
<h:commandButton />
<h:outputText value="#{ testBean.statusid}"></h:outputText>
</h:form>
</f:view>
</body>
</html>