12 Replies Latest reply on Jun 27, 2007 8:32 AM by knisterpeter

    EntityHome problem

    knisterpeter

      I have a problem using the framework and EntityHome class.
      My page parameter is not set in the EntityHome on link click and therefore no entity instance is loaded into the EntityHome class.

      Anything I'm missing?

      My list.xhtml:

      <h:column>
       <f:facet name="header">Username</f:facet>
       <s:link view="/admin/secure/options/details.xhtml"
       value="#{entity.username}">
       <f:param name="entityId" value="#{entity.id}" />
       </s:link>
       </h:column>
      

      My details.xhtml
      <s:decorate id="usernameDecorate"
       template="fieldDecorate.xhtml">
       <ui:define name="label">Username:</ui:define>
       <ui:define name="field">
       <h:inputText id="username" value="#{account.username}" />
       </ui:define>
       </s:decorate>
      

      My components.xml:
      <factory name="account" value="#{accountHome.instance}" />
       <fwk:entity-home name="accountHome"
       entity-class="de.llynch.kingpin.dao.Account" />
      

      And my pages.xml:
      <page view-id="details.xhtml">
       <param name="entityId" value="#{accountHome.id}"
       converter="java.lang.Integer" />
       <begin-conversation join="true" />
      
       <navigation>
       <rule if-outcome="updated">
       <end-conversation />
       <redirect />
       </rule>
       <rule if-outcome="persisted">
       <end-conversation />
       <redirect />
       </rule>
       <rule if-outcome="removed">
       <end-conversation />
       <redirect view-id="/admin/secure/options/list.xhtml" />
       </rule>
       </navigation>
       </page>
      


      I'm also not sure if the begin-conversation and end-converstation tags are required. It does not work with or without them though.

        • 1. Re: EntityHome problem
          pmuir

          That should be /details.xhtml for the view-id in pages.xhtml probably.

          • 2. Re: EntityHome problem
            knisterpeter

            It is. Acutally it is a bit longer line '/admin/secure...'. I've cut that down for simplicity.

            • 3. Re: EntityHome problem
              dustismo

              Just a shot in the dark, but are you using myfaces + state saving=server? If so, it is a known problem with myfaces.

              • 4. Re: EntityHome problem
                knisterpeter

                No, but thanks. I'm using JSR RI 1.2 with Facelets 1.1.12 and Tomcat 5.5.

                • 5. Re: EntityHome problem
                  knisterpeter

                  I have found the following in the seam DEBUG logs:

                  [DEBUG] 10:19:34.211 core.Events - Processing event:org.jboss.seam.preRemoveVariable.entityId
                  [DEBUG] 10:19:34.211 seam.Component - instantiating Seam component: org.jboss.seam.core.events
                  [DEBUG] 10:19:34.212 seam.Component - initializing new instance of: org.jboss.seam.core.events
                  [DEBUG] 10:19:34.212 seam.Component - done initializing: org.jboss.seam.core.events
                  [DEBUG] 10:19:34.213 seam.Component - instantiating Seam component: org.jboss.seam.core.events
                  [DEBUG] 10:19:34.213 seam.Component - initializing new instance of: org.jboss.seam.core.events
                  [DEBUG] 10:19:34.214 seam.Component - done initializing: org.jboss.seam.core.events
                  [DEBUG] 10:19:34.214 core.Events - Processing event:org.jboss.seam.postRemoveVariable.entityId
                  

                  Where can I find the code logging this statements?
                  I'll just want to find an entry point to debug my problem. Where and when are the page parameters set to the model?

                  • 6. Re: EntityHome problem
                    knisterpeter

                    After looking throught the code in seam related to setting page parameters, I'm sure my problem is related to this line in pages.xml:

                    <param name="entityId" value="#{accountHome.id}"
                     converter="java.lang.Integer" />

                    The converter in JSF is not java.lang.Integer, but javax.faces.Integer!
                    The problem why I not noticed this is that Seam silently fail in creating the converter (without logging the error) and removing the parameter!!!

                    It would be best if there is a logentry (maybe only at debug level) if the converter creation fails! :(

                    • 7. Re: EntityHome problem
                      knisterpeter

                      For reference:
                      The code in Seam is in org.jboss.seam.pages.Param#getValueFromRequest() around lines 133 to 142

                      • 8. Re: EntityHome problem
                        knisterpeter

                        Also I should have used converterId instead of converter attribute.

                        • 9. Re: EntityHome problem
                          pmuir

                          Seam allows you to use the java.lang.XXX for converter id (extension to JSF). The reason for no error was not using the correct attribute, if a converter can't be found, then an exception will be thrown.

                          • 10. Re: EntityHome problem
                            knisterpeter

                            For sure the attribute was the worst thing, but as you can see here:

                            public Object getValueFromModel(FacesContext facesContext)
                             {
                             Object value = getValueExpression().getValue();
                             if (value==null)
                             {
                             return null;
                             }
                             else
                             {
                             Converter converter = null;
                             try
                             {
                             converter = getConverter();
                             }
                             catch (RuntimeException re)
                             {
                             //YUCK! due to bad JSF/MyFaces error handling
                             return null;
                             }
                            
                             return converter==null ?
                             value :
                             converter.getAsString( facesContext, facesContext.getViewRoot(), value );
                             }
                             }
                            

                            Any (runtime) exception thrown by the getConverter() call will be dropped silently which (I think) is bad.

                            • 11. Re: EntityHome problem
                              pmuir

                              Can you file a JIRA issue for this?

                              • 12. Re: EntityHome problem
                                knisterpeter