6 Replies Latest reply on Mar 27, 2012 8:08 PM by hantsy

    A generic JSF 2 problem

    hantsy

      I have some entities are inhretance relation...

      There is a Company and Agent, agent is extened from Company  which has a List<Agent> relatedAgents.

       

       

      @OneToMany(mappedBy = "parentAgent")
          private List<Agent> relatedAgents = new ArrayList<Agent>();
      

       

       

      In the Company edit page(wich is also designed to be used to edit Agent), I added extre fields in the Agent. I use ui:fragment to differenate Company and Agent(of course the backend entity is different fro different parameter).

      it should be not rendered at the runtime.

       

      But when I enter the Company edit page.

       

      I got an error.

       

       

      Caused by: javax.el.PropertyNotFoundException: /directory/includes/companyAgentEdit.xhtml @39,59 value="#{companyEdit.currentCompany.relatedAgents}": The class 'com.skolarikos.model.Company' does not have the property 'relatedAgents'.
          at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:104) [jsf-impl-2.0.2-b10.jar:2.0.2-FCS]
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:193) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
          at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:181) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
          at org.richfaces.component.UISequence.getValue(UISequence.java:179) [richfaces-components-ui-4.2.0.Final.jar:]
          at org.richfaces.component.UISequence.createExtendedDataModel(UISequence.java:113) [richfaces-components-ui-4.2.0.Final.jar:]
          at org.richfaces.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:466) [richfaces-components-ui-4.2.0.Final.jar:]
          at org.richfaces.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:279) [richfaces-components-ui-4.2.0.Final.jar:]
          at org.richfaces.component.UIDataAdaptor.visitTree(UIDataAdaptor.java:1306) [richfaces-components-ui-4.2.0.Final.jar:]
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
          at javax.faces.component.UIComponent.visitTree(UIComponent.java:1496) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
          at javax.faces.component.UINamingContainer.visitTree(UINamingContainer.java:163) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
      

       

      This fragment are wrapped within ui:fragment.

       

       

      <ui:fragment
      rendered="#{companyEdit.entityType  ne null and companyEdit.entityType eq 'Agent'}">
      <ui:include src="/directory/includes/companyAgentEdit.xhtml" />
      </ui:fragment>

       

      The final page rendered correctly, the agent related fields are not rendered in the edit page for a Company entity.

       

      1. Bug why I  got the error, Is there some guide for this problem.

      2. Another cases in application, Yacht, Ship are extended from Vessel, they also have some specific generic fields(NOT associations), they worked well as expected.

       

       

      Any help here?

       

      Thanks.

        • 1. Re: A generic JSF 2 problem
          lightguard

          Are you missing a getter / setter for the relatedAgents property?

          • 2. Re: A generic JSF 2 problem
            hantsy

            Of course, relatedAgents is in the Agent entity. And when create a Agent, it worked well.

             

             

            1. Agent extends Company

            2. the edit page is for Company and Agent, some fragment are hidden for different type..

            3. in my list page, I used a h:link with type parameter to create a new entity in CompanyEdit bean.

            if("Company".equals(entityType)){

                 this.currentCompany=new Company()

            }else{

                 this.currentCompany=new Agent();

            }

             

            which is called in  the preRenderViw event listener.

             

            4. In the Company edit, when it was displayed. I got the error. But the page display result is correctly, the agent data part is hidden, but why in the background, it still active in the jsf view tree?

             

            I used JBoss 7.0.1.Final, Mojarra2.0.2, Weld 1.1.5.

            • 3. Re: A generic JSF 2 problem
              lightguard

              Same problem on 7.1.0.Final or 7.1.1.Final? It could be a Mojarra issue.

              • 4. Re: A generic JSF 2 problem
                hantsy

                I have tried on JBoss 7.1.Final which is shipped with Mojarra 2.1.5.

                The same problem there.

                 

                the relatedAgents is an one to many association there.

                 

                but nomal fields worked well.

                • 5. Re: A generic JSF 2 problem
                  lightguard

                  I've got nothing, sorry. Maybe in the JSF channel on IRC, or the JSF forums at Oracle?

                  • 6. Re: A generic JSF 2 problem
                    hantsy

                    I have post this link in Mojarra maillist, thanks.