File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Dialog in JSF page starts working only after page reload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Dialog in JSF page starts working only after page reload" Watch "Dialog in JSF page starts working only after page reload" New topic
Author

Dialog in JSF page starts working only after page reload

Dmitry Perv
Greenhorn

Joined: Apr 23, 2014
Posts: 5
The problem:
When the application starts and the index page is initially loaded, dialog is not shown correctly (panel is not shown) and shows that selected==null. But in debugger prepareSelect seems working correctly and selected is initialised (not null). When I reload page, dialog is shown correctly.
Below are facelets for the page composition and backing bean code.

Register.xhtml


index.xhtml


backing bean:
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

Since I'm a pedant, I first have to mention again that in JSF you don't write Controllers. Backing Beans are Models.

As far as your actual problem, if PrimeFaces is like RichFaces, a Dialog should be contained completely within its own JSF form, and forms (JSF or HTML) cannot be nested.

I see and end-form tag that looks like it goes with the dialog, but not corresponding start-form tag.


Customer surveys are for companies who didn't pay proper attention to begin with.
Dmitry Perv
Greenhorn

Joined: Apr 23, 2014
Posts: 5
Tim Holloway wrote:Since I'm a pedant, I first have to mention again that in JSF you don't write Controllers. Backing Beans are Models.

JSF files are generated by Netbeans wizards, but thank you for your comment.
Tim Holloway wrote:As far as your actual problem, if PrimeFaces is like RichFaces, a Dialog should be contained completely within its own JSF form, and forms (JSF or HTML) cannot be nested.

I see and end-form tag that looks like it goes with the dialog, but not corresponding start-form tag.

Dialog is included in the index.xhtml page after the </form> tag... What line of the code did you mention?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16137
    
  21

If NetBeans is automatically naming backing beans "XxxxController", I have issues with them. A Controller's sole task is to update the View from the Model and the Model from the View. That function is handled in JSF by the FacesServlet and the various control tags. Action methods are not Controller methods - they're business logic (not part of MVC), and backing bean properties are quite obviously Model attributes.

I looked again and found your opening form tag. What I think you may need to do is relocate it so that the form encloses the dialog instead of having the dialog enclose the form. But I recommend checking the documentation just to be sure.
Dmitry Perv
Greenhorn

Joined: Apr 23, 2014
Posts: 5
There is a mistake in line 16 of the index.xhtml - there should be :AppUserRegisterForm.

Tim, thank you very much for your comments and assistance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dialog in JSF page starts working only after page reload