This content has been marked as final.
Show 2 replies
-
1. Re: Rendered option
niox.nikospara.yahoo.com Jun 18, 2009 3:18 PM (in response to thiagu.m)Hi,
One solution with RichFaces would be:
<h:selectOneMenu value="#{bean.type}"> <f:selectItem itemLabel="Y only" value="Y_ONLY" /> <f:selectItem itemLabel="X only" value="X_ONLY" /> <f:selectItem itemLabel="Both" value="BOTH" /> <a:support event="onchange" reRender="xval,yval" /> </h:selectOneMenu> <h:inputText id="xval" disabled="#{bean.type == 'Y_ONLY'}" ... /> <h:inputText id="yval" disabled="#{bean.type == 'X_ONLY'}" ... />
But this requires a roundtrip to the server. It can be done with JS:
<h:selectOneMenu value="#{bean.type}" onchange="disableControl(this.value)" > <f:selectItem itemLabel="Y only" value="Y_ONLY" /> <f:selectItem itemLabel="X only" value="X_ONLY" /> <f:selectItem itemLabel="Both" value="BOTH" /> <a:support event="onchange" reRender="xval,yval" /> </h:selectOneMenu> <h:inputText id="xval" ... /> <h:inputText id="yval" ... />
And the JS function would be like (you have to complete various parts, like the input ids):
<script> function disableControl(val) { var xControl = document.getElementById("....:xval"); var yControl = document.getElementById("....:yval"); if( val == "Y_ONLY" ) { xControl.disabled = true; yControl.disabled = false; } else if( val == "X_ONLY" ) { ... } else { ... } } </script>
I am not aware of Drools support for what you ask. It can be done, but you would have to write the plumbing code.
-
2. Re: Rendered option
thiagu.m Jun 18, 2009 3:32 PM (in response to thiagu.m)thank u for Ur reply
i am going to try with try with script.