Project Documentation

Summary

Tag name: <t:subform>
UIComponent class: org.apache.myfaces.custom.subform.SubForm
Tag class: org.apache.myfaces.custom.subform.SubFormTag
Component type: org.apache.myfaces.SubForm
Component family: org.apache.myfaces.SubForm
Renderer type: org.apache.myfaces.SubForm
Renderer class: org.apache.myfaces.custom.subform.SubFormRenderer

A SubForm which will allow for partial validation and model update.

A subform to an existing form. Inputs in this form will only be validated and updated, if a t:commandButton or t:commandLink has been clicked with an actionFor attribute which references the client-id of this subform. Optionally, the validation will trigger if a commandButton or commandLink embedded in this subform has been clicked, except if this command is a t:commandButton or t:commandLink with an actionFor attribute which doesn't reference the client-id of this subform.

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.

You can have several comma-separated entries in the actionFor-attribute - with this it's possible to validate and update more than one subForm at once.

Usage

<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.

Attributes

Name Type Supports EL? Description
binding org.apache.myfaces.custom.subform.SubForm Only EL Identifies a backing bean property (of type UIComponent or appropriate subclass) to bind " + "to this component instance. This value must be an EL expression.
id String Yes Get a string which uniquely identifies this UIComponent within the scope of the nearest ancestor NamingContainer component. The id is not necessarily unique across all components in the current view.
preserveSubmittedValues Boolean Yes true|false - set to false if you submit other subforms and would like to have your subform reflecting any model update. Default: true
rendered boolean Yes A boolean value that indicates whether this component should be rendered. Default value: true.