0
Why my Bean is not recognizing the attribute of a simple selectOneMenu:
I created in my Bean the attribute private Long areaprevencaoId
.
This attribute is associated with a <p:selectOneMenu>
xhtml
<h:selectOneMenu value="#{cadastroUsuarioBean.areaPrevencaoId}">
<f:selectItems value="#{cadastroUsuarioBean.listaAreaPrevencaoSelect}"></f:selectItems>
</h:selectOneMenu>
<p:commandButton action="#{cadastroUsuarioBean.incluirArea}" value="Incluir"
process="@this" update="panel-grid-equipe" immediate="true" />
My Bean that uses the attribute:
public void incluirArea() {
if (areaPrevencaoId == null) {
messages.error("Selecione uma Equipe");
} else {
usuarioPrevencao.setUsuarioId(usuario.getId());
usuarioPrevencao.setAreaprevencaoId(areaPrevencaoId);
try {
usuarioPrevencaoRepository.salvar(usuarioPrevencao);
//this.listaUsuarioPrevencao = usuarioPrevencaoRepository.todosIdUsuario(usuario.getId());
} catch (PersistenceException e) {
messages.error("Erro ao gravar os dados da Equipe do Usuário");
}
}
RequestContext.getCurrentInstance().update(Arrays.asList("msg-area-prevencao","painel-equipe"));
}
My suggestion is that you do the
process
of the form instead of theCommandButton
, but none of the components ofform
will go through the jsf lifecycle and update your template (Bean
).– Wakim
Wakin made the adjustment, but it’s still going null.
– Marcelo Gomes
Place
@form
in the attributeprocess
?– Wakim
Wakin, you were right. In xhtml it was all within a single form. I separated and made the
process="@form"
and it worked. Thanks!– Marcelo Gomes
I will put as an answer so that others can find the solution to the problem if it is the same.
– Wakim