Hi Anahide,
I made it work. Almost..
This version works (with a textbox):
<a4j:region renderRegionOnly="false">
<h:selectOneRadio id="choose" value="#{bean.a}">
<f:selectItems value="#{bean.map}" />
<a4j:support ajaxSingle="true" event="onchange" reRender="ajaxPanel" />
</h:selectOneRadio><br />
</a4j:region>
<a4j:outputPanel id="ajaxPanel">
<h:inputText id="myInput" value="#{bean.b}" rendered="#{bean.a == 'blue'}"
required="true" />
<h:message for="myInput" />
</a4j:outputPanel><br />
Mandatory field:
<h:inputText value="#{bean.c}" required="true" /><br />
<h:commandButton value="submit" action="submit" />
This version fails in some cases with a Converter exception for the radiobutton
control.
(the only change is the use of radiobuttons instead of a textbox)
<a4j:region renderRegionOnly="false">
<h:selectOneRadio id="choose" value="#{bean.a}">
<f:selectItems value="#{bean.map}" />
<a4j:support ajaxSingle="true" event="onchange" reRender="ajaxPanel" />
</h:selectOneRadio><br />
</a4j:region>
<a4j:outputPanel id="ajaxPanel">
<h:selectOneRadio id="myInput" value="#{bean.b}" rendered="#{bean.a ==
'blue'}"
required="true">
<f:selectItems value="#{bean.map2}" />
</h:selectOneRadio>
<h:message for="myInput" />
</a4j:outputPanel>
<br />
Mandatory field:
<h:inputText value="#{bean.c}" required="true" /><br />
<h:commandButton value="submit" action="submit" />
The exception is:
java.lang.IllegalArgumentException: Value is no String (class=org.apache.myfaces.shared_impl.renderkit.RendererUtils$1,
[EMAIL PROTECTED]) and component myform:myInput with path:
{Component-Path : [Class: org.ajax4jsf.framework.ajax.AjaxViewRoot,ViewId: /ajax.xhtml][Class:
javax.faces.component.html.HtmlForm,Id: myform][Class: org.ajax4jsf.ajax.html.HtmlAjaxOutputPanel,Id: ajaxPanel][Class:
javax.faces.component.html.HtmlSelectOneRadio,Id: myInput]} does not have a Converter
It looks like Jsf/Ajax tries to assign an invalid value (maybe a myfaces radiobutton control ?!) to the SelectOneRadio
button.
Anahide Tchertchian wrote:
Hi,
Not sure what is the right thing to do, haven't played with it much yet.
Perhaps try to use set ajaxSingle="true" to your a4j:support tag (?).
Else you can also have a look at the a4j:region tag:
http://forum.exadel.com/viewtopic.php?p=16463&sid=b7f87fa61126de62a8892227e47004f6
The dev guide may be useful to investigate further:
https://ajax4jsf.dev.java.net/nonav/documentation/ajax-documentation/developerGuide.html
George Lefter a écrit :
Hi,
I have to show/hide a field only if another field has a certain value.
The problem is that ajax requests fail if the form does not validate
(mandatory fields not filled) when the ajax event is triggered.
Has anyone met this before? Any workarounds?
Below is my code; bean.map is a hashMap with values { "Green" =>
"green", "Red" => "red", "Blue" => "blue" }, the other fields, bean.a
and bean.c are simple strings.
<h:form>
Trigger:
<h:selectOneRadio id="choose" value="#{bean.a}">
<f:selectItems value="#{bean.map}" />
<a4j:support event="onchange" reRender="panel" />
</h:selectOneRadio><br />
Show/Hide:
<a4j:outputPanel id="panel">
<h:inputText name="myLabel" value="label" rendered="#{bean.a ==
'blue'}" />
</a4j:outputPanel>
<br />
Mandatory field:
<h:inputText value="#{bean.c}" required="true" />
</h:form>
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm