7 Replies Latest reply on Jul 18, 2006 1:31 AM by lcoetzee

    nested datatables with s:link

    lcoetzee

      Hi,

      I want to nest datatable, with the inside loop containing a s:link with an action.

      Something like:

      <t:dataList value="#{sections}" var="currentSection" layout="simple"
       rendered="#{not empty sections}" id="dt1">
       <li>#{currentSection.sectionLabel}
       <t:dataList value="#{currentSection.questions}"
       var="currentQuestion" layout="simple"
       rendered="#{not empty currentSection.questions}" id="dt2">
       <li><s:link action="#{questionSelectionBean.selectQuestion}" id="selectQuestion">#{currentQuestion.questionLabel}</s:link></li>
       </t:dataList>
      
       </ul>
       </li>
       </t:dataList>
      


      Each section has several questions associated with it (section is annotated with a @DataModel).
      It displays nicely, but as yet I have no clue how to get hold of the selected "currentQuestion" in my SFSB method (questionSelectionBean.selectQuestion).

      Any ideas ?

      Thanks
      Louis

        • 1. Re: nested datatables with s:link
          lcoetzee

          I have found a way using MyFaces Tomahawk's updateActionListener. Something like:

          <h:form id="section_questions">
           <ul id="linkslist">
           <t:dataList value="#{sections}" var="currentSection" layout="simple"
           rendered="#{not empty sections}" id="dt1"
           rowIndexVar="sectionRowIndex">
           <li><h:outputText value="#{currentSection.sectionLabel}" />
          
           <ul>
           <t:dataList value="#{currentSection.questions}"
           var="currentQuestion" layout="simple"
           rowIndexVar="questionRowIndex"
           rendered="#{not empty currentSection.questions}" id="dt2">
           <li><h:commandLink
           action="#{questionSelectionBean.selectQuestion}" id="cl1">
           <h:outputText value="#{currentQuestion.questionLabel}" />
           <t:updateActionListener id="sectionListener"
           property="#{sectionSelectionBean.sectionRowIndex}"
           value="#{sectionRowIndex}" />
          
           <t:updateActionListener id="questionListener"
           property="#{sectionSelectionBean.questionRowIndex}"
           value="#{questionRowIndex}" />
          
           </h:commandLink></li>
           </t:dataList>
          
           </ul>
           </li>
           </t:dataList>
          
           </ul>
           </h:form>


          Unfortunately the solution forces me to use a form/commandLink action. I get the following exception when trying to use the s:link.

           ERROR [STDERR] 2006/07/17 03:23:34 com.sun.facelets.FaceletViewHandler handleRenderException
          SEVERE: Error Rendering View[/secure/questionnaire/sections.xhtml]
          java.lang.ClassCastException: org.jboss.seam.ui.HtmlLink
           at csir.utils.taghandlers.TomahawkUpdateActionListenerHandler.apply(TomahawkUpdateActionListenerHandler.java:76)
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
           at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
           at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
           at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:295)
           at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:165)
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
           at com.sun.facelets.tag.ui.DefineHandler.apply(DefineHandler.java:58)
           at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:128)
           at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:306)
           at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:279)
           at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
           at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
           at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
           at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
           at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
           at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:143)
           at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
           at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
           at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
           at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
           at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:510)
           at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:553)
           at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:30)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at org.jboss.seam.servlet.SeamExceptionFilter.doFilter(SeamExceptionFilter.java:45)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
           at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
           at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
           at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
           at java.lang.Thread.run(Thread.java:595)
          


          I am using a TomahawkUpdateActionListenerHandler as written by Andrew Robinson (http://www.mail-archive.com/users@myfaces.apache.org/msg09735.html)


          Any ideas ? Ideally I would like to work with s:link and not have the whole form with javascript as generated by the commandLink.

          Regards

          Louis

          • 2. Re: nested datatables with s:link
            pmuir

            What about f:param's?

            <s:link action="#{questionSelectionBean.selectQuestion}" id="selectQuestion">
             <f:param name="sectionRowIndex" value="#{sectionRowIndex}" />
             <f:param name="questionRowIndex" value="#{questionRowIndex}" />
            </s:link>
            


            inject using

            @RequestParam private Integer sectionRowIndex;
            @RequestParam private Integer questionRowIndex;
            


            • 3. Re: nested datatables with s:link
              lcoetzee

              Jip, it will work. My one fear of using the RequestParameter stuff is that I need to add a bit more error handling to ensure that somebody isn't messing with the url (e.g sending a bogus row value).

              Thanks

              L

              • 4. Re: nested datatables with s:link
                gavin.king

                Is this yet another case of the Tomahawk stuff just not playing nicely with others?

                I'm really really getting close to adding a big "don't use tomahawk components because they are too broken" warning in the Seam docs.

                I'm really waiting for the Trinidad stuff to finally get released....

                • 5. Re: nested datatables with s:link
                  lcoetzee

                  Jip. I think in this case it is more a case of getting Tomahawk working with Facelets. The whole thing falls apart in a specific class that was written to allow for the usage in Facelets.

                  I will keep an eye on the Trinidad stuff.

                  With regard to the current solution:
                  I am still searching for good ways to handle the f:param for possible error handling.. with the @RequestParameter it gets converted to an int, but fails if somebody bookmarked and then changed the url (e.g. replacing the int with say a string... resulting in a number conversion exception). Any suggestions ?

                  Regards

                  Louis

                  • 6. Re: nested datatables with s:link
                    gavin.king

                     

                    "lcoetzee" wrote:

                    I am still searching for good ways to handle the f:param for possible error handling.. with the @RequestParameter it gets converted to an int, but fails if somebody bookmarked and then changed the url (e.g. replacing the int with say a string... resulting in a number conversion exception). Any suggestions ?


                    http://jira.jboss.com/jira/browse/JBSEAM-305

                    • 7. Re: nested datatables with s:link
                      lcoetzee

                      Excellent. thanks Gavin.


                      Later

                      Louis