Previously, I used java ee 7 and glassfish 4 and my code was working correctly. After switching to Jakarta ee 8 and payara the selectEvent used is returning null. Follow the code below.
html
<sys:inputConverter convUpdate=":form1:mensagem" entidade="Religiao"
objeto="#{alunoJsfBean.crudObj.religiao}"
prepBuscaMetodo="#{bscBean.abrirPesquisaReligiao()}" />
.
.
.
inputConverter.xhtml
.
.
.
<cc:interface componentType="br.com.systempro.conversores.InputConverterUIComponent">
<cc:attribute name="dlgReturnListenner" method-signature="void java.lang.String listener(org.primefaces.event.SelectEvent)" />
</cc:interface>
.
.
.
<p:commandButton id="btnPesquisar" value="#{cc.attrs.nameBtn}" icon="#{icon.pesquisar}" process="@this #{cc.attrs.prepBuscaProcess}" update="@this #{cc.attrs.prepBuscaUpdate}" actionListener="#{cc.attrs.prepBuscaMetodo}" disabled="#{cc.attrs.disabled}" title="Abrir Pesquisa" tabindex="-1" styleClass="styleClass">
<p:ajax event="dialogReturn" listener="#{cc.attrs.dlgReturnListenner}" update="@parent #{cc.attrs.dialogReturnUpdate}"
oncomplete="PrimeFaces.focus('#{cc.clientId}:codigo');#{cc.attrs.dialogReturnOncomplete}" />
<p:resetInput target="#{cc.clientId}:codigo" rendered="#{cc.attrs.resetInput}" />
</p:commandButton>
.
.
.
...
InputConverterUIComponent.java
package br.com.systempro.conversores;
import br.com.systempro.beans.GerBean;
import br.com.systempro.utils.JsfUtil;
import java.util.ArrayList;
import java.util.List;
import javax.el.ELContext;
import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.NamingContainer;
import javax.faces.component.UIInput;
import javax.faces.component.UINamingContainer;
import javax.faces.context.FacesContext;
@FacesComponent("br.com.systempro.conversores.InputConverterUIComponent")
public class InputConverterUIComponent extends UIInput implements NamingContainer {
@Override
public String getFamily() {
return UINamingContainer.COMPONENT_FAMILY;
}
public String getDescInput() {
ELContext context = FacesContext.getCurrentInstance().getELContext();
if (getValueExpression("objetoDesc") != null) {
Object objetoDesc = getValueExpression("objetoDesc").getValue(context);
if (objetoDesc != null) {
return objetoDesc.toString();
}
}
Object objeto = getValueExpression("objeto").getValue(context);
if (objeto == null) {
return "";
}
if (objeto instanceof List) {
List<Object> objects = (List<Object>) objeto;
if (objects.isEmpty()) {
return "";
} else if (objects.size() == 1) {
return objects.get(0).toString();
} else {
return objects.size() + " Itens selecionados";
}
} else {
return objeto.toString();
}
}
public void selectObj(org.primefaces.event.SelectEvent event) {
if (event.getObject() == null) {
return;
}
ELContext context = FacesContext.getCurrentInstance().getELContext();
ValueExpression ve = getValueExpression("objeto");
if (event.getObject() instanceof List) {
List<Object> lst = (List<Object>) event.getObject();
List<Object> retorno = new ArrayList<>();
for (Object value : lst) {
retorno.add(value);
}
ve.setValue(context, retorno);
} else {
ve.setValue(context, event.getObject());
}
JsfUtil.getJsfBean(GerBean.class).getObjetosSelecionados().clear();
}
}
In the selectEvent method the event is null. If I pass the selectObj () method directly in the ajax listener, it works.
<p:commandButton id="btnPesquisar" value="#{cc.attrs.nameBtn}" icon="#{icon.pesquisar}" process="@this #{cc.attrs.prepBuscaProcess}" update="@this #{cc.attrs.prepBuscaUpdate}" actionListener="#{cc.attrs.prepBuscaMetodo}" disabled="#{cc.attrs.disabled}" title="Abrir Pesquisa" tabindex="-1" styleClass="styleClass">
<p:ajax event="dialogReturn" listener="#{cc.selectObj}" update="@parent #{cc.attrs.dialogReturnUpdate}"
oncomplete="PrimeFaces.focus('#{cc.clientId}:codigo');#{cc.attrs.dialogReturnOncomplete}" />
<p:resetInput target="#{cc.clientId}:codigo" rendered="#{cc.attrs.resetInput}" />
</p:commandButton>
Why is this happening?
Primefaces 6.2 Jakarta ee 8 Payara 5.201