Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dialog in JSF page starts working only after page reload

 
Dmitry Perv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dmitry Perv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic