2 Replies Latest reply on Jul 6, 2009 8:35 AM by ohughes

    Facelet or JSF Component?

    ohughes

      Hi,


      I have a project which is made up mostly of Facelet components due to their ease of development, but now I need to introduce SEAM into the mix, but it seems that SEAM has a problem with the parameters that are being passed into the facelet, which are generally standard java beans, it resolves these beans to be null, whereas without using seam components they are resolved fine.


      For example, we have an action button facelet component, which takes an ActionButton bean as a parameter, and this bean tells it which image to use, etc, and there is an interface registered with the ActionButton bean which then notifies the listener class when an action is performed, i.e.


      Facelet:



      <ui:composition 
           xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:c="http://java.sun.com/jstl/core"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:ice="http://www.icesoft.com/icefaces/component">
      
           <ui:param name="actionButton" value="#{actionButton}"/>
           <ui:param name="disabled" value="#{disabled}"/>
      
           <ice:commandLink action="#{actionButton.notifyOfSelection}" style="text-decoration: none;" disabled="#{actionButton.disabled or disabled}" partialSubmit="false">
                ....
           </ice:commandLink>
      </ui:composition>
      




      ActionButton bean:



      public abstract class ActionButton<E> implements Serializable {
      
           public ActionButton(ActionButtonListener actionButtonListener) {
                this.actionButtonListener = actionButtonListener;
           }
      
           ....
      
           public String notifyOfSelection() {
                return actionButtonListener.actionPerformed(this);
           }
      
      }





      But when I change the commandLink to be an s:link, it can't resolve the actionButton, it says that it is null.


      Is this somethig to do with different phases being executed for Facelet EL?


      Would I have to re-write all of the Facelet components we have as full JSF components?  If yes, then we end up having lots and lots of view logic in the code instead of as a collection of tags as it would be in a facelet.


      Am I heading down the right road with this??  Or am I totally on the wrong path :)


      Any tips or ideas are more than welcome,


      Thanks,
      Osian

        • 1. Re: Facelet or JSF Component?
          erimag

          You certainly don't need to rewrite all your facelet components, we have tons of custom facelets tags in our Seam project that work fine.


          It looks more like this is something specific with the s:link tag. If you look at the reference for s:link, it does mention the following:



          The use of action listeners (including the default JSF action listener) is not supported with s:link.

          Why are you trying to replace the commandLink at all btw, that should work fine with Seam as well?

          • 2. Re: Facelet or JSF Component?
            ohughes

            Hi Erik,


            Thanks for your reply.


            But it seems that I was barking up the wrong tree.  I thought that by using the s components I would be keeping my seam components alive, but it turns out that because I was using HibernateEntityHome/Query in PAGE scope, then this was causing all of my problems.  I happened to see somewhere on another posting that these components only like to be in CONVERSATION scope, then after resolving this issue, all was well :)


            Oo, any thoughts on how I can reset a seam component?


            Thanks,
            Osian