NumberFormatException:对于输入字符串:在dataTable多次选择之后

时间:2014-07-30 18:46:08

标签: jsf primefaces datatable

我正在使用Primefaces 5应用程序并将我的一些dataTable视图从单个选择更改为多个选择...每当我尝试修改行的内容时,我都会收到此错误:

Jul 30, 2014 9:36:38 PM com.sun.faces.lifecycle.ProcessValidationsPhase execute
WARNING: For input string: "get"
java.lang.NumberFormatException: For input string: "get"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at javax.el.ListELResolver.coerce(ListELResolver.java:174)
at javax.el.ListELResolver.getValue(ListELResolver.java:52)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at org.apache.el.parser.AstValue.getTarget(AstValue.java:121)
at org.apache.el.parser.AstValue.getType(AstValue.java:82)
at org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:176)
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:98)
at org.primefaces.util.ComponentUtils.getConverter(ComponentUtils.java:126)
at org.primefaces.renderkit.InputRenderer.getConvertedValue(InputRenderer.java:171)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1034)
at javax.faces.component.UIInput.validate(UIInput.java:964)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1237)
at javax.faces.component.UIInput.processValidators(UIInput.java:702)

它真的开始打扰我了,因为我无法弄清楚错误是什么......

这是dataTable标题:

<p:dataTable id="ordDataTable" var="r" rowIndexVar="rowIndex"
value="#{ordController.lazyModel}" rows="10"
widgetVar="dtWidgetVar" paginator="true"
paginatorTemplate="
                   {CurrentPageReport} {FirstPageLink} {PreviousPageLink} 
                   {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="10,15,50,100,500,1000"
filteredValue="#{ordController.filteredList}"
selection="#{ordController.selectionList}"
filterMap="#{ordersFilterBackingBean.filterMap}"
selectionMode="multiple" lazy="true" sortOrder="ascending"
resizableColumns="true" tableStyle="width:auto">

这是我进行更改的地方:

            <!-- Dialog for updating an EXISTING Order -->
        <p:dialog header="#{msgs.CRUD_dlgModify}" widgetVar="CRUD_updateDlg"
            resizable="false" id="CRUD_update">
            <p:outputPanel id="updatePanel">
                <h:form id="updateOrd">
                    <p:panelGrid columns="2">
                        <p:panelGrid columns="2">
                        #{msgs.Column_order_id}
                        <p:inputText
                                value="#{ordController.selectionList.get(0).order_id}" disabled="true" />
                        #{msgs.Column_inherited_id}
                        <p:inputText
                                value="#{ordController.selectionList.get(0).inherited_id}" />

                        #{msgs.Column_start_time}*
                        <p:calendar
                                value="#{ordController.selectionList.get(0).start_time}"
                                pattern="MM/dd/yyyy HH:mm" />

                        #{msgs.Column_priority}*
                         <h:selectOneMenu
                                value="#{ordController.selectionList.get(0).priority}">
                                <f:selectItems value="#{ordController.priorityList}" var="v"
                                    itemLabel="#{v.t2}" itemValue="#{v.t1}" />
                            </h:selectOneMenu>

                        #{msgs.Column_agent}*
                            <h:selectOneMenu
                                value="#{ordController.selectionList.get(0).agent}">
                                <f:selectItems value="#{ordController.agentList}" var="v"
                                    itemLabel="#{v.t2}" itemValue="#{v.t1}" />
                            </h:selectOneMenu>
                        #{msgs.Column_observations}
                        <p:inputText
                                value="#{ordController.selectionList.get(0).observations}" />
                        </p:panelGrid>

                        <p:panelGrid columns="2">
                            #{msgs.Column_order_id_ext}
                            <p:inputText
                                value="#{ordController.selectionList.get(0).order_id_ext}" />

                            #{msgs.Column_order_no}*
                            <p:inputText
                                value="#{ordController.selectionList.get(0).order_no}" />

                            #{msgs.Column_stop_time}*
                            <p:calendar
                                value="#{ordController.selectionList.get(0).stop_time}"
                                pattern="MM/dd/yyyy HH:mm" />

                             #{msgs.Column_client_id}*
                               <h:selectOneMenu
                                value="#{ordController.selectionList.get(0).client_id}">
                                <f:selectItems value="#{ordController.clientIDList}" var="v"
                                    itemLabel="#{v.t2}" itemValue="#{v.t1}" />
                            </h:selectOneMenu>                               
                             #{msgs.Column_truck_plate}
                             <p:inputText
                                value="#{ordController.selectionList.get(0).truck_plate}" />
                        </p:panelGrid>

                    </p:panelGrid>
                    <p:commandButton value="#{msgs.CRUD_btnSubmit}"
                        actionListener="#{ordController.updateOrd}"
                        oncomplete="PF('CRUD_updateDlg').hide()"
                        update=":form:ordDataTable :form:messages" />
                </h:form>
            </p:outputPanel>
        </p:dialog>
不认为这是相关的,但有人可能会问......

  public void updateOrd() {
if (selectionList.size() == 0 || selectionList.size() > 1) {
  FacesUtils.addErrorMessage(ResourceBundleUtils.getMessage(IBundleMsgs.NO_ROW_SELECTED));
} else {
  Orders order = selectionList.get(0);
  Map<String, Object> paramMap = new HashMap<String, Object>();
  selectionList.get(0).setStart_time_char(DateUtils.DateToString(selectionList.get(0).getStart_time()));
  selectionList.get(0).setStop_time_char(DateUtils.DateToString(selectionList.get(0).getStop_time()));
  paramMap.put("p_order_id", order.getOrder_id());
  ...params....
  SQLResult result = ordServ.updateOrders(paramMap);
  if (result.isOk()) {
    FacesUtils.addMessage(result.getResultMessage());
  } else {
    FacesUtils.addErrorMessage(result.getResultMessage());
  }
}

}

1 个答案:

答案 0 :(得分:1)

在表达式语言中,使用

完成索引的索引
listName[i]

而不是普通的java语法

listName.get(i)

第一个元素仍然是索引0。