5 Replies Latest reply on Aug 4, 2010 4:43 PM by scott duke

    EJBQL and Richfaces question.

    scott duke Novice

      Within my EntityQuery called ItemList.java, I am trying to query items and the default image(or other info from image table) within the image table. The items along with the default image (if one is defined) will be displayed on my search listing screen. So, I guess I have 2 questions:


      1. Is my query correct using a join?
      2. How can I access the joined table on rich dataTable where my var is item?


      SQL in ItemList.java:


      select item from Item item left join item.images images where item.images.defaultImage="true"
      



      ItemList.xhtml


                  <rich:dataTable id="itemList" 
                                 var="_item"
                             value="#{itemList.resultList}" 
                           rendered="#{not empty itemList.resultList}">
               
                   <h:column>
                       <f:facet name="header">
                           <a4j:htmlCommandLink styleClass="columnHeader" reRender="itemList"
                                             value="Code #{itemList.order=='item.code asc' ? messages.down : ( itemList.order=='item.code desc' ? messages.up : '' )}">
                               <f:param name="itemListOrder" value="#{itemList.order=='item.code asc' ? 'item.code desc' : 'item.code asc'}"/>
                           </a4j:htmlCommandLink>
                       </f:facet>
                       #{_item.code}
                   </h:column>   
      
      ...
      
                   <h:column>
                       <f:facet name="header">
                           <a4j:htmlCommandLink styleClass="columnHeader" reRender="itemList"
                                            value="Image Name2 #{itemList.order=='image.name asc' ? messages.down : ( itemList.order=='image.name desc' ? messages.up : '' )}">
                               <f:param name="itemListOrder" value="#{itemList.order=='image.name asc' ? 'image.name desc' : 'image.name asc'}"/>
                           </a4j:htmlCommandLink>
                       </f:facet>
                       #{_item.images.name}
                   </h:column>   
      
      ...
      
                  </rich:dataTable>
      
      




        • 1. Re: EJBQL and Richfaces question.
          Joshua Jackson Master

          1.


          select item from Item item left join item.images images where images.defaultImage=true



          2. Are you able to display it in your dataTable? Because the query will only return list of objects to be displayed on the dataTable.


          • 2. Re: EJBQL and Richfaces question.
            scott duke Novice

            If I do not include the column for item.images.name, then it works. However, by trying to access the column on the datatable I get the following error:



            16:48:19,937 ERROR [viewhandler] Error Rendering View[/ItemList.xhtml]
            javax.el.ELException: /ItemTable.xhtml: For input string: "name"
                 at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
                 at com.sun.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:39)
                 at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:280)
                 at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                 at org.richfaces.renderkit.AbstractTableRenderer.encodeOneRow(AbstractTableRenderer.java:334)
                 at org.richfaces.renderkit.AbstractRowsRenderer.process(AbstractRowsRenderer.java:86)
                 at org.ajax4jsf.model.SequenceDataModel.walk(SequenceDataModel.java:101)
                 at org.richfaces.model.ModifiableModel.walk(ModifiableModel.java:118)
                 at org.ajax4jsf.component.UIDataAdaptor.walk(UIDataAdaptor.java:1127)
                 at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:106)
                 at org.richfaces.renderkit.AbstractRowsRenderer.encodeRows(AbstractRowsRenderer.java:91)
                 at org.richfaces.renderkit.AbstractRowsRenderer.encodeChildren(AbstractRowsRenderer.java:138)
                 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.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:284)
                 at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
                 at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:220)
                 at org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:215)
                 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.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:189)
                 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.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:154)
                 at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
                 at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:366)
                 at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
                 at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
                 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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:73)
                 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(Unknown Source)
            Caused by: java.lang.NumberFormatException: For input string: "name"
                 at java.lang.NumberFormatException.forInputString(Unknown Source)
                 at java.lang.Integer.parseInt(Unknown Source)
                 at java.lang.Integer.parseInt(Unknown Source)
                 at javax.el.ListELResolver.coerce(ListELResolver.java:166)
                 at javax.el.ListELResolver.getValue(ListELResolver.java:51)
                 at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                 at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
                 at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
                 at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
                 at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
                 at com.sun.facelets.el.ELText$ELTextVariable.writeText(ELText.java:184)
                 at com.sun.facelets.el.ELText$ELTextComposite.writeText(ELText.java:108)
                 at com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:45)
                 ... 68 more
            


            • 3. Re: EJBQL and Richfaces question.
              Joshua Jackson Master

              This has got to do with the value of your item.images.name



              Caused by: java.lang.NumberFormatException: For input string: name

              Check your data on that field.


              • 4. Re: EJBQL and Richfaces question.
                Haris Jan Newbie



                i have the exact same issue and i cant figure out the problem please help me solve this problem
                Than you!

                • 5. Re: EJBQL and Richfaces question.
                  scott duke Novice

                  It has been awhile since I posted this, but I did come up with a solution.


                  In my ItemList.xhtml


                  <rich:column>
                      <f:facet name="header">Image</f:facet>
                      <s:graphicImage value="#{_image.data ne null ? _image.data : '/img/large-no-image.jpg'}" fileName="#{_image.name}-36-thumbnail" atl="[thumbnail of image data]">
                          <s:transformImageSize width="36" maintainRatio="true" />
                      </s:graphicImage>
                  </rich:column>      
                  



                  This will allow an image to be displayed if there is one or a default no image when no image is present.