myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject [Trinidad] Exception with XMLMenuModel usage
Date Wed, 12 Sep 2007 22:10:08 GMT
I have 2 controls backed by an XmlMenuModel, a main menu and a help
context menu. When I only had one menu, my code was working. When I
introduced the 2nd model, I started getting this exception:

java.lang.NullPointerException
        at org.apache.myfaces.trinidad.model.XMLMenuModel.getFocusRowKey(XMLMenuModel.java:292)
        at org.apache.myfaces.trinidad.component.UIXNavigationHierarchy.getFocusRowKey(UIXNavigationHierarchy.java:79)
        at org.apache.myfaces.trinidad.component.HierarchyUtils.__handleEncodeBegin(HierarchyUtils.java:88)
        at org.apache.myfaces.trinidad.component.UIXNavigationTree.__encodeBegin(UIXNavigationTree.java:153)
        at org.apache.myfaces.trinidad.component.UIXCollection.encodeBegin(UIXCollection.java:515)
        at org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChild(RendererUtils.java:435)
        at org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils.renderChildren(RendererUtils.java:423)
        at org.apache.myfaces.custom.roundeddiv.HtmlRoundedDivRenderer.encodeChildren(HtmlRoundedDivRenderer.java:319)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
        at org.apache.myfaces.trinidadinternal.uinode.UIComponentUINode._renderComponent(UIComponentUINode.java:320)
        at org.apache.myfaces.trinidadinternal.uinode.UIComponentUINode.render(UIComponentUINode.java:279)
        at org.apache.myfaces.trinidadinternal.uinode.UIComponentUINode.render(UIComponentUINode.java:256)
        at org.apache.myfaces.trinidadinternal.ui.BaseRenderer.renderChild(BaseRenderer.java:425)
        at org.apache.myfaces.trinidadinternal.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:343)
        at org.apache.myfaces.trinidadinternal.ui.BaseRenderer.renderIndexedChild(BaseRenderer.java:235)
        at org.apache.myfaces.trinidadinternal.ui.BaseRenderer.renderContent(BaseRenderer.java:142)
        at org.apache.myfaces.trinidadinternal.ui.laf.base.desktop.PanelTabbedRenderer.renderContent(PanelTabbedRenderer.java:112)
        at org.apache.myfaces.trinidadinternal.ui.BaseRenderer.render(BaseRenderer.java:93)
        at org.apache.myfaces.trinidadinternal.ui.laf.base.xhtml.XhtmlLafRenderer.render(XhtmlLafRenderer.java:84)
        at org.apache.myfaces.trinidadinternal.uinode.UIXComponentUINode.renderInternal(UIXComponentUINode.java:192)
        at org.apache.myfaces.trinidadinternal.uinode.UINodeRendererBase.encodeEnd(UINodeRendererBase.java:70)
        at org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:710)


faces-config.xml:
  <managed-bean>
    <managed-bean-name>mainMenuModel</managed-bean-name>
    <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
    <managed-property>
      <property-name>source</property-name>
      <value>/WEB-INF/mainMenu.xml</value>
    </managed-property>
  </managed-bean>
  <managed-bean>
    <managed-bean-name>helpContextMenuModel</managed-bean-name>
    <managed-bean-class>org.apache.myfaces.trinidad.model.XMLMenuModel</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
    <managed-property>
      <property-name>source</property-name>
      <value>/WEB-INF/helpContents.xml</value>
    </managed-property>
  </managed-bean>


The problem seems to be a result of:

    if (this == _getRootModel())
    {
      _viewIdFocusPathMap = _contentHandler.getViewIdFocusPathMap(_mdSource);
      _nodeFocusPathMap   = _contentHandler.getNodeFocusPathMap(_mdSource);
      _idNodeMap          = _contentHandler.getIdNodeMap(_mdSource);
    }

For the 2nd component, the "if" evaluates to false, so the three
member variables are null, and the exception is because
_viewIdFocusPathMap is null.

Am I doing something wrong or is this a bug in 1.0.3-SNAPSHOT?

Usage of main menu
      <tr:navigationPane
        id="mainMenuPanel"
        partialTriggers="mainMenuPanel"
        hint="list"
        var="_node"
        value="#{mainMenuModel}">
        <f:facet name="detailStamp">
          <tr:commandNavigationItem
            actionListener="#{menuBean.onMainAction}"
            partialSubmit="true"
            immediate="true">
            <f:param name="conversationPropagation" value="#{'none'}" />
          </tr:commandNavigationItem>
        </f:facet>
      </tr:navigationPane>

Usage of contents model:

                    <tr:navigationTree
                      id="helpContextTree"
                      var="_item"
                      value="#{helpContextMenuModel}">
                      <f:facet name="nodeStamp">
                        <tr:commandNavigationItem
                          text="#{_item.label}"
                          partialSubmit="true">
                          <t:updateActionListener
                            value="#{_item.id}"
                            property="#{helpBean.currentHelpTopicKey}" />
                        </tr:commandNavigationItem>
                      </f:facet>
                    </tr:navigationTree>


-Andrew

Mime
View raw message