--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wildfly/60c01989-8231-4157-ac97-8693a919a7f2n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wildfly/b72daffc-a1da-442e-b851-be9972d1542fn%40googlegroups.com.
package org.primefaces.diamond.view;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import jakarta.annotation.PostConstruct;
import jakarta.faces.component.UIComponent;
import jakarta.faces.context.FacesContext;
import jakarta.faces.convert.Converter;
import jakarta.faces.event.AjaxBehaviorEvent;
import jakarta.faces.view.ViewScoped;
import jakarta.inject.Named;
@Named
@ViewScoped
public class CostVarianceView implements Serializable {
// Getter y Setter para el objeto seleccionado
private GasStationTO selectedGasStationTO = new GasStationTO();
private List<GasStationTO> listGasStation; // La lista que inventamos
@PostConstruct
public void init() {
// Inventamos los datos (Simulación de base de datos)
listGasStation = new ArrayList<>();
listGasStation.add(new GasStationTO(1L, "Estación Central - Repsol"));
listGasStation.add(new GasStationTO(2L, "Grifo Norte - Primax"));
listGasStation.add(new GasStationTO(3L, "E.S. El Puerto - Petroperú"));
listGasStation.add(new GasStationTO(4L, "Gasolinera San Isidro - Shell"));
}
public GasStationTO getSelectedGasStationTO()
{
return selectedGasStationTO;
}
public void setSelectedGasStationTO(GasStationTO selectedGasStationTO)
{
this.selectedGasStationTO = selectedGasStationTO;
}
// Este es el método que llama el p:ajax
public void handleCharactersChange(AjaxBehaviorEvent event)
{
System.out.println("Hello!");
if (selectedGasStationTO != null) {
System.out.println("Lógica ejecutada para: " + selectedGasStationTO.getName());
}
}
private Converter<GasStationTO> gasStationConverter = new Converter<>() {
@Override
public GasStationTO getAsObject(FacesContext context, UIComponent component, String value) {
if (value == null || value.isEmpty()) return null;
return listGasStation.stream()
.filter(g -> String.valueOf(g.getId()).equals(value))
.findFirst()
.orElse(null);
}
@Override
public String getAsString(FacesContext context, UIComponent component, GasStationTO value) {
if (value == null || value.getId() == null) return "";
return String.valueOf(value.getId());
}
};
public Converter<GasStationTO> getSelectedGasStationSupport() {
return gasStationConverter;
}
public List<GasStationTO> getListGasStation()
{
return listGasStation;
}
public void setListGasStation(List<GasStationTO> listGasStation)
{
this.listGasStation = listGasStation;
}
public Converter<GasStationTO> getGasStationConverter()
{
return gasStationConverter;
}
public void setGasStationConverter(Converter<GasStationTO> gasStationConverter)
{
this.gasStationConverter = gasStationConverter;
}
}
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="jakarta.faces.html"
xmlns:f="jakarta.faces.core"
xmlns:ui="jakarta.faces.facelets"
xmlns:p="primefaces"
xmlns:pb="http://xmlns.jcp.org/jsf/composite/primeblocks"
template="/WEB-INF/template.xhtml">
<ui:define name="title">Demo</ui:define>
<ui:define name="content">
<h:form id="viewCostVariance">
<p:growl id="messages" showDetail="true" />
<p:tabView id="tabViewMain">
<p:tab title="Estaciones">
<h:panelGrid columns="2" cellpadding="7">
<p:outputLabel for="listGasStationSelected" value="Seleccione Estación:" />
<p:selectOneListbox id="listGasStationSelected"
value="#{costVarianceView.selectedGasStationTO}"
var="g"
converter="#{costVarianceView.selectedGasStationSupport}"
filter="true"
filterMatchMode="contains">
<f:selectItems value="#{costVarianceView.listGasStation}"
var="item"
itemLabel="#{item.name}"
itemValue="#{item}" />
<!-- USAR EL LISTENER CORRECTO SIN ACTIONEVENT -->
<p:ajax listener="#{costVarianceView.handleCharactersChange}"
process="@this"
update="panelGridGasStationFuel" />
<p:column>
<h:outputText value="#{g.name}" />
</p:column>
</p:selectOneListbox>
</h:panelGrid>
<!-- Panel que se actualiza al cambiar la selección -->
<h:panelGroup id="panelGridGasStationFuel">
<p:fieldset legend="Detalle de Combustible" rendered="#{not empty costVarianceView.selectedGasStationTO}">
<h:outputText value="Estación seleccionada: #{costVarianceView.selectedGasStationTO.name}" />
<!-- Más campos aquí -->
</p:fieldset>
</h:panelGroup>
</p:tab>
</p:tabView>
</h:form>
</ui:define>
</ui:composition>
package org.primefaces.diamond.view;
import java.io.Serializable;
import java.util.Objects;
public class GasStationTO implements Serializable
{
private static final long serialVersionUID = 1L;
private Long id;
private String name;
public GasStationTO()
{
}
public GasStationTO(Long id, String name)
{
this.id = id;
this.name = name;
}
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
@Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
GasStationTO that = (GasStationTO) o;
return Objects.equals(id, that.id); // Compara por el ID único
}
@Override
public int hashCode()
{
return Objects.hash(id);
}
@Override
public String toString()
{
return name; // Útil para depuración
}
}
To view this discussion visit https://groups.google.com/d/msgid/wildfly/57a55029-e122-4a11-8ed9-8848638cea00n%40googlegroups.com.
omnifaces.SelectItemsConverter, or create a converter., to be clear this is not a problem from wildfly 39 or other version.@Jose. After upgrading to 'Mojarra 4.0.15' it has show an Error. Looking at your example it highlighted my error is probably with the/no 'converters'.public Converter<GasStationTO> getSelectedGasStationSupport() {I thought that I could use the OmniFaces 'ListConverter' as:<p:selectOneListbox
id="archersCharacters"
converter="omnifaces.ListConverter"
value="#{daily.theArchersCharactersString}">However when I 'click' on my 'selectOneListbox':<p:ajax
listener="#{theArchersDailyRSSController.handleCharactersChange}"
process="@this"
update="panelCharacterSelect"/>I get:Cannot invoke "java.util.List.iterator()" because "this.list" is nullAn Error Occurred:Looks like I need to create my own 'Converter'.Thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wildfly/ccb77d43-9b47-4c95-a3d0-b201f67a4f41n%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wildfly/CACKu8DVvJKHFa_KVdQ-QwqBTKqfx58f0wLUCakgDzRTh_STZPQ%40mail.gmail.com.
I like to hear that! :P I am, though, watching and waiting to see if there’s anything we need to do in WF or Mojarra. :)On Mar 24, 2026, at 5:00 PM, Jose Socola <jso...@gmail.com> wrote:
Hi,I think u can use omnifaces.SelectItemsConverter, or create a converter., to be clear this is not a problem from wildfly 39 or other version.Regards,
JS
To view this discussion visit https://groups.google.com/d/msgid/wildfly/CACKu8DVvJKHFa_KVdQ-QwqBTKqfx58f0wLUCakgDzRTh_STZPQ%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "WildFly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wildfly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wildfly/d24421fc-bcae-4ca8-b66e-0e6ce879a20bn%40googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/wildfly/eba6bf48-c006-4765-8b50-2e456cf3226fn%40googlegroups.com.

