我使用的是JSF 2.0的primefaces 2.2.1。我有一个页面与各种标签显示数据,一些列表框和一对命令按钮。无论我做什么,每当我点击这个页面中的命令按钮时,我都会得到以下错误:
java.lang.NullPointerException
at org.primefaces.component.inputmask.InputMaskRenderer.getConvertedValue(InputMaskRenderer.java:115)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIForm.processValidators(UIForm.java:253)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)
at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)
at com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:619)
我不知道为什么。有人知道是什么引起的吗?我还为这个页面使用了实体类和托管bean。这是JSF页面的一部分:每当单击命令按钮时,错误就会发生。
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/ xhtml1/DTD/xhtml1-transitional.dtd">
<html 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.prime.com.tr/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view>
<h:head>
<link rel="stylesheet" type="text/css" href="../resources/css/masterpage.css" />
<link rel="stylesheet" type="text/css" href="../resources/css/requests.css" />
</h:head>
<h:body>
<h:form prependId="false" >
<p:growl id="messages" showDetail="true"/>
<p:panel id="pnlMain" widgetVar="pnlMain" style="width: 100%; font-size: 15px; text-align: left" header="Request Detail">
.
.
.
<table>
<tr>
<td valign="top">
</td>
<td align="right">
<p:commandButton id="btnViewComment" widgetVar="btnViewComment" ajax="false" value="View Selected" />
</td>
<td>
</td>
</tr>
</table>
<p:panel id="pnlSupportingDocs" widgetVar="pnlSupportingDocs" header="Supporting Documents" >
<div>
<table>
<tr>
<td valign="top" >
<h:selectOneListbox id="lstDocs" style="width: 300px; height: 100px" value="#{MyDocuments.doId}" >
<f:selectItems value="#{RequestSearch.selectedRequest.documentCollection}" var="d" itemLabel="#{d.doName}" itemValue="#{d.doId}" />
</h:selectOneListbox>
</td>
<td valign="bottom" >
<table>
<tr>
<td>
<p:commandButton id="btnViewSelected" style="font-size: 8px; width: 150px" widgetVar="btnViewSelected" value="View Selected" />
</td>
</tr>
<tr>
<td>
<p:commandButton id="btnRemoveSelected" style="font-size: 8px; width: 150px" widgetVar="btnRemoveSelected" value="Remove Selected" />
</td>
</tr>
<tr>
<td>
<p:fileUpload id="btnNewDoc" widgetVar="btnNewDoc" update="messages" allowTypes="*.*" description="All Files" fileUploadListener="#{MyDocuments.handleFileUpload}" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</p:panel>
<p:panel id="pnlFinalization" widgetVar="pnlFinalization" header="Final Evaluation" >
<table>
<tr>
<td valign="top" >
<h:outputLabel id="lblComments" style="font-size: 12px" value="Comments:" />
</td>
<td>
<p:inputTextarea id="txtComments" widgetVar="txtComments" style="width: 300px" maxHeight="600" />
</td>
</tr>
</table>
<table>
<tr>
<td>
<h:outputLabel id="lblFinalAdjAmt" style="font-size: 12px" value="Final Adjustment Amt:" />
</td>
<td>
<p:inputMask id="txtFinalAdjAmt" widgetVar="txtFinalAdjAmt" mask="$9999999.99" style="width: 100px; text-align: right" maxlength="15" />
</td>
<td width="100px" >
</td>
<td>
<h:outputLabel id="lblFinalStatus" style="font-size: 12px" value="Final Status:" />
</td>
<td>
<h:selectOneMenu id="cmbStatus" value="#{theStatus.reqStatus}" >
<f:selectItems value="#{theStatus.finalStatus}" />
</h:selectOneMenu>
</td>
<td>
<p:commandButton id="btnSave" widgetVar="btnSave" value="Save" />
</td>
</tr>
</table>
</p:panel>
</p:panel>
<p:dialog header="Print Forms" id="pf" widgetVar="pf" modal="true" width="450" height="300">
<iframe src="../PopUpPages/FormMenu.jsf" width="400" height="250" />
</p:dialog>
<p:dialog header="Comment Detail" id="cd" widgetVar="cd" modal="true" width="450" height="300" >
</p:dialog>
<p:dialog header="Supporting Documents" id="sd" widgetVar="sd" modal="true" width="600" height="800" >
<iframe src="../PopUpPages/SupportingDoc.jsf" width="590" height="650" scrolling="true" />
</p:dialog>
</h:form>
</h:body>
</f:view>
</html>
您的<p:inputMask>
没有value
属性:
<p:inputMask id="txtFinalAdjAmt" widgetVar="txtFinalAdjAmt" mask="$9999999.99" style="width: 100px; text-align: right" maxlength="15" />