roggaioso
roggaioso

Reputation: 15

validation and rich: popupPanel don't work

My intention is to display a message to the user in a rich: popupPanel after insert a record in BD.

With the code below I get to do what I want, but with a problem. Only works when I type all page fields correctly. If one of the fields does not pass in validation, the validation message is displayed in the h:messages, and the page does not change, even if I change the contents of the field and click the button again.

What could be wrong?

Upvotes: 0

Views: 3327

Answers (1)

Elias Dorneles
Elias Dorneles

Reputation: 23806

When you render the contents of a rich:popupPanel through AJAX (rendering from a4j:commandButton), it may be best choose to display it conditionally using its show attribute, instead of calling Javascript code (oncomplete).

So, I suggest you just add a condition for showing the popupPanel. Assuming that textoModal is null upon initialization, and your bean is a request scoped, you can just use something like this:

<rich:popupPanel id="pnlOk" modal="true"
       show="#{dizimistaMB.textoModal != null}" ...>

You may want to create a method in the backing bean something like public boolean isShowTextoModal() that may implement better rules than simply checking if a field is not null.

Then, you can change your button to this:

<h:commandButton id="btnInserirDizimista" value="Inserir"
       render="pnlMessages outPnlOk"
       action="#{dizimistaMB.inserirDizimista}" />

... and remove the ActionEvent argument from your method inserirDizimista, making it an action method instead of a actionListener.

This should get things going for you.

Upvotes: 1

Related Questions