开发者

Primefaces - using dialogs and layouts

I have a (JSF 2.0/ Primefaces 2.2RC-SNAPSHOT) app that has

 <p:layout> 

I use a lot of dialog in my application and before the newest version of primefaces came out there was no way to display a dialog with a modal on top of the layout without putting the dialog开发者_如何学JAVAs outside of the tags.

So I did just that. The issue I am having now is I am noticing that constructors and postcontructs are being called when my application is loaded. This is because the view with the layout is being loaded and therefore all my dialogs are being loaded.

I don't want these constructors being called until I am actually dealing with the appropriate views in my application.

I have been testing the appendToBody attribute on the

 <p:dialog> 

tag but it seems really buggy. Everything works fine on the initial rendering of a view. I can open a dialog close it etc and it works fine. If I navigate away to another view and then come back to the initial view and open the dialog, everything is running off the page. The dialog window is in the correct place but the content is not.

My question is 1. Is there a way I can have the dialog windows outside of my layout as a child of the

 <h:body>

without having all the managed bean constructors associated with them initiated when the application loads?

Or does anyone know how to fix the alignment issue when using the appendToBody tag? Thanks.


When using layout and dialog, I usually place my dialogs outside of the layout as a direct child of the body element. I have a special ui:insert part in my page template for this.

appendToBody was added to make this easier, if it doesn't work well for you, give this approach a try. I know modal dialogs and layout can work this way.


without having all the managed bean constructors associated with them initiated when the application loads

Maybe the managedbean gets loaded when your dialog is rendered.

Try rendering the dialog only after the button click, perhaps byputting rendered="#{mybean.flagLoadMyDialog}" on the dialog, and set the flagLoadMyDialog when the button is clicked using ajax.

Also remember to ajax-update the dialog after the button click.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜