Rendering problem

1

On my registration screen I have 2 buttons: Save and Back . If I'm editing a record, the New button is enabled. My problem is when I click this New button the screen gives the refresh but what I want is to clear the data for a new one. A help please?

Method that fires 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"/>
    
asked by anonymous 09.06.2016 / 03:13

1 answer

1

Solved. There were 2 problems:

  • The mb name was wrong.
  • In method novo() needed to instantiate the object at the end.

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

09.06.2016 / 18:41