1 Reply Latest reply on Mar 3, 2011 5:46 PM by Rocky S

    Access to composite component attributtes

    Jakub Pawłowski Newbie



      I have a composite component on page:



              <dc:demoComponent title="Any string here"/>



      This is definiton of this component:


        <!-- INTERFACE -->


            <cc:attribute name="title" required="true"/>


        <!-- IMPLEMENTATION -->



                      <h:outputText value="#{componentBean.outputVal}"/>




      and ManagedBean for this component;




      public class ComponentBean {

          private String outputVal;

          // getters and setters



      My question is: how to get programatically in componentBean values passed to composite component from main page ? I mean something like this:


       CompositeComponent  comp = (CompositeComponent)resolveExpression("#{demoComponent}");

      Map compAttributes = comp.getAttributes();

      String name = compAttributes.get("title");


      Thanks for help


        • 1. Access to composite component attributtes
          Rocky S Master

          use action listener or your managed bean itself to get values-


          action listener, example-


          public class LoginActionListener implements ActionListener {

              public void processAction(ActionEvent event) throws AbortProcessingException {

              UIComponent container = event.getComponent().getNamingContainer();

              String name = (String) ((UIInput)


             String pwd = (String) ((UIInput)


            if (Registrar.isRegistered(name, pwd)) return;

          FacesContext context = FacesContext.getCurrentInstance();


          new FacesMessage("Name and password are invalid. Please try again."));

          throw new AbortProcessingException("Invalid credentials");