我有以下的JSF代碼(剝離下來理智的緣故):A4J:支持重新解析導致NumberFormatException異常被拋出
<!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:s="http://jboss.com/products/seam/taglib"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
template="layout/template.xhtml">
<ui:define name="body">
<h1>#{messages['l.userConfig']}</h1>
<h:panelGrid styleClass="tblCenter">
<h:dataTable
rowClasses="#{principalHome.editOrNewMode?'rowClear':'rowClear,rowShaded'}"
styleClass="dataTable"
var="row"
value="#{principalHome.editOrNewMode ? principalHome.editList : principalList.users}"
columnClasses="allCols">
<h:column>
<f:facet name="header">
<h:outputText value="#{messages['l.principalsTable.userNameCol']}"/>
</f:facet>
<f:facet name="footer">
<s:decorate template="Edit.xhtml">
<h:panelGrid columns="2">
<h:outputText value="#{messages['l.principalsTable.userNameCol']}"/>
<h:inputText
required="true"
validator="#{principalHome.validateUniqueName}"
value="#{principalHome.instance.username}"
autocomplete="off" />
<h:outputText value="#{messages['l.principalsTable.passwordCol']}"/>
<h:inputSecret
id="password"
required="#{principalHome.instance.ldapStr == 'false'}"
redisplay="true"
value="#{principalHome.instance.password}"
disabled="#{principalHome.instance.ldapStr == 'true'}"
autocomplete="off" />
</h:panelGrid>
</s:decorate>
</f:facet>
<s:decorate template="View.xhtml">
#{row.username}
</s:decorate>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="#{messages['l.principalsTable.ldapUserCol']}"/>
</f:facet>
<f:facet name="footer">
<s:decorate template="Edit.xhtml">
<h:selectBooleanCheckbox id="ldapUser" value="#{principalHome.instance.ldapUser}">
<a4j:support event="onclick" ajaxSingle="true" reRender="password" />
</h:selectBooleanCheckbox>
</s:decorate>
</f:facet>
<s:decorate template="View.xhtml">
<h:panelGroup columns="1" id="enabledPanel">
<h:graphicImage id="enabled" title="LDAP User" url="/img/check-16.png" rendered="#{row.ldapStr=='true'}" />
</h:panelGroup>
</s:decorate>
</h:column>
</h:dataTable>
<ui:include src="common/TableNavigation.xhtml"/>
<h:panelGrid columns="2">
<h:outputText value="#{messages['t.permissions.hint']}"/>
<s:button
rendered="#{!principalHome.editOrNewMode and !s:hasRole('read-only')}"
style="float:right;"
action="#{principalHome.createEntity}"
value="#{messages['l.gbl.addButton']}"
styleClass="submit">
</s:button>
</h:panelGrid>
<h:outputText value="#{messages['t.permissions.hint2']}" rendered="#{!s:hasRole('all-site-admin') and principalHome.editOrNewMode}"/>
</h:panelGrid>
</ui:define>
</ui:composition>
的目標是,當點擊selectBooleanCheckbox時,密碼字段將啓用/禁用|相應地需要/不需要。當A4J onclick事件:支持火災,我會見了以下異常:
5:34:39,668 WARNING [lifecycle] java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'tform:j_id219:j_id242:j_id244:ldapUser' For input string: "j_id242"
javax.faces.FacesException: java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'tform:j_id219:j_id242:j_id244:ldapUser' For input string: "j_id242"
at javax.faces.component.UIData.invokeOnComponent(UIData.java:878)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:239)
at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:412)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:530)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.shockwatch.servlet.IE9CompatablityFixServlet.doFilter(IE9CompatablityFixServlet.java:14)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'tform:j_id219:j_id242:j_id244:ldapUser' For input string: "j_id242"
at javax.faces.component.UIData.invokeOnComponent(UIData.java:861)
... 59 more
15:34:39,669 SEVERE [lifecycle] JSF1054: (Phase ID: APPLY_REQUEST_VALUES 2, View ID: /PrincipalEdit.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[[email protected]]
15:34:39,708 ERROR [Exceptions] handled and logged exception
javax.servlet.ServletException: java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'tform:j_id219:j_id242:j_id244:ldapUser' For input string: "j_id242"
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:530)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.shockwatch.servlet.IE9CompatablityFixServlet.doFilter(IE9CompatablityFixServlet.java:14)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.FacesException: java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'tform:j_id219:j_id242:j_id244:ldapUser' For input string: "j_id242"
at javax.faces.component.UIData.invokeOnComponent(UIData.java:878)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
at javax.faces.component.UIComponent.invokeOnComponent(UIComponent.java:720)
at javax.faces.component.UIComponentBase.invokeOnComponent(UIComponentBase.java:675)
at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:239)
at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:412)
at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
... 47 more
Caused by: java.lang.NumberFormatException: Trying to extract rowIndex from clientId 'tform:j_id219:j_id242:j_id244:ldapUser' For input string: "j_id242"
at javax.faces.component.UIData.invokeOnComponent(UIData.java:861)
... 59 more
當我刪除了A4J:支持,異常不再拋出,當然密碼字段不更新...我也嘗試刪除ajaxSingle屬性,這也導致異常不再被拋出,但是,再次,密碼字段不會相應reRendered。我試圖重新渲染整個窗體,dataTable,panelGrids等無濟於事。我甚至試圖將inputSecret包裝在a4j:outputPanel中以查找沒有區別。
我一直在毆打自己了好幾天,到目前爲止,我發現NumberFormatException和強大的Google上的reRender嘗試之間沒有關聯(我發現在reRender中拋出異常的例子,但錯誤與rowIndex無關)。任何建議將不勝感激,因爲我的死線越來越吱吱作響,而且我不知所措。如果這對我來說太愚蠢了,一定要讓我知道。
嘗試將id =標記添加到您的控件,以便更容易找出j_id242是什麼。同時發佈你的java代碼可能會有所幫助,ldapUser和ldapStr是什麼類型? – arved 2012-02-21 11:42:29
我還沒有找到j_id組件所屬的組件。我在inputSecret周圍的所有內容中都添加了id屬性,但沒有找到它。 ldapUser是一個布爾值,ldapStr是一個字符串。 – 2012-02-21 19:17:27