In all the examples I saw in the code below, the normal occurrence was when the xhtml page was started creating a new client-type object. Through the values entered in the inputs, set the attributes of this object and the commandbutton could use this data in some way, invoking a method. This is not happening in the code below. Why?
JSF Code:
<p:panel id="dados-cliente" header="Dados do Cliente">
<h:form>
<p:panelGrid id="dados-cliente-container" columns="2">
<p:outputLabel value="CNPJ:"/>
<p:inputMask mask="##.###.###/####-##" value="# {clienteMB.cliente.cnpj}"/>
<p:outputLabel value="Razão Social:"/>
<p:inputText value="#{clienteMB.cliente.razao_social}"/>
<p:commandButton action="#{clienteMB.Salvar}" value="Salvar" process="@this"/>
</p:panelGrid>
</h:form>
</p:panel>
Java code:
@ManagedBean
public class ClienteMB {
Cliente cliente;
public ClienteMB(){
cliente = new Cliente();
}
public Cliente getCliente() {
return cliente;
}
public void setCliente(Cliente cliente) {
this.cliente = cliente;
}
public void Salvar(){
System.out.println(cliente.getRazao_social());
System.out.println(cliente.getCnpj());
}
}