9 Replies Latest reply on Jul 15, 2009 11:18 PM by Chandran Narasimhan

    Seam, RichFaces and binding issues... rich:scrollableDataTable

    Bill Evans Newbie

      Before you ask, I did put this on the Richfaces forum but never got an answer, so I'm hoping that you Seam guys are more responsive...





      Environment: JBoss 4.2 AS, Seam 2.0.0.GA and Richfaces 3.2.0.SR1.




      Problem: I want to use the rich:scrollableDataTable to display data but the column layout must be dynamic. It cannot be hardcoded in the xhtml file.
      Therefore, I want to use the 'binding' option.



      However, when I do this I get a peculiar exception in ScrollableDataTableBaseRenderer.encodeBegin(). Basically, the component that I give in my binding, which is a new org.richfaces.component.html.HtmlScrollableDataTable instance, is determined NOT to be an instanceof org.richfaces.component.UIScrollableDataTable, even though it clearly extends it!!


      I would guess that someone is messing with the class but with all the injection, etc. who knows...


      And then when I DON'T use binding, but specify the columns in the xhtml, and trap at the encodeBegin, I find that the instance of HtmlScrollableDataTable is fine - so it works.


      Now, I did find the warning about Seam and binding in the Seam doc ( Link)
      but, I have to say it is not much help.


      So, really I would like to know what to do. I have used bindings with Tomahawk JSF components, so why not with RichFaces?


      How can I do what I want to do?


      (Please help!)



       

        • 1. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
          Bill Evans Newbie

          Here's a bit more info in case you need it:


          The html:



          <rich:scrollableDataTable binding="#{adminUsers.adminTableRF.table}" value="{#adminUsers.userList}"/>




          The bean:



          @Name("adminTableRF")
          @Scope(ScopeType.EVENT)
          public class AdminTableUsingRichFacesAction  {
          
               public static final String ROW_VAR_NAME = "usr";     //Used for constructing columns
               
               private HtmlScrollableDataTable table = new HtmlScrollableDataTable();
               
               
               public AdminTableUsingRichFacesAction() {
               
                    table = new HtmlScrollableDataTable();
                    table.setVar(ROW_VAR_NAME);
                    //
                    for (UserColumn uc : UserColumn.values()) {
                         UIColumn col = RichHelper.createUIColumn(FacesHelper.createHeader(uc.getColumnTitle(), null), 
                                                             FacesHelper.createUIOutput(ROW_VAR_NAME + "." + uc.binding, String.class, ROW_VAR_NAME + ".styleClass", String.class),
                                                             uc.width);
                         table.getChildren().add(col);
                    }
               }
               
               
               public HtmlScrollableDataTable getTable() {
                    return this.table;
                  }
          }
               





          The exception:



          java.lang.IllegalArgumentException: Component mainForm:j_id59 not instance of org.richfaces.component.UIScrollableDataTable
               at org.ajax4jsf.renderkit.RendererBase.encodeBegin(RendererBase.java:94)
               at org.richfaces.renderkit.html.ScrollableDataTableBaseRenderer.encodeBegin(ScrollableDataTableBaseRenderer.java:870)
               at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:788)
               at javax.faces.component.UIData.encodeBegin(UIData.java:879)
               at org.ajax4jsf.component.UIDataAdaptor.encodeBegin(UIDataAdaptor.java:1185)
               at org.richfaces.component.UIScrollableDataTable.encodeBegin(UIScrollableDataTable.java:170)
               at javax.faces.component.UIComponent.encodeAll(UIComponent.java:884)
               at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
               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: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.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
               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)


          • 2. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
            Olle Mårtensson Newbie

            I'm having the same problem when trying to create an richfaces component dynamically.


            XHTML:


            <rich:panelBar
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:rich="http://richfaces.org/rich"
                binding="#{categoryPanelBar}"
                />



            COMPONENT:


            @Name("itemCategoryAction")
            public class ItemCategoryAction
            {
            
                 @In(create=true)
                 ShopManager shopManager;
                 
                 @In
                 EntityManager entityManager;
                 
                 @Out(required = false)
                 private List<ItemCategory> categories;
                 
                 @Out(required = false)
                 HtmlPanelBar categoryPanelBar;
                 
                 @SuppressWarnings("unchecked")
                 @Factory("categories")
                 public void loadCategories()
                 {
                      categories = shopManager.getItemCategories();
                 }
                 
                 @Factory("categoryPanelBar")
                 public void loadPanelBar()
                 {
                      if(categories == null)
                      {
                           loadCategories();
                      }
                      HtmlPanelBar panelBar = new HtmlPanelBar();
                      for(ItemCategory category : categories)
                      {
                           HtmlPanelBarItem item = new HtmlPanelBarItem();
                           item.setLabel(category.getName());
                           panelBar.getChildren().add(item);
                      }
                      categoryPanelBar = panelBar;
                 }
                 
            }



            ERROR:


            java.lang.IllegalArgumentException: Component j_id11 not instance of org.richfaces.component.UIPanelBar








            • 3. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
              Robert Raksi Newbie

              Hi!


              Any news about this issue? I get the same error with the PanelMenu component when I build it from java code.

              • 4. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
                Eike Hartmann Newbie

                Hi, I had the same issue, however looking into the RichFaces JSF components tag library I found that the binding must evaluate to javax.faces.component.UIComponent


                hence, try sth like:

                javax.faces.component.UIComponent talbe = new HtmlScrollableDataTable();

                • 7. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
                  michele giuliano Newbie

                  I have the same problem, trying to create a DropDownMenu dinamically.
                  I was developing it with Jboss developer studio 1 using seam 2 and richfaces 3.2 under jboss 4.2.2 and all works correctly.



                  I migrated it to Jboss developer studio 2 using seam 2.1.1 and jboss 5.0.0.
                  and i obtain this error


                  java.lang.IllegalArgumentException: Component j_id11 not instance of org.richfaces.component.UI....
                  



                  I read every post about this problem and tryed everything, but nothing.
                  Can sameone help me ?
                  Thanks in advance
                  Michele

                  • 8. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
                    Chandran Narasimhan Newbie

                    Iam new to Seam and working with Richfaces for a while. Hope you guys got a solution for this. By this time you guys might have got an workaround atleast. Anyway I did tried the same thing and after google, I found out that you need to annotate your UIComponent with @In and @Out. It works !


                    Here is the code snip :


                    In your backing bean:


                    @Name("somename")
                    @Scope(ScopeType.SESSION) 
                    public class DevicesAction
                    {
                      @In(required = false)
                      @Out(required = false)
                      private HtmlScrollableDataTable myScrollableDataTable;
                     
                       public HtmlScrollableDataTable getMyScrollableDataTable() {
                            return myScrollableDataTable;
                       }
                    
                       public void setMyScrollableDataTable(HtmlScrollableDataTable myScrollableDataTable) {
                            this.myScrollableDataTable = myScrollableDataTable;             
                       }
                    
                    }



                    In Richfaces JSF:


                    <rich:scrollableDataTable id="someid" binding="#{myScrollableDataTable}" ..../>



                    Could any of the seam expert help me in understanding the myth/logic behind this behavior, please ?


                    • 9. Re: Seam, RichFaces and binding issues... rich:scrollableDataTable
                      Chandran Narasimhan Newbie

                      Chandran Narasimhan wrote on Jul 15, 2009 22:50:


                      Iam new to Seam and working with Richfaces for a while. This is slightly a different issue.I found out that you need to annotate your UIComponent with @In and @Out to make the richfaces binding work. Why is that i need a injection tags, whereas in a non-seam environment you don't need one?

                      Here is the code snip :

                      In your backing bean:

                      @Name("somename")
                      @Scope(ScopeType.SESSION) 
                      public class DevicesAction
                      {
                        @In(required = false)
                        @Out(required = false)
                        private HtmlScrollableDataTable myScrollableDataTable;
                       
                         public HtmlScrollableDataTable getMyScrollableDataTable() {
                              return myScrollableDataTable;
                         }
                      
                         public void setMyScrollableDataTable(HtmlScrollableDataTable myScrollableDataTable) {
                              this.myScrollableDataTable = myScrollableDataTable;             
                         }
                      
                      }



                      In Richfaces JSF:

                      <rich:scrollableDataTable id="someid" binding="#{myScrollableDataTable}" ..../>



                      Could any of the seam expert help me in understanding the myth/logic behind this behavior, please ?




                      Click HELP for text formatting instructions. Then edit this text and check the preview.