简体   繁体   中英

Event for resize window in primefaces

I have problem with resize window. I use chart from primefaces jsf library and when window is resize chart is not resize and I want to ajax refresh chart with new size window.

Do you want to know how catch resize event in p:panel or p:outputPanel??

Perhaps you can combine some operations using HTML onresize event and p:remoteCommand.

Event in HTML would be:

<body onresize="updatechartpanel">
...
</body>

...but it's very likely that JSF woudn't validate the above, so you can bind the event from JavaScript:

<script type="text/javascript">
window.onresize = function(event) {
    updatechartpanel();
}
</script>

Where updatechartpanel() is simplified PrimeFaces remote command defined as following:

<p:remoteCommand name="updatechartpanel" update=":myform:mychartpanel" />

To be precise, there's nothing executed remotely because we don't call any bean action from this command. But it force update given components.

Nevertheless, be aware that this event is called almost every single resized pixel (also during mouse manipulations), so it would be worth to protect from too exhausting operations as it was proposed here: JQuery: How to call RESIZE event only once it's FINISHED resizing?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM