3 Replies Latest reply: Apr 6, 2013 8:11 AM by gimbal2 RSS

    Generic controller

    Zlaja
      Hi,

      I want to bind UI component to generic controller.

      Is ti posible to have generic call in EL?

      For example, instead of

      #{user.name} //this is for get and set

      have something like this

      #{controller.setValue(index,value)} //for setting value
      #{controller.getValue(index)} //for setting value

      It does not have to be EL solution. Any other approach will be fine.


      Thanks for any idea.

      Zlaja
        • 1. Re: Generic controller
          EJP
          I want to bind UI component to generic controller.
          What do you mean by 'generic controller'?
          Is ti posible to have generic call in EL?
          It depends entirely on what you mean by 'generic controler'.
          #{controller.setValue(index,value)} //for setting value
          You can do that from EL 2.2 onwards.
          • 2. Re: Generic controller
            Zlaja
            Generic controller exposes generic api for all UI component:

            setValue(int index, Object value) for setting value
            Object getValue(int index) for getting value.

            Implementation of controller will know that index 0 is name property of domain object( User for example) , index 1 is surname property of domain object and so on.

            UI component will be initialized only with index and controller and will call only these two methods.


            Zlaja
            • 3. Re: Generic controller
              gimbal2
              Zlaja wrote:
              Hi,

              I want to bind UI component to generic controller.

              Is ti posible to have generic call in EL?

              For example, instead of

              #{user.name} //this is for get and set

              have something like this

              #{controller.setValue(index,value)} //for setting value
              #{controller.getValue(index)} //for setting value

              It does not have to be EL solution. Any other approach will be fine.
              Exactly what is the problem? Create your generic controller, make it a JSF backing bean and call the methods at your leasure. As long as you run it on a modern enterprise server or Tomcat 7 (so you have a properly updated EL API), it will work just fine.