3 Replies Latest reply on Nov 12, 2007 7:29 AM by nevez

    Component j_id22 not instance of org.richfaces.component.UID

    nevez

      Hello, i`m trying to create richfaces components dynamically:

      import org.jboss.seam.annotations.Name;
      import org.richfaces.component.UIDropDownMenu;
      import org.richfaces.component.html.HtmlDropDownMenu;
      import org.richfaces.component.html.HtmlMenuItem;
      
      @Name("confTypeMenu")
      public class ConfTypeMenu {
      
       public UIDropDownMenu getMyMenu() {
       UIDropDownMenu menu = new HtmlDropDownMenu();
       HtmlMenuItem menuItem = new HtmlMenuItem();
       String subOption = "Sec. Change Passsword";
       menuItem.setValue(subOption);
      
       menu.getChildren().add(menuItem);
       return menu;
      
       }
      


      and using it in my .xhtml:
       <rich:dropDownMenu binding="#{confTypeMenu.myMenu}"/>


      and i get the following error when trying to acces page:
      Component j_id22 not instance of org.richfaces.component.UIDropDownMenu


      i`m using JBoss AS 4.2.1, and JBoss Seam 2.0.0

      any ideas ?
      TIA

        • 1. Re: Component j_id22 not instance of org.richfaces.component
          dmitry.demyankov

          I think you should use

          HtmlDropDownMenu menu = new HtmlDropDownMenu();
          and return type should be HtmlDropDownMenu as it is shown in Developer Guide (see 6.41.4. Creating the Component Dynamically Using Java)

          • 2. Re: Component j_id22 not instance of org.richfaces.component
            nevez

            I tried, but it doesn`t work, could there something be wrong with classloading ?
            I find out that jboss-service.xml should have a UseJBossWebLoader property, but i cant find the property anywhere and where to put it.

            • 3. Re: Component j_id22 not instance of org.richfaces.component
              nevez

              I solved the problem, as i suspected there was a problem with classloading, in \jboss-4.2.0.GA\server\default\deploy\jboss-web.deployer\META-INF\jboss-serice.xml
              i changed "UseJBossWebLoader" to true and used the following code to create component:

              private HtmlDropDownMenu menu;
              public HtmlDropDownMenu getMyMenu() {
               if (menu == null) {
               Application app = FacesContext.getCurrentInstance().getApplication();
              
               menu = (HtmlDropDownMenu) app.createComponent(HtmlDropDownMenu.COMPONENT_TYPE);
               menu.setValue("File");
               .....
               }
               return menu
              }