I had a quick look at the code to see if there was
a simple way to resolve:

  http://issues.apache.org/jira/browse/TRINIDAD-708

... and, ouch, not really.  The problem's not so much
on the XMLMenuModel side of things, but the
MenuContentHandlerImpl and MenuNode code,
where we have:
  - A singleton MenuContentHandlerImpl that is
    storing a requestMap key to pass it onto the MenuNode
  - MenuNodes that use that key to go back and locate the
    root menu model.
Fixing the one-XMLMenuModel-per-page limitation is going
to require rethinking this odd design.

-- Adam



On 9/12/07, Adam Winer <[EMAIL PROTECTED]> wrote:
> On 9/12/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
> > I changed the managed-bean-scope to request for both, seeing that in
> > the developer guide, but it doesn't affect this code.
> >
> > Is there some odd requirement that there can only be one XmlMenuModel
> > per application?
>
> There definitely shouldn't be any such requirement.  I
> don't know the code well enough to know why this might
> go wrong.
>
> -- Adam
>
>
> >
> > -Andrew
> >
> > On 9/12/07, Andrew Robinson <[EMAIL PROTECTED]> wrote:
> > > 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
> > >
> >
>

Reply via email to