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
  • parents
  • children
  • clientId
 Use the “type” attribute of composite:attribute to hook the element(s) to bean properties

      <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");
                                }
4.override the getSubmitted values.
                          @Override
                     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
                  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.                                     
                    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

Popular posts from this blog

'jasypt.encryptor.password' or one of ['jasypt.encryptor.privateKeyString', 'jasypt.encryptor.privateKeyLocation'] must be provided for Password-based or Asymmetric encryption

Field or property 'jobParameters' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - Spring Batch

Couldn't store job: Unable to serialize JobDataMap for insertion into database because the value of property 'jobLauncher' is not serializable