Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Primefaces: Two mesages getting displayed instead of one for ajax blur event  RSS feed

 
Raghu Sundar
Ranch Hand
Posts: 40
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one row editable datatable.I have implemented email validation to one of the column where error message must display on blur of email field.This is working fine.I have a dialog with form to be displayed in the same page .Validation is implemented to this form also with on blur event.The dialog validation message gets displayed on blur but along with that the main form also displays the same validation message.This should not happen.

Any idea on how to fix this problem?

JSF page



The message with id lpcErrMsg is the one that i am displaying on blur in the main page when email format is wrong.And this message gets displayed with dialog field validation also although i have never referred to this id to be rendered in the dialog.

The message with id lpcDlgMsg is the message that i am displaying inside the dialog with widgetvar dlg on blur.As of now i have implemented blur event validation for the first required field in the dialog.
 
Tim Holloway
Bartender
Posts: 18531
61
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I propably didn't read that correctly. The longer the sample, the lazier I get, which is why it's a good idea to strip down examples to their basics.

However, what I think is going on is this:

Firstly, an AJAX element does a form submit, subject to the usual JSF rules. Meaning that for whatever fields the form contains, ALL submitted fields MUST be valid or nothing works. With AJAX the effective number of fields in the submitted form can be adjusted (for example, to only submit the email field itself), but I can't remember what the defaults are on that tag, so I recommend that you check the official docs to make sure you're doing it the way you need to.

In the case of a commandButton, the ENTIRE form is submitted and instead of partial page rendering, you get a full-page render of the response. And, as before, ALL fields on the form must be valid or the submit is rejected.

I don't use AJAX for Cancel buttons normally. The stock h:commandButton with "immediate=true" works pretty much the same way. You should verify that "onclick" isn't supposed to return a value. I know that the "submit=" attribute must return true or false because returning false suppresses the actual submit part of the button operation.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!