Search code examples
jsfjsf-2richfacesseam

Richfaces 4 dynamically created rich components display as text instead of menus/links


I'm migrating from RF3.3.3, JSF1.2 and jboss 5 to JSF2/ RF4. We have a rich toolbar group with dropdown menus that is generated from a database table. I made the changes to web.xml, renamed the applicable components in the backing bean, but the toolbar will only show as text instead of dropdown menus and links.

web.xml:

<?xml version="1.0"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
 <context-param>
  <param-name>org.richfaces.enableControlSkinning</param-name>
  <param-value>true</param-value>
 </context-param>
 <context-param>
  <param-name>org.richfaces.enableControlSkinningClasses</param-name>
  <param-value>false</param-value>
 </context-param>

 <context-param>
  <param-name>org.richfaces.resourceOptimization.enabled</param-name>
  <param-value>true</param-value>
 </context-param>

 <context-param>
  <param-name>org.richfaces.skin</param-name>
  <param-value>blueSky</param-value>
 </context-param>

menu.xhtml - included in a template.xhtml with h:head and h:body tags:

<h:form id="mnMenu">
<rich:toolbar id="tb" >
    <rich:toolbarGroup>
    <s:link id="menuHomeId" view="/home.xhtml" value="Home" propagation="none"/>
    </rich:toolbarGroup>

    <rich:toolbarGroup binding="#{menuQueries.myBarGrp}" />

</rich:toolbar>
<!-- account for jsf bug? bug DOESN'T WORK -->
    <rich:toolbar rendered="false"/>
    <rich:toolbarGroup rendered="false"/>
    <rich:dropDownMenu rendered="false"/>
    <rich:menuGroup rendered="false"/>
    <rich:menuItem rendered="false"/>
</h:form>

from backing bean - this method creates the toolbar group, it originally looked like this:

public HtmlToolBarGroup getMyBarGrp()
{
     this.myBarGrp = new org.richfaces.component.html.HtmlToolBarGroup();
     for (CtsPermissionHierarchyAltV each : this.getMainMenuList()) {
          this.myBarGrp.getChildren().add(getDropDownMenu(each));
     }
return this.myBarGrp;
}

I changed it to this, both generate the same output:

public UIToolbarGroup getMyBarGrp()
{
     FacesContext ctx = FacesContext.getCurrentInstance();
     this.myBarGrp = (UIToolbarGroup) ctx.getApplication().createComponent(ctx,     
      UIToolbarGroup.COMPONENT_TYPE, "org.richfaces.ToolbarGroupRenderer");
     this.myBarGrp.setId("dynMenuGrp");
     for (CtsPermissionHierarchyAltV each : this.getMainMenuList()) 
     {    
          this.myBarGrp.getChildren().add(getDropDownMenu(each));
     }
}

the getDropDownMenu and submenu methods are coded similarly. I'm not getting any errors. FF firebug output for text that should be a dropdown menu looks like this:

<div id="mnMenu:Communications" class="rf-ddm-lbl rf-ddm-unsel ">
... more stuff

Pre-migration it looked like this:

<div id="mnMenu:Communications" class="rich-ddmenu-label rich-ddmenu-label-unselect">
... more stuff

Navigating through the firebug output I can see all the submenus - but they're all text references. I see all my css files - they're showing up in body instead of head, but they're all there. Did I miss something? What else can I check?

jboss 7.1.1 Seam 2.3.0 JSF2.1 RichFaces 4.2.2


Solution

  • Found the answer here. I needed to add

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
     <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/org.richfaces.resources/*</url-pattern>
    </servlet-mapping>
    

    to web.xml. Not sure why it worked though, this solution is for containers using servlet2.5, and (as far as I know) I'm using servlet3.0.

    claudegex your answer put me on the path to fix it - there actually were 404 errors. I'll mark this one correct after the bounty is over, you should get 1/2 of it.