Problem in rendering

Asked

Viewed 30 times

1

In my registration screen I have 2 buttons: Save and Come back.
In case I am editing some record, the button is enabled New.
My problem is when I click this button New the screen gives the refresh but what I want is to clean the data for a new registration. A help please?

Method that is triggered when I click the button:

public void novo(){
    if (nature == null){
        nature = new Nature();
    } else{
        nature = null;
    }
    }

Button code:

<p:commandButton actionListener="#{habilidademb.novo}" value="Novo" ajax="false" update="cadastro" rendered="#{naturemb.nature.id != null}" styleClass="separadorBotoes"/>
  • The problem is that you can not mark ajax="false", you are exactly making the screen give refresh. take this option, by default jsf already leaves ajax as true.

  • Another thing, in your new() method, you don’t need to do any checking, just let Nature = new Nature();

1 answer

1


Solved. There were 2 problems:

  • Mb’s name was wrong.
  • In the method novo() needed to instantiate the object at the end.

    public void new() { if (Nature == null) { Nature = new Nature(); } Else { Nature = null; Ature = new Nature(); } }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.