5 Replies Latest reply on Jul 10, 2007 10:44 AM by amitdk

    DataModel PersistentSet problem from rich subtable

    amitdk

      Hello
      I have a situation that requires me to use the DataModel and DataModelSelection tags in a rich subtable tag. Here's the xhtml code:

      <rich:dataTable value="#{taskObjectives}" var="taskObj"
       columnsWidth="70%,15%,15%"
       style="align:center">
      
       <f:facet name="header">
       <rich:columnGroup>
       <rich:column>
       <h:outputText value="Assigned Task" />
       </rich:column>
       <rich:column>
       <h:outputText value="Update Unapproved" />
       </rich:column>
       <rich:column>
       <h:outputText value="Remove" />
       </rich:column>
       </rich:columnGroup>
       </f:facet>
      
       <rich:column colspan="3" style="background-color:#F1E1D1">
       <h:outputText value="#{taskObj.description}" />
       </rich:column>
      
       <rich:subTable var="selectTask" value="#{taskObj.taskAssignments}"
       onRowMouseOver="this.style.backgroundColor='#E0E0E0'"
       onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
       <rich:column>
       <h:outputText value="#{selectTask.comments}" />
       </rich:column>
       <rich:column style="text-align:center">
       <s:button type="submit" action="#{report.updateTask}"
       value="Update Task" />
       </rich:column>
       <rich:column style="text-align:center">
       <s:button type="submit" action="#{report.removeTask}"
       value="Remove Task" />
       </rich:column>
       </rich:subTable>
      </rich:dataTable>
      

      There is a one to many relationship from taskObjective and taskAssignment. DataModel tag is used on the taskObjective, however since taskAssignments aren't exposed that way, I get the following exception on the subtable section:
      Caused by: javax.faces.el.PropertyNotFoundException: /WeeklyReport.xhtml @52,55
      value="#{selectTask.comments}": Bean: org.hibernate.collection.PersistentSet, pr
      operty: comments
       at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.ja
      va:58)
       at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
       at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue
      (RendererUtils.java:223)
       ... 77 more
      


      Is there any built-in way to convert a PersistentSet to a DataModel for use in the the subtable? If not what would be a good way to implement this - use a converter??

      Any hints or tips appreciated.
      Thanks
      Amit Karandikar

        • 1. Re: DataModel PersistentSet problem from rich subtable
          pmuir

          Post the whole exception please.

          • 2. Re: DataModel PersistentSet problem from rich subtable
            amitdk

            Sorry, here's the whole stack trace:

            SEVERE: Error Rendering View[/WeeklyReport.xhtml]
            javax.faces.FacesException: Could not retrieve value of component with path : {C
            omponent-Path : [Class: org.ajax4jsf.framework.ajax.AjaxViewRoot,ViewId: /Weekly
            Report.xhtml][Class: javax.faces.component.html.HtmlForm,Id: _id39][Class: org.r
            ichfaces.component.html.HtmlPanel,Id: _id41][Class: org.richfaces.component.html
            .HtmlDataTable,Id: _id44][Class: org.richfaces.component.html.HtmlSubTable,Id: _
            id54][Class: org.richfaces.component.html.HtmlColumn,Id: _id55][Class: javax.fac
            es.component.html.HtmlOutputText,Id: _id56]}
             at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue
            (RendererUtils.java:227)
             at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.re
            nderOutput(HtmlTextRendererBase.java:69)
             at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.en
            codeEnd(HtmlTextRendererBase.java:57)
             at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:
            539)
             at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase
            .java:286)
             at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererB
            ase.java:262)
             at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase
            .java:284)
             at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(Abstr
            actRowsRenderer.java:282)
             at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTa
            bleRenderer.java:216)
             at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRend
            erer.java:86)
             at org.ajax4jsf.ajax.repeat.SequenceDataModel.walk(SequenceDataModel.jav
            a:101)
             at org.ajax4jsf.ajax.repeat.UIDataAdaptor.walk(UIDataAdaptor.java:917)
             at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsR
            enderer.java:103)
             at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractR
            owsRenderer.java:135)
             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.
            java:527)
             at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase
            .java:282)
             at org.richfaces.renderkit.AbstractRowsRenderer.encodeCellChildren(Abstr
            actRowsRenderer.java:282)
             at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTa
            bleRenderer.java:216)
             at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRend
            erer.java:86)
             at org.ajax4jsf.ajax.repeat.SequenceDataModel.walk(SequenceDataModel.jav
            a:101)
             at org.ajax4jsf.ajax.repeat.UIDataAdaptor.walk(UIDataAdaptor.java:917)
             at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsR
            enderer.java:103)
             at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractR
            owsRenderer.java:135)
             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.
            java:527)
             at org.ajax4jsf.framework.renderer.RendererBase.renderChild(RendererBase
            .java:282)
             at org.ajax4jsf.framework.renderer.RendererBase.renderChildren(RendererB
            ase.java:262)
             at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRend
            erer.java:189)
             at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRend
            erer.java:184)
             at org.ajax4jsf.framework.renderer.RendererBase.encodeChildren(RendererB
            ase.java:121)
             at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.
            java:527)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSu
            pport.java:244)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSu
            pport.java:249)
             at com.sun.facelets.tag.jsf.ComponentSupport.encodeRecursive(ComponentSu
            pport.java:249)
             at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.jav
            a:573)
             at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapp
            er.java:108)
             at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandle
            r.java:233)
             at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderRes
            ponseExecutor.java:41)
             at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:
            132)
             at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
            icationFilterChain.java:252)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
            ilterChain.java:173)
             at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
            Filter.java:147)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
            icationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
            ilterChain.java:173)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
            a:63)
             at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.jav
            a:60)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
            a:49)
             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
            a:49)
             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
            a:49)
             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:79)
             at org.jboss.seam.web.SeamFilter$FilterChainImpl.doFilter(SeamFilter.jav
            a:49)
             at org.jboss.seam.web.SeamFilter.doFilter(SeamFilter.java:84)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
            icationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
            ilterChain.java:173)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseX
            MLFilter.java:127)
             at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.
            java:277)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
            icationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
            ilterChain.java:173)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
            lter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
            icationFilterChain.java:202)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
            ilterChain.java:173)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
            alve.java:213)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
            alve.java:178)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
            yAssociationValve.java:175)
             at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
            torBase.java:432)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
            e.java:74)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
            ava:126)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
            ava:105)
             at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConne
            ctionValve.java:156)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
            ve.java:107)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
            a:148)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
            :869)
             at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
            rocessConnection(Http11BaseProtocol.java:664)
             at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
            int.java:527)
             at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
            kerThread.java:112)
             at java.lang.Thread.run(Thread.java:595)
            Caused by: javax.faces.el.PropertyNotFoundException: /WeeklyReport.xhtml @51,54
            value="#{selectTask.comments}": Bean: org.hibernate.collection.PersistentSet, pr
            operty: comments
             at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.ja
            va:58)
             at javax.faces.component.UIOutput.getValue(UIOutput.java:80)
             at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue
            (RendererUtils.java:223)
             ... 77 more
            


            I was also looking at your jroller posting(http://jroller.com/page/pmuir?entry=using_sets_in_jsf) about using a facelet function to convert the set to a list. Does that apply here? Or is there a function within Seam that helps out with this.

            Thanks again
            Amit

            • 3. Re: DataModel PersistentSet problem from rich subtable
              amitdk

              Pete,
              Using the code you posted at http://jroller.com/page/pmuir?entry=using_sets_in_jsf, I was able to get this to work with a facelet function to convert the Map to a List. Here's how the code looks now:

              <rich:subTable var="selectTask" value="#{sr:asList(taskObj.taskAssignments)}"
               onRowMouseOver="this.style.backgroundColor='#E0E0E0'"
               onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'">
               <rich:column>
               <h:outputText value="#{selectTask.comments}"/>
               </rich:column>
               <rich:column style="text-align:center">
               <s:button type="submit" action="#{report.updateTask(selectTask)}"
               value="Update Task" />
               </rich:column>
               <rich:column style="text-align:center">
               <s:button type="submit" action="#{report.removeTask(selectTask)}"
               value="Remove Task" />
               </rich:column>
              </rich:subTable>
              


              Please let me know if you have any other suggestions on the same. The only other problem now I'm facing is that report.updateTask(selectTask) method that gets called on the report bean sends in a null value. Not sure what I'm doing wrong. Any suggestions?

              Thanks
              Amit

              • 4. Re: DataModel PersistentSet problem from rich subtable
                pmuir

                Whether thats to do with the rich:subTable, or doing the set->list conversion I'm not sure. Try passing in the id of task to select.

                • 5. Re: DataModel PersistentSet problem from rich subtable
                  amitdk

                  I did try passing in the task id. However, even that comes as null in my session bean:

                   @Begin
                   public void updateTask(String id)
                   {
                   System.out.println(id);
                   .......
                  

                  I went back to the Seam reference manual and was again reading through this excerpt:
                  26.1. Parameterized Method Bindings
                  Note: You can not pass objects as arguments! All that is passed is names, for example, hotel.id and user.username. If you check the rendered code of the previous example, you will see that the command button contains these names. These name arguments will be submitted to the server when you press the button, and Seam will look up and resolve these names (in any available context) before the action method is called. If the arguments can not be resolved at that time (because hotel and user variables can not be found in any available context) the action method will be called with null arguments!
                  .
                  Is this the problem I am stumbling on? Since the AssignedTask is an association of the Objective and AssignedTask is not declared as a DataModel, Seam is not able to find the list of AssignedTask objects in any context. Am I understanding this correctly? Also, besides converting the button to a link and passing the id that way, is there any other way around?

                  Thanks
                  Amit