1
In all the examples I saw of the code below, the normal one was to start the xhtml page to create a new client-like 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. Because?
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());
}
}
Thank you very much friend, gave it right here now! You’re the guy!
– Marco Aurélio Soares de Souza