JSF Composite Component
"cc" is a predefined variable and stands for Composite Component.It Reffers to the Top Level Component in component file UINaming Container.
Main Property is "attrs" contains a Map of all the properties.Some of the other attributes
<composite:attribute name="value" required="true" type="coreservlets.Nameable"/>
To Create the Backing Bean for the Custom Component Following Steps are important
1. Define the @FacesComponent("full class name") - This Defines the component which is newly created.
2. If Input Component UIInput must be extended and "NamingContainer" should be implemented.
3. Override getFamilyMethod as
Main Property is "attrs" contains a Map of all the properties.Some of the other attributes
- parents
- children
- clientId
<composite:attribute name="value" required="true" type="coreservlets.Nameable"/>
To Create the Backing Bean for the Custom Component Following Steps are important
1. Define the @FacesComponent("full class name") - This Defines the component which is newly created.
2. If Input Component UIInput must be extended and "NamingContainer" should be implemented.
3. Override getFamilyMethod as
public String getFamily()
{
return("javax.faces.NamingContainer");
}
{
return("javax.faces.NamingContainer");
}
4.override the getSubmitted values.
@Override
public Object getSubmittedValue() {
return(this);
}
public Object getSubmittedValue() {
return(this);
}
The Steps 3 and 4 are needed else the component intialization wont happen.
5. Overide encodeBegin(FacesContext context) -- to populate elements in input form so that initial
display corresponds to current bean value
display corresponds to current bean value
Steps to be done inside this function
Find individual input elements with findComponent("id-used-in-composite-component").
Populate them by calling setValue
Call super.encodeBegin at end of method
6. Overide getConvertedValue(FacesContext context) --to take individual submitted values and combine
them into a single bean value.
them into a single bean value.
Steps to be done inside this function
Find individual input elements with findComponent("id-used-in-composite-component").
Find their values with getSubmittedValue
Make an Object and return it from method
Comments
Post a Comment