在 JSF1.1 中使用带有 DataTable 的自定义组件时出现重复 ID 错误

发布于 2024-11-05 11:28:40 字数 4555 浏览 4 评论 0原文

当我尝试返回同一页面而不重定向时,出现以下错误。

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component ID '_id20' found in view.
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:527)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component ID '_id20' found in view.
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
    org.apache.jsp.view_005fneed_jsp._jspService(view_005fneed_jsp.java:556)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
root cause

java.lang.IllegalStateException: Duplicate component ID '_id20' found in view.
    com.sun.faces.application.StateManagerImpl.checkIdUniqueness(StateManagerImpl.java:201)
    com.sun.faces.application.StateManagerImpl.checkIdUniqueness(StateManagerImpl.java:204)
    com.sun.faces.application.StateManagerImpl.saveSerializedView(StateManagerImpl.java:97)
    com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:189)
    org.apache.jsp.view_005fneed_jsp._jspx_meth_f_005fview_005f0(view_005fneed_jsp.java:741)
    org.apache.jsp.view_005fneed_jsp._jspService(view_005fneed_jsp.java:546)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

我有一个自定义组件,它仅在 DataTable 内呈现 HTML 以及 ah:form(也在数据表内)。

我的 bean 是请求级别 Bean,JSF 版本是实现版本:1.1_02-b08

[编辑] 我的自定义组件位于数据表内,我认为这造成了问题, 页面中也没有 Ajax 操作。

我的 jsp 看起来像这样..

<h:datatable>
<h:column>
<ch:activity name="#{need.name}" />

</h:column>

其中 CH:activity 是自定义组件

I am getting the following error when i try to return to same page without redirect.

org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component ID '_id20' found in view.
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:527)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:401)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
root cause

javax.servlet.ServletException: javax.servlet.jsp.JspException: java.lang.IllegalStateException: Duplicate component ID '_id20' found in view.
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
    org.apache.jsp.view_005fneed_jsp._jspService(view_005fneed_jsp.java:556)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
root cause

java.lang.IllegalStateException: Duplicate component ID '_id20' found in view.
    com.sun.faces.application.StateManagerImpl.checkIdUniqueness(StateManagerImpl.java:201)
    com.sun.faces.application.StateManagerImpl.checkIdUniqueness(StateManagerImpl.java:204)
    com.sun.faces.application.StateManagerImpl.saveSerializedView(StateManagerImpl.java:97)
    com.sun.faces.taglib.jsf_core.ViewTag.doAfterBody(ViewTag.java:189)
    org.apache.jsp.view_005fneed_jsp._jspx_meth_f_005fview_005f0(view_005fneed_jsp.java:741)
    org.apache.jsp.view_005fneed_jsp._jspService(view_005fneed_jsp.java:546)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:346)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:152)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:137)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:214)
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

I am having a custom component which just renders HTML inside the DataTable along with a h:form(also inside the datatable).

My bean is Request level Bean and the JSF version is Implementation-Version: 1.1_02-b08

[EDIT] My custom component is inside a Datatable I think thats creating the problem,
Also there is no Ajax action in the page.

My jsp looks like this..

<h:datatable>
<h:column>
<ch:activity name="#{need.name}" />

</h:column>

Where CH:activity is a custom component

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空城仅有旧梦在 2024-11-12 11:28:40

这些 _idxx id 已生成,并且您的自定义组件中可能存在一些错误。您通常应该为每个组件提供一个自定义 ID,否则 AJAX 函数可能无法正常工作 - 如果您使用它们。

您能发布您的 JSP/XHTML 吗?
你能检查一下你的渲染器(它是一个自定义的,对吗?)不会渲染相同的 id 两次?

Those _idxx ids are generated and maybe there's some error in your custom component. You should generally give each component a custom id, since otherwise AJAX functions might not work correctly - should you use them.

Could you post your JSP/XHTML?
Can you check that your renderer (its a custom one, right?) doesn't render the same id twice?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文