-
1. Executing code when panelMenuGroup collapses/expands
martind1111 May 18, 2011 9:57 AM (in response to martind1111)The reason I am trying to exexute code when panelMenuGroup is expanded/collapsed is to trrack value of expanded property. I have defined expanded property as :
expanded="#{mybean.expanded}"
The menu has the right expansion when first rendered, but when the expansion is changed, this value in the back end bean is not updated. I would like to execute some code in the back end when the expansionchanges to update my backing bean expanded property in order for menu to be rendered with appropriate expansion next time the form is refreshed.
Martin
-
2. Executing code when panelMenuGroup collapses/expands
martind1111 May 20, 2011 8:02 AM (in response to martind1111)I found out researching this issue that the onbeforeexpand and onbeforecollapse properties in the rich:panelMenuGroup were good placeholders for executing JavaScript code. I still haven't figured out how to get the changeExpandListener to work in a backing bean, but in the meantime, I trigger code to execute on expand and collapse which updates a h:inputHidden field on my page that gets submitted when the form refreshes (groupMode is set to server to force page submit on expand/collapse) and that I use to keep track of the status of the expand state of the panelMenuGroup.
Martin
-
3. Re: Executing code when panelMenuGroup collapses/expands
eunnini Jul 11, 2011 4:49 AM (in response to martind1111)Hi Martin,
I had the same problem as you, and inspired by your post found another workaround.
If you want you could use listeners for onbeforeexpand and onbeforecollapse events, or just onswitch listener, something like this
<a4j:ajax event="switch" listener="#{leftMenu.switchEvent}" render="left_menu" limitRender="true" execute="@this"/>
<a4j:param value="menu1" name="menu"/>
public void switchEvent(AjaxBehaviorEvent event){
String menu = FacesUtils.getParameterFromRequestMap("menu");
if(menu.equals("menu1"))
this.menu1 = !this.menu1;
...
}
You could than read a4j parameter from request scope and set specific attribute to collapsed/expanded
Regards
Nikola