Description
The tag allows partial validation and model update. Components will be validated and updated only if either a child-component of this form caused the submit of the form, or an extended commandLink or commandButton with the actionFor attribute set to the client-id of this component was used. There can be several comma-separated entries in the actionFor-attribute - with this, it's possible to validate and update more than one subForm at once.
API
component-family | org.apache.myfaces.SubForm |
renderer-type | org.apache.myfaces.SubForm |
component-class | org.apache.myfaces.custom.subform.SubForm |
renderer-class | org.apache.myfaces.custom.subform.SubFormRenderer |
tag-class | org.apache.myfaces.custom.subform.SubFormTag |
Usage
Submit from outside the subForm:<h:form> <t:subForm id="subFormId"> <h:inputText value="#{bean.value}" /> </t:subForm> <t:commandButton value="Submit subForm" actionFor="subFormId"/> </h:form>
<h:form> <t:subForm id="subFormId"> <h:inputText value="#{bean.value}" /> <t:commandButton value="Submit subForm"/> </t:subForm> </h:form>
<h:form> <t:subForm id="subFormId" preserveSubmittedValues="false"> <h:inputText value="#{bean.value}" /> <t:commandButton value="Submit subForm"/> </t:subForm> </h:form>
Additional Information
There are cases when the subForm needs to be submitted not just by clicking a button inside or outside of it, but by clicking or changing fields like combo-boxes, check-boxes or radio-buttons, or many other fields; usualy this is done by invoking a JavaScript code in their "onchange" attribute for example. It's possible to submit the subForm also by JavaScript, if id="subFormId" then you just have to invoke "subFormId_submit()". For an example see subForm.jsp in the Tomahawk examples.