Object is not completed

Asked

Viewed 65 times

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 just action doesn’t work?

  • 1

    @Igorventurelli works not :(

1 answer

0

Try replacing the process="@this" from its button to @form.

Browser other questions tagged

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