I'd like to save in some variable (menuSize) the size of my <p:panelMenu> which is surrounded by an <p:layoutUnit> element. I tried the following :
In my view (xhtml) :
<p:layoutUnit id="myMenuLayout" position="west" size="#{loginBean.menuSize}" resizable="true" header="Menu">
<p:panelMenu id="myPanelMenu" widgetVar="myMenu" model="#{menuModelGenerator.menuModel}" />
</p:layoutUnit>
<p:resizable for="myMenuLayout" onResize="#{loginBean.keepMenuSize(event)}" />
In my controller :
public void keepMenuSize(ResizeEvent event) {
if (event != null) {
menuSize = event.getWidth();
} else {
logger.info("event is null !!");
}
But my keepMenuSize method is not called when I resize the menu, and the value of the event still null when I refresh the page into the browser
What am I missing ?
EDIT :
I've succeed now to make keepMenuSizemethod called using the following :
<p:layoutUnit id="boToolMenuLayout" position="west" size="#{loginBean.menuSize}" resizable="true" header="Menu">
<p:panelMenu id="boToolPanelMenu" widgetVar="boToolMenu" model="#{menuModelGenerator.menuModel}" />
</p:layoutUnit>
<p:ajax event="resize" listener="#{loginBean.keepMenuSize}" global="false" />
But the problem now is that my method is called twice, for example :
When I resize my menu into the UI, the logger I've implemented into keepMenuSize method says that the size value is 475px, then immediately after that says that the size value is 711px.
Then if I resize again, it says 864px then immediately 322px...etc.
Does anyone knows why ?
Thank you