0 Replies Latest reply on Feb 28, 2008 10:58 PM by N A (these are my real initials)

    Can you embed @DataModel?

    N A (these are my real initials) Newbie

      This demo was made with seam-gen (2.0.1 on JBoss 4.2.2) to demonstrate a problem. I wouldn't be surprised if it turns out to be a PEBKAC, it probably is, but I figured it never hurts to ask.


      I'm running into this exception:


      javax.faces.FacesException: javax.el.PropertyNotFoundException: /aclassManager.xhtml @44,53 value="#{b.name}": Property 'name' not found on type java.util.HashSet
           at javax.faces.component.UIOutput.getValue(UIOutput.java:176)
           at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:189)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:320)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:200)
           at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:836)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
           at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:307)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
           at com.sun.faces.renderkit.html_basic.TableRenderer.encodeChildren(TableRenderer.java:307)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
           at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
           at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
           at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
           at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
           at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
           at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:812)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
           at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
           at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
           at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
           at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.el.PropertyNotFoundException: /aclassManager.xhtml @44,53 value="#{b.name}": Property 'name' not found on type java.util.HashSet
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
           at javax.faces.component.UIOutput.getValue(UIOutput.java:173)
           ... 65 more


      With this setup:


      @Entity
      @Name("aclass")
      public class aclass implements Serializable {
           
           private Long id;
           private Integer version;
           private String name;
           @DataModel
           private Set<bclass> bclasses;
           
           public aclass() {
                bclasses = new HashSet<bclass>();          
           }
           
          @Id @GeneratedValue
           public Long getId() {
                return id;
           }
      
           public void setId(Long id) {
                this.id = id;
           }
           
           @Version
           public Integer getVersion() {
                return version;
           }
      
           private void setVersion(Integer version) {
                this.version = version;
           }        
           
           @Length(max=20)
           public String getName() {
                return name;
           }
      
           public void setName(String name) {
                this.name = name;
           }
      
           @OneToMany(mappedBy="aclass")
           public Set<bclass> getBclasses() {
                return bclasses;
           }
      
           public void setBclasses(Set<bclass> bclasses) {
                this.bclasses = bclasses;
           }        
      }
      



      @Entity
      @Name("bclass")
      public class bclass implements Serializable {
           
           private Long id;
           private Integer version;
           private String name;
           private aclass aclass;
           
           @Id @GeneratedValue
           public Long getId() {
                return id;
           }
      
           public void setId(Long id) {
                this.id = id;
           }
           
           @Version
           public Integer getVersion() {
                return version;
           }
      
           private void setVersion(Integer version) {
                this.version = version;
           }        
           
           @Length(max=20)
           public String getName() {
                return name;
           }
      
           public void setName(String name) {
                this.name = name;
           }
      
           @ManyToOne
           public aclass getAclass() {
                return aclass;
           }
      
           public void setAclass(aclass aclass) {
                this.aclass = aclass;
           }
      }
      



      @Local
      public interface AclassManager {  
           
           public String save();
           public void addAInstance();
           public void addBInstance();
           public String begin();
           public String increment();
           public String end();
           public int getValue();
           public void destroy();
                
      }




      @Stateful
      @Name("aclassManager")
      public class AclassManagerBean implements AclassManager {
           @PersistenceContext
           EntityManager em;
           @Logger
           private Log log;
      
           @DataModel
           private Set<aclass> aclassSet;
      
           @DataModelSelection
           private aclass aclassSelection;
      
           private int value;
      
           @Begin
           public String begin() {
                log.info("beginning conversation");
      
                aclassSet = new HashSet<aclass>();
      
                return "success";
           }
      
           public String increment() {
                log.info("incrementing");
                value++;
                return "success";
           }
      
           @End
           public String end() {
                log.info("ending conversation");
                return "home";
           }
      
           public int getValue() {
                return value;
           }
      
           @Destroy
           @Remove
           public void destroy() {          
           }
      
           public String save() {
                em.persist(aclassSet);
                return null;
           }
      
           public void addAInstance() {
                log.info("adding instance of class A");
                aclassSet.add(new aclass());          
                log.info("Done.\nWe now have " + aclassSet.size() + " instances in the set");
           }
           
           public void addBInstance() {
                log.info("adding instance of class B to class " + aclassSelection.getName());
                aclassSelection.getBclasses().add(new bclass());
                log.info("Done.\nWe now have " + aclassSelection.getBclasses().size() + " instances in class " +aclassSelection.getName()+"'s set");
           }
      }
      



      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                                   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:s="http://jboss.com/products/seam/taglib"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:rich="http://richfaces.org/rich"
                      template="layout/template.xhtml">
                             
      <ui:define name="body">
      
          <h:messages globalOnly="true" styleClass="message"/>
          
          <rich:panel>
              <f:facet name="header">aclassManager</f:facet>
                  
              <div class="dialog">
                  <div class="prop">
                      <span class="name">Value</span>
                      <span class="value">#{aclassManager.value}</span>
                  </div>
              </div>
              
              <div style="clear:both"/>
          
          </rich:panel>
          <h:form id="manage">
          <rich:panel>
               <h:dataTable value="#{aclassSet}" var="a">              
                    <h:column>
                          <f:facet name="header">aclass name</f:facet>
                               <h:inputText id = "aName" value="#{a.name}"/>
                     </h:column>
                     <h:column>
                     <f:facet name="header">action</f:facet>
                     <h:commandButton id="addB" value="Add bclass Instance" 
                      action="#{aclassManager.addBInstance}"/>
                     </h:column>
                     <h:column>
                          <h:dataTable value="#{a.bclasses}" var="b" rendered="#{a.bclasses.size>0}">
                               <h:column>
                                    <f:facet name="header">bclass name</f:facet>
                                         <h:inputText id = "bName" value="#{b.name}"/>
                               </h:column>
                          </h:dataTable>
                     </h:column>
               </h:dataTable>
          </rich:panel>
          </h:form>
          <h:form id="aclassManager">
              <div class="actionButtons">
                  <h:commandButton id="begin" value="Begin" 
                      action="#{aclassManager.begin}"/>                      
                  <h:commandButton id="inc" value="Increment" 
                      action="#{aclassManager.increment}"/>                      
                  <h:commandButton id="end" value="End" 
                      action="#{aclassManager.end}"/>
                  <h:commandButton id="save" value="Save" 
                      action="#{aclassManager.save}"/>
                  <h:commandButton id="addA" value="Add aclass Instance" 
                      action="#{aclassManager.addAInstance}"/>
              </div>
          </h:form>
          
      </ui:define>
      
      </ui:composition>
      



      Is what I'm trying to do here not possible?
      I see the right debug statements logged, but the page craps its pants once it tries to render.
      Any insight would be much appreciated.
      Thanks!