myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chad Skinner <cha...@sbcglobal.net>
Subject Re: PanelNavigation2
Date Thu, 14 Aug 2008 12:30:50 GMT
Is the example incorrect then? The example uses NavigationMenuItem  
which extends the Model object and not UIComponent. I don't believe  
that it has a getChildren method, but rather only an  
add(NavigationMenuItem) method. Hense my problem figuring out how to  
add attributes or parameters to it. I was just looking at the 1.7  
snapshot docs and there is a a UINavigationMenuItem, should this be  
used in place of NavigationMenuItem?



On Aug 14, 2008, at 6:07 AM, Eivind Ronnevik wrote:

> Chad,
>
> I guess you can use the UIParameter object:
>
>
> UIParameter parameter = new UIParameter();
> parameter.setName(“yourName”);
> parameter.setValue(“theValue”);
>
> In your loop you would then add this to the lItem
> lItem.getChildren().add(parameter);
>
> And then you look it up in your ActionListener method like this:
>
> FacesContext context = FacesContext.getCurrentInstance();
> Map map = context.getExternalContext().getRequestParameterMap();
> String key = (String) map.get("yourName ");
>
> Regards,
>
> Eivind
>
>
> From: Chad Skinner [mailto:cws-dls@sbcglobal.net]
> Sent: 14. august 2008 04:35
> To: MyFaces Discussion
> Subject: PanelNavigation2
>
> I am trying to create a dynamic PanelNavigation Menu using the  
> method utilized in the examples. The problem I am having is that I  
> need my actionListener to be able to access an attribute that  
> identifies the current item and I don't see how to add an attribute  
> to the NavigationMenuItem.
>
> For example, I have the facelet code:
>
> <t:panelNavigation2 id="profileNavigation"
>                     layout="list"
>                     itemClass="mypage"
>                     activeItemClass="selected"
>                     disabledStyle="color:red">
>    <t:navigationMenuItems id="navitems" value="#{mybean.menuItems}" />
> </t:panelNavigation2>
>
>
>
> My Bean contains the following Code similar to the following as I  
> have removed a lot of the code to simplify the example:
>
> List<NavigationMenuItems> lMenuItems = new  
> ArrayList<NavigationMenuItem>();
> for( Student lStudent : students ) {
>    NavigationMenuItem lItem = new  
> NavigationMenuItem( lStudent.getName(), "#{myaction}");
>    lItem.setActionListener("#{myActionListener}");
>    lItem.setValue(lStudent.getName())
> }
>
> The problem is that when the user clicks on the menu Item the action  
> listener needs access to two pieces of information: 1) the student  
> and 2) a display mode.
>
> Can anyone tell me what I need to do to set attributes on the  
> components so that I can look them up in the actionListener.


Mime
View raw message