It looks like you have a good usecase setup for showing the error, but I
don't think the selectOneRadio component should enforce the use of a
converter if the value is not a string-- EL can handle putting anything
to a String without explicit converters.
[cc'ing MyFaces Dev]
-- Jacob
Mike Lewis wrote:
Hi all
I've got a simple form that contains a selectOneMenu and
selectOneRadio with required="true" attributes and a commandButton.
The page also contains 3 links to the same form:
<!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">
<head>
<title>
Choose a Pet
</title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<p>
Choose a Pet
</p>
<p>
<form jsfc="h:form" id="petForm">
Pet Type
<h:selectOneMenu id="type" value="#{testController.type}"
required="true">
<f:selectItems value="#{testController.typeItems}"/>
</h:selectOneMenu>
<br/>
Pet Color
<h:selectOneRadio id="color" layout="lineDirection"
value="#{testController.color}" required="true">
<f:selectItems value="#{testController.colorItems}"/>
</h:selectOneRadio>
<br/>
<p>
<input jsfc="h:commandButton" id="submit" type="submit"
value="Submit" action="showTestForm"/>
</p>
</form>
</p>
<p>
<span jsfc="h:messages" id="errorMessages"
errorClass="errorMessage" showDetail="true" showSummary="false"/>
</p>
<a href="testForm.jsf">plain reload</a><br/>
<a jsfc="h:outputLink" href="testForm.jsf">outputLink reload</a><br/>
<form jsfc="h:form" id="linkForm">
<a jsfc="h:commandLink" href="testForm.jsf"
action="showTestForm">commandLink reload</a>
</form>
</body>
</html>
When I submit the form with no selections made, the form is
redisplayed with error messages as expected. Now if I click on the
"plainReload" or "outputLink" hyperlinks, I get the following error:
Value is no String and component petForm:colorwith path:
{Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId:
/testForm.xhtml][Class: javax.faces.component.html.HtmlForm,Id:
petForm][Class: javax.faces.component.html.HtmlSelectOneRadio,Id:
color]} does not have a Converter
Opening the Component Tree tab on the error page I get the following:
<UIViewRoot locale="en" renderKitId="HTML_BASIC" rendered="true"
transient="false" viewId="/testForm.xhtml">
<!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"> <head> <title> Choose
a Pet </title> <link rel="stylesheet" type="text/css"
href="styles.css"/> </head> <body> <p> Choose a Pet </p> <p>
<HtmlForm enctype="application/x-www-form-urlencoded" id="petForm"
rendered="true" submitted="false" transient="false">
Pet Type
<HtmlSelectOneMenu disabled="false" id="type"
immediate="false" localValueSet="false" readonly="false"
rendered="true" required="true" submittedValue=""
transient="false" valid="true">
<UISelectItems id="_id3" rendered="true" transient="false"/>
</HtmlSelectOneMenu>
<br/> Pet Color
<HtmlSelectOneRadio border="-2147483648" disabled="false"
id="color" immediate="false" layout="lineDirection"
localValueSet="false" readonly="false" rendered="true"
required="true"
submittedValue="[EMAIL PROTECTED]"
transient="false" valid="true">
<UISelectItems id="_id5" rendered="true" transient="false"/>
</HtmlSelectOneRadio>
<br/> <p>
<HtmlCommandButton action="showTestForm" disabled="false"
id="submit" immediate="false" readonly="false" rendered="true"
transient="false" type="submit" value="Submit"/>
</p>
</HtmlForm>
</p> <p>
<HtmlMessages errorClass="errorMessage" globalOnly="false"
id="errorMessages" layout="list" rendered="true" showDetail="true"
showSummary="false" tooltip="false" transient="false"/>
</p> <a href="testForm.jsf">reload</a><br/>
<HtmlOutputLink id="_id10" rendered="true" transient="false">
reload
</HtmlOutputLink>
<br/>
<HtmlForm enctype="application/x-www-form-urlencoded"
id="linkForm" rendered="true" submitted="false" transient="false">
<HtmlCommandLink action="showTestForm" id="_id13"
immediate="false" rendered="true" transient="false">
another reload
</HtmlCommandLink>
</HtmlForm>
</body> </html>
</UIViewRoot>
The culprit appears to be the value of the selectOneRadio component
which is an instance of
org.apache.myfaces.shared_impl.renderkit.RendererUtils instead of null.
This doesn't occur with the commandLink but it does if you re-enter
the url in the browser's command textbox so there's no safe workaround
that I can see.
Sorry for the noise if this is a myfaces/JSF error.
Thanks,
Mike
--
--------------------------
Sent from my FrankenBerry Wireless Handheld