Hi,
I'm trying to use <rich:panelMenu and I have my panel menu items.
<rich:panelMenuItem label="Member Activity List" action="#{panelMenu.memberActivityList}">
It calls the seam component, panelMenu and calls that method which is
public String memberActivityList() {
return "/MemberActivityList.xhtml";
}
The problem is - the <rich:panelMenu is not staying at the item I just clicked on, it folds up and does not show the selected menu item.
Why is that so?
Should I be returning something different from my method?
Any help greatly appriciated,
Thanks, Philip
I want to clarify, it is ok if it is on the same page. Its when I go to a different page, it forgets its state. How can I pass the state across?
I see a selectedChild attribute on it, would I be able to use this?
See this thread, you only hope right now is to use an iframe or frames.
I believe that imagination is stronger than knowledge -- myth is more potent than history -- dreams are more powerful than facts -- hope always triumphs over experience -- laughter is the cure for grief -- love is stronger than death.
Yes, I would try binding selectedChild to a bean in conversation scope. Sounds just like selectedTab (for a TabPanel), which works like a charm!
The only limit to our realization of tomorrow will be our doubts of today.
You may also need to add something like this to pages.xml if you are doing redirects:
<param name="selectedTab" value="#{commonController.selectedTab}" />The only limit to our realization of tomorrow will be our doubts of today.
It sounds like the right idea, thanks - but do you have an example of doing it using the tabs?
I'm very interested to see a similar example to copy.
Geez, do you want a donut with that ;-)
<rich:tabPanel switchType="ajax" selectedTab="#{commonController.selectedTab}">@Name("commonController") @Scope(ScopeType.CONVERSATION) public class CommonController extends EntityController { protected String selectedTab; public String getSelectedTab() { return selectedTab; } public void setSelectedTab(String selectedTab) { this.selectedTab = selectedTab; } }The only limit to our realization of tomorrow will be our doubts of today.
PS Doesn't need to extend EntityController, nothing special here, just a getter and setter and you're good to go!
The only limit to our realization of tomorrow will be our doubts of today.
FYI, in case you have a long running conversation you will propagate it to /MemberActivityList.xhtml.
Hi Ingo,
Yes please give me a donut, I've spend over a day full time trying many combinations and what you suggested and it didn't work for me.
My next step will be to try what you suggested for the tab panel to make sure that I can do it AT LEAST with the tab panel. Then I will go back to this rich:panelMenu. I'm about to go insane.
Thanks, Philip
Hi Philip, have you tried setting breakpoints on the getter and setter in your backing bean? Are these methods being called?
The only limit to our realization of tomorrow will be our doubts of today.
Hi, It calls get method a lot but never sets it to a different value. sad
(please help... begs)
Post your code, will work for donuts :-)
The only limit to our realization of tomorrow will be our doubts of today.
Wow, working for donuts! - its going to be difficult to send you a donut unless your in Hong Kong, and sadly the Krispy Kreme shut down due to financial problems when all the financial workers lost their jobs.
The zip is located at http://www.intercitizen.com/menu.zip which is 292k.
If you want all the lib jars that seamgen made, do http://www.intercitizen.com/menularge.zip but thats 64mb.
I use IntelliJ 8 to develop, this was all from a seamgen from a database, so I tried to delete most of the files out of it to cut it down for this purpose. The IntelliJ project is there. Ant file as well.
Its from a seamgen as I'm trying to develop quickly a CMS, so well the functioning of the menu is important from the customers perspective.
The important files are:
1) In the view, the template includes the menu.xhtml which has the rich:panelMenu for the left hand side of the page. Note it has selectedChild="#{panelMenu.selectedChild}".
2) Staff.page.xml and Staff.xhtml is the page we are going to, we get there through a click of the menu action="#{panelMenu.staff}".
3) PanelMenu.java this is the seam component. It has a method staff which takes us to the Staff.xhtml page.
The steps that happen:
http://localhost:8080/artawardscheme/
Ok it takes me to http://localhost:8080/artawardscheme/home.seam fine.
Click on top left menu - click on "Member Statistics" under "Manage Membership".
Fine, it takes me to the same page via a post, "Member Statistics" is now highlighted AND the menu is open at the current point, good I want it open.
Click on "Search Members". This takes us to http://localhost:8080/artawardscheme/Staff.seam?selectedChild=1&cid=4
Now the menu is closed up, thats not what I want. I want the current item to be selected and the menu in the open position.
What I think is happening is its happy on a post of some form, as I saw in the docs somewhere it uses a form to post the state.
So its not happy on the redirect. However the problem is that my seamgen project has lots of pages and I need to go from page to page.
Hope you can help -
let me know if you need more than a stale donut.
Thanks, Philip
Try adding this to Staff.page.xml:
<param name="selectedChild" value="#{panelMenu.selectedChild}" />The only limit to our realization of tomorrow will be our doubts of today.
i tried now, not working.
)
.-"(" "-.
.-|`'---'`|
| | | ____
\| | .'` __ `'. ____
`\ / | '--' |.'` __ `'.
`"---"` \`------`/| '--' |
`------' \`------`/
`------`
_.-------._
'....___....'.
/.....(___).....\
|'_..........._.'|
|....`'-----'`...|
\............../
'-..______..-'
Ha ha .... good one!
Try setting a breakpoint on panelMenu.selectedChild, is it even being called?
The only limit to our realization of tomorrow will be our doubts of today.
Hi,
Here are the facts.
The set method (setSelectedChild(...)) is never called.
When running the program with the following code
@Name("panelMenu")
@Scope(ScopeType.SESSION)
public class PanelMenu extends EntityController {
@Logger
private Log log;
private int getCalls = 0;
private int setCalls = 0;
protected String selectedChild = null;
public String getSelectedChild()
{
log.info("######### get selected child " + selectedChild + " : " + (++getCalls) + " times");
return selectedChild;
}
public void setSelectedChild(String selectedChild)
{
log.info("######### set selected child " + selectedChild + " : " + (++setCalls) + " times");
this.selectedChild = selectedChild;
}
1) I run it - and when I first load the page I get these log messages (... means lots of messages)
12:15:06,810 INFO [PanelMenu] ######### get selected child null : 1 times
...
12:15:10,929 INFO [PanelMenu] ######### get selected child null : 40 times
12:15:10,931 INFO [PanelMenu] ######### get selected child null : 41 times
2) Then I click on a menu item which is keeping it on the same page,
12:25:18,787 INFO [PanelMenu] ######### get selected child null : 42 times
12:25:18,790 INFO [PanelMenu] ######### get selected child null : 43 times
12:25:23,091 INFO [PanelMenu] ######### get selected child null : 44 times
12:25:23,093 INFO [PanelMenu] ######### get selected child null : 45 times
3) Then I click on the link which goes to new page (as above email) action="#{panelMenu.staff}"
12:26:05,379 INFO [PanelMenu] ######### get selected child null : 46 times
...
12:26:10,138 INFO [PanelMenu] ######### get selected child null : 86 times
12:26:12,852 INFO [STDOUT] Hibernate:
select
venue0_.id as id14_,
venue0_.description as descript2_14_
from
artawardscheme.venue venue0_ limit ?
12:26:13,949 INFO [PanelMenu] ######### get selected child null : 87 times
...
12:26:14,620 INFO [PanelMenu] ######### get selected child null : 97 times
Note that the set is never called.
Thanks, philip
Hi,
I paid for a solution!
http://www.getafreelancer.com/projects/Java-J-EE/Solve-Java-Richfaces-SEAM-problem.html
Since I paid - its not fair for me to share it, as I'd be putting the author out of business.
But the developers of Richfaces should know that its not a simple solution, they should have made this component simple to work across different pages.
Thanks, Philip
One possible solution
Yes good but I guess it doesn't work down to multiple nested levels? here's some ideas from the one I purchased without giving away too much the code. (I'm not sure about the morality here but I want to be helpful?)
<rich:panelMenuGroup label="Manage Membership" expanded="#{panelMenu.item('manageMembership').expanded}" name="manageMembership" action="#{panelMenu.itemSelected('manageMembership', null)}">
<rich:panelMenuItem label="Member Statistics" name="memberStatistics" action="#{panelMenu.itemSelected('memberStatistics', '/Staff.xhtml')}">
RichfacesMenuHelper has above member itemSelected, itemData = new HashMap<String, MenuItemData>(), selectedChild.
public MenuItemData item(String key) {
if (!itemData.containsKey(key)) {
MenuItemData item = new MenuItemData(key);
itemData.put(key, item);
}
return itemData.get(key);
}
class MenuItemData has key (String), expanded and selected.
Nesting levels also worked:
<rich:panelMenu style="width:200px" mode="client" selectedChild="#{menuState.selectedMenuItem}" iconExpandedGroup="disc" iconCollapsedGroup="disc" iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right" iconCollapsedTopGroup="chevronDown" iconCollapsedTopPosition="right" > <rich:panelMenuGroup label="Group 1" id="group1" value="#{menuState.menu['group1']}"> <rich:panelMenuItem label="Item 1" id="group1_item1" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> <rich:panelMenuItem label="Item 2" id="group1_item2" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> <rich:panelMenuItem label="Item 3" id="group1_item3" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> <rich:panelMenuGroup label="Group 1.1" value="#{menuState.menu['group1_1']}"> <rich:panelMenuItem label="Item 1" id="group1_1_item1" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> <rich:panelMenuItem label="Item 2" id="group1_1_item2" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> </rich:panelMenuGroup> </rich:panelMenuGroup> <rich:panelMenuGroup label="Group 2" id="group2" value="#{menuState.menu['group2']}" > <rich:panelMenuItem label="Item 1" id="group2_item1" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> <rich:panelMenuItem label="Item 2" id="group2_item2" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> <rich:panelMenuItem label="Item 3" id="group2_item3" actionListener="#{menuBean.select}" action="/select.xhtml" mode="server"/> </rich:panelMenuGroup> </rich:panelMenu>Max,
Thanks for the solution. Unfortunately, I having trouble with Safari (3.2.1). For the life of me, I can't get the actionListener on a menu item to fire with Safari (3.2.1). Clicking does nothing. Are you aware of any javascript or related problems with this browser? Firefox and Opera work perfectly - saving state, firing events, etc.
Thanks again.
It turns out that this problem (with Safari) was addressed in the latest RichFaces release (3.3.0). The previous release 3.2.2 wasn't firing the actionListener events in the latest version of Safari (which confusingly is version 3.2.1).
I dropped in the new jars and voila! Everything works. Thanks again Max!