I have a site in Primefaces 10. There is a subsite fur listing the results. I want to have a selectManyCheckbox filled with a list of enums, which results in an array of those enums. On one subsite it works and on another I do almost the same thing (other enum) and I get the conversion error when I send the form. My xhtml looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="../layout.xhtml">
<ui:define name="header">
<div id="header">
Dashboard
</div>
</ui:define>
<ui:define name="main">
<style type="text/css">
.ui-chart {
margin-bottom: 50px;
}
</style>
<h:form id="dashboardForm">
<p:messages id="dashboardErrMsg" globalOnly="true"/>
<p:selectManyCheckbox id="abfSelector" value="#{dashboardHandler.selectedAbfragen}" layout="grid" columns="3" styleClass="grid-checkbox">
<f:selectItems value="#{dashboardHandler.abfragen}" var="abfrage" itemLabel="#{abfrage.name}" itemValue="#{abfrage}"/>
</p:selectManyCheckbox>
<p:commandButton id="showButton" value="Anzeigen" icon="pi pi-search" action="#{dashboardHandler.anzeigen}"/>
<div class="card">
<p:lineChart model="#{dashboardHandler.lineModel}" style="width: 100%; height: 500px;"/>
</div>
</h:form>
</ui:define>
</ui:composition>
and the bean looks like this:
@Named("dashboardHandler")
@ViewScoped
public class DashboardHandler implements Serializable {
private List<Abfrage> abfragen = new ArrayList<>();
private Abfrage[] selectedAbfragen;
private LineChartModel lineModel;
@PostConstruct
private void init() {
abfragen = UcmdbAbfTableHandler.getAbfragenBySystem(ReferenceSystem.UCMDB);
createLineModel();
}
public void anzeigen() {
//do some search
}
public List<Abfrage> getAbfragen() { return abfragen; }
public LineChartModel getLineModel() { return lineModel; }
public Abfrage[] getSelectedAbfragen() { return selectedAbfragen; }
public void setAbfragen(List<Abfrage> abfragen) { this.abfragen = abfragen; }
public void setLineModel(LineChartModel lineModel) { this.lineModel = lineModel; }
public void setSelectedAbfragen(Abfrage[] selectedAbfragen) { this.selectedAbfragen = selectedAbfragen; }
}
I can't see my error why there is a type conversion error. I've tried changing the Abfrage-Array to a List then I'm getting a list with Strings of the classname of abfrage like when I make an abfrage.toString().
I also don't understand why my messages isn't triggered. I always get the error in my Logfile with unhandeled facesmessage. So I think I'm doing something wrong here too.