I am having a tabMenu using menu items each of the menu items has a parameter "i" that is linked to the activeIndex to indicate which page to load when the tab is clicked.
The problem I faced is that I need to get this parameter value of i to call another widget that is doing an action / processing. Is there any way I can get this parameter value of i and pass it to my widget managed bean (the widget contains a command button that is supposed to call a method in the widget managed bean and do some processing based on the menu that is selected).
The widget is saperate from the tabMenu, but still is on the same page as the tab menu. Is there a way to do this?
TabMenu is something like this:
<p:tabMenu activeIndex="#{param.i}">
<p:menuitem value="AAA" outcome="/ABC/DEF/123.xhtml">
<f:param name="i" value="0" />
</p:menuitem>... continued similar menuitem for 3 times with values for i 0-3
</p:tabMenu>
My widget contains a command button that looks like this:
<h:commandButton outcome="widget" action="#{mbean.callWidgetMethod}" >
</h:commandButton>
Can anyone please guide me? Thanks in advance.
OK, I found the answer
In the xhtml :
<h:commandButton outcome="widget" action="#{bean.callWidgetMethod}" >
<f:param name="i" value="#{param['i']}" />
</h:commandButton>
In the Managed Bean:
Map<String,String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
String param = params.get("i");
System.out.println("i = "+param);