0
I have the following form from my page:
<h:panelGrid columns="3">
<p:outputLabel value="Código" for="codigo"/>
<p:inputText id="codigo" value="#{encomendaController.encomenda.codigo}" required="true"/>
<p:message for="codigo"/>
<p:outputLabel value="Loja/Origem" for="loja"/>
<p:selectOneMenu id="loja" value="#{encomendaController.encomenda.loja}" required="true">
<f:selectItem itemLabel="" itemValue="" />
<f:selectItems value="#{enumHelper.obterLojas()}" var="bean" itemLabel="#{bean.nome}" itemValue="#{bean.nome}" />
</p:selectOneMenu>
<p:message for="loja"/>
<p:commandButton value="Cadastrar" action="#{encomendaController.salvar()}" process="@this"/>
</h:panelGrid>
This is my controller:
@ManagedBean
@ViewScoped
public class EncomendaController {
@Getter
@Setter
private Encomenda encomenda;
@Getter
@Setter
private Collection<Encomenda> objetos;
@Inject
private EncomendaService service;
@PostConstruct
public void novo() {
encomenda = new Encomenda();
}
public void salvar() {
if (encomenda.getId() == null) {
service.insert(encomenda);
JsfUtils.addInfoMessage("encomenda.cadastrada");
} else {
service.update(encomenda);
}
}
What is happening is that by clicking the Register button, the values are not going to the object, that is, the attributes are not being filled. How can I solve ?
Put
actionListener="#{encomendaController.salvar}"
instead of justaction
doesn’t work?– igventurelli
@Igorventurelli works not :(
– Roknauta