我有以下JSF代码(为了理智而剥离):
<!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:support中的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[source=com.sun.faces.lifecycle.LifecycleImpl@6d34f3c8]
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:support时,不再抛出异常,但当然密码字段没有更新...我也尝试删除ajaxSingle属性,这也导致异常不再被抛出,但是同样,密码字段不会相应地重新生成。我试过重新渲染整个表单,dataTable,panelGrids等无济于事。我甚至试图将inputSecret包装在a4j:outputPanel中以找不到差异。
我一直在打扰自己几天,到目前为止,我发现NumberFormatException和强大的Google上的reRender尝试之间没有关联(我发现在reRender期间抛出异常的例子,但是该错误与rowIndex无关)。任何建议都会受到高度赞赏,因为我的死线越来越近了,我不知所措。如果这对我来说是愚蠢的,请务必告诉我。
答案 0 :(得分:0)
我终于想出了这个问题。答案是包装&lt; h:inputSecret /&gt;在
<a4j:outputPanel layout="none" ajaxRendered="false"> </a4j:outputPanel>
然后设置ajaxSingle =&#34; false&#34;在&lt; a4j:support /&gt;
中花了一段时间来弄明白,但最后,最后看了一下RichFaces文档,找到了答案。