3 Replies Latest reply on Apr 12, 2006 4:56 AM by Per Wiklander

    Converting from EJB collections to JSF models -- technique

    Uhyon Chung Newbie

      I had this problem where I needed to create TreeModel (for the tree component, in fact for Oracle ADF), and I didn't want to create it directly from the EJB code. I don't think this is usually an issue since you usually separate the web code from the EJB code.

      I'm still pretty new to JSF, so I don't quite understand all the intricacies involved, so I'm not sure if this is the best way, so maybe someone could point to me in a better direction...

      The way I thought of was to create an EL function that'd convert from a collection to a TreeModel (or which ever JSF model types you needed). You could pass in the necessary parameters (such as children property name) to make this work.

      Any thoughts?

        • 1. Re: Converting from EJB collections to JSF models -- techniq
          Gavin King Master

          I don't think you can use EL for this. Basically, do it the same way you would do it in plain JSF, ie, write code to build up the TreeModel.

          • 2. Re: Converting from EJB collections to JSF models -- techniq
            Uhyon Chung Newbie

            I've tried it with EL functions (that is you can declare EL functions in the taglib) and it seems to work fine. I've created a a few that would make it easier to separate out the Faces code as much as possible.

            One of the main reasons for doing it this way is the fact that the TreeModel I'm using is Oracle ADF dependent. This would mean that I need to put the ADF Jar in the ear (as opposed to WEB-INF/lib) in order for it to be accessible from my ejb jar (and of course update the manifest file). Either that or create separate beans in the WEB-INF/classes directory (that creates the TreeMode from the data from EJB), which means I have to create another bean in the web portion... One of the main (among many I might add) attractions of Seam is reduce the amount of coding spread.

            I think Seam is wonderful, and I believe it'd be worthwhile to go that last mile and try to remove the EJB-JSF/Web dependency (or as much as is practical).

            • 3. Re: Converting from EJB collections to JSF models -- techniq
              Per Wiklander Newbie

              Would you like to post your functions somewhere for the rest of us to have a look at them? I'm sure you could make a page about it in the seam wiki for example.