我使用panelGrid来显示我的结果,但是我有一个问题,我不知道我的类在panelGrid中的实例如何,我的列表有问题,我无法添加元素,我有错误,我认为我需要实例我的班级,但我不知道如何,如何在列表中添加元素?
这是我的代码:
@Component("points")
public class Points extends FormTemplate implements Serializable {
private String taskId;
private TaskInfo currentTask;
private int taskNumber;
Map<String,Object> varsMap;
private ArrayList<RhReunionEntretin> pointsObjects;
private ArrayList<RhReunionEntretin> removedPoints;
private String loggedUser;
@Override
public void init() {
if(varValues.get("points") != null)
pointsObjects= (ArrayList<RhReunionEntretin>)varValues.get("points");
else
pointsObjects = new ArrayList<RhReunionEntretin>();
if(pointsObjects.size() == 0){
List<Long> pointsMultiline = new ArrayList<Long>();
if(varValues.get("form_1475754639065") != null) {
pointsMultiline = (List<Long>) varValues.get("form_1475754639065");
if (pointsMultiline != null && pointsMultiline.size() != 0) {
for (Long pr : pointsMultiline) {
RhReunionEntretin point = (RhReunionEntretin) businessService.getEntitytById("com.imaginepartners.imagineworkflow.models.rh.RhReunionEntretin", pr.toString());
pointsObjects.add(point);
}
}
}
}
removedPoints = new ArrayList<RhReunionEntretin>();
loggedUser = userService.getLoggedInUser().getId();
}
public void addPoint() {
pointsObjects.add(new RhReunionEntretin());
}
.xhtml
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
#{taskController.registerTemplate('points','Points', fn:split('pointsObjects',',') )}
<p:panelGrid style="margin-top:20px" id="compteRTemplate" var="points" value="#{points.pointsObjects}" styleClass="entityList" >
<f:facet name="header">
<p:row>
<p:column >Critères</p:column>
<p:column >Evaluation</p:column>
<p:column >Commentaire</p:column>
</p:row>
</f:facet>
<p:row>
<p:column style="font-weight: bold;">Formation</p:column>
<p:column style="font-weight: bold;">
<p:selectOneRadio id="formation"
value="#{points.pointsObjects.formation}">
<p:ajax event="blur"/>
<f:selectItem itemLabel="A" itemValue="A" />
<f:selectItem itemLabel="B" itemValue="B" />
<f:selectItem itemLabel="C" itemValue="C" />
<f:selectItem itemLabel="NA" itemValue="NA" />
</p:selectOneRadio></p:column>
<p:column style="font-weight: bold;">
<p:inputText
value="#{points.pointsObjects.commentaireForm}">
</p:inputText>
</p:column>
</p:row>
我提交时收到此错误
oct. 25, 2018 10:50:52 AM com.sun.faces.lifecycle.ProcessValidationsPhase execute
AVERTISSEMENT: For input string: "formation"
java.lang.NumberFormatException: For input string: "formation"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.parseInt(Integer.java:615)
at javax.el.ListELResolver.coerce(ListELResolver.java:163)
at javax.el.ListELResolver.getType(ListELResolver.java:71)
at com.sun.faces.el.DemuxCompositeELResolver._getType(DemuxCompositeELResolver.java:215)
at com.sun.faces.el.DemuxCompositeELResolver.getType(DemuxCompositeELResolver.java:242)
at org.apache.el.parser.AstValue.getType(AstValue.java:84)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:171)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at com.sun.faces.renderkit.html_basic.MenuRenderer.convertSelectOneValu