-
15. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Dec 21, 2008 5:23 PM (in response to philip142au.philip_andrew.hotmail.com)Hi Ingo,
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 -
16. Re: How to keep component state on page? (rich:panelMenu)?
joblini Dec 22, 2008 6:53 AM (in response to philip142au.philip_andrew.hotmail.com)Try adding this to Staff.page.xml:
<param name="selectedChild" value="#{panelMenu.selectedChild}" />
-
17. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Dec 22, 2008 8:08 AM (in response to philip142au.philip_andrew.hotmail.com)i tried now, not working.
-
18. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Dec 22, 2008 12:33 PM (in response to philip142au.philip_andrew.hotmail.com)Donut?
)
.-"(" "-.
.-|`'---'`|
| | | ____
\| | .'` __ `'. ____
`\ / | '--' |.'` __ `'.
`"---"` \`------`/| '--' |
`------' \`------`/
`------` -
19. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Dec 22, 2008 12:49 PM (in response to philip142au.philip_andrew.hotmail.com)
_.-------._
'....___....'.
/.....(___).....\
|'_..........._.'|
|....`'-----'`...|
\............../
'-..______..-' -
20. Re: How to keep component state on page? (rich:panelMenu)?
joblini Dec 23, 2008 7:10 AM (in response to philip142au.philip_andrew.hotmail.com)Ha ha .... good one!
Try setting a breakpoint on panelMenu.selectedChild, is it even being called?
-
21. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Dec 24, 2008 5:34 AM (in response to philip142au.philip_andrew.hotmail.com)
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 -
22. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Dec 28, 2008 9:51 AM (in response to philip142au.philip_andrew.hotmail.com)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
-
24. Re: How to keep component state on page? (rich:panelMenu)?
philip142au.philip_andrew.hotmail.com Jan 1, 2009 1:16 PM (in response to philip142au.philip_andrew.hotmail.com)Hi Max,
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. -
25. Re: How to keep component state on page? (rich:panelMenu)?
mkatz Jan 2, 2009 5:39 PM (in response to philip142au.philip_andrew.hotmail.com)
philip andrew wrote on Jan 01, 2009 13:16:
Hi Max,
Yes good but I guess it doesn't work down to multiple nested levels?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>
-
26. Re: How to keep component state on page? (rich:panelMenu)?
dan19460 Jan 23, 2009 9:15 PM (in response to philip142au.philip_andrew.hotmail.com)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.
-
27. Re: How to keep component state on page? (rich:panelMenu)?
dan19460 Jan 24, 2009 2:44 PM (in response to philip142au.philip_andrew.hotmail.com)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!
-
28. Re: How to keep component state on page? (rich:panelMenu)?
jsfgeeks Nov 28, 2009 10:39 AM (in response to philip142au.philip_andrew.hotmail.com)hello,
SORRY if i am posting this message at a wrong place.
actually i am developing richfaces jsp project.
In my project i use Panel Menu for different topic listing of different category. for dyanmic panel menu group and panel menu item i am using C:for Each and c:if tag. like below
`
<c:if test="${contentlist.current_subject==1}">
<rich:panelMenu selectedChild="#{contentlist.current}"
style="width:250px;height:600px" expandMode="ajax" mode="ajax" expandSingle="true" id="pnlmenu_phy"
iconExpandedGroup="disc" iconCollapsedGroup="disc" topItemStyle="color:red;"
iconExpandedTopGroup="chevronUp" iconGroupTopPosition="right"
iconCollapsedTopGroup="chevronDown">
<c:forEach items="#{contentlist.selectItems_std}" var="std1">
<rich:panelMenuGroup value="#{listState.lststate}" expanded="true" actionListener="#{listState.select}" id="pnlmenugrp_phystd" style="background-color:red" label="#{std1.label}" >
<h:outputText value="#{listState.lststate}"/>
<c:forEach items="#{contentlist.selectItems_chap}" var="chap1">
<c:if test="${chap1.description==std1.value}">
<rich:panelMenuItem name="#{chap1.value}"
id="pnlmenuitm_phychap" mode="ajax" ignoreDupResponses="true" ajaxSingle="true" action="#{contentlist.chapterlist_action}" label="#{chap1.label}" >
<a4j:support id="ajxsprt_phychap" event="onclick" reRender="datagridtopic"></a4j:support >
<rich:dragSupport id="drgsprt_phychap" dragIndicator=":drgindic"
dragType="value" dragValue="#{chap1.value}">
<rich:dndParam id="dndprm_phychap" name="label" value="#{chap1.label}" />
</rich:dragSupport>
<f:param id="fprm_phychap" name="current" value="#{chap1.value}"/>
</rich:panelMenuItem>
</c:if>
</c:forEach>
</rich:panelMenuGroup>
</c:forEach>
</rich:panelMenu>
</c:if>
`
Everything is working fine.
now my problem is i am using datagrid which is get rendered as user clicks on panel meu items and there are links on datagrid rows.
when user clicks on that links and come back to this page i want to maintain state of Panelmenu and panel menu group.
suppose i have selected Group2 >item4 then when back from redirect it gets selected and expanded.
i have tried your solution but how to use it with dynamic(iteration of c:foreach) panelmenugroup and item how to maintain state of panel menu.
flow is like below
1). i click on menugroup-it Exapnds
2).click on menuitem-datagrid renderd
3).click on datagrid item link to redirect to another page
4).back to current page.At this point i want maintain state
any help would gretly appriciated.