Lets say I have three inputs in a modal dialog panel:
Field A:
<h:inputText id="fieldA" value="#{callbackDialog.fieldA}" required="true">
Field B:
<h:inputTextarea id="fieldB" value="#{callbackDialog.fieldB}" required="false" rows="4" onkeyup="this.value = this.value.substring(0, 255);"/>
Field C:
<h:selectOneMenu id="fieldC" value="#{callbackDialog.fieldC}" required="true">
<s:selectItems value="#{callbackDialog.fieldCList}"
var="fieldC"
label="#{fieldC.name}"
hideNoSelectionLabel="true"
noSelectionLabel="Empty"/>
<s:convertEntity />
</h:selectOneMenu>t>
I also have a Cancel button on the modal panel:
<a4j:commandLink styleClass="btn-standard"
immediate="true"
action="#{generalDialogAction.forwardCancelButton()}"
oncomplete="#{rich:component('modalPanel')}.hide(); Event.stop(event); return false;">
<span><h:outputText value="Cancel"></h:outputText></span>
</a4j:commandLink>
Now field A and C are required fields. Is there a generic way in which a button (the Cancel button in this case) can check which input fields on a page are required, and if they are, clear their values when Cancel is clicked? Please help!
Just a guess… try,