0

我一次又一次地收到同样的异常。比较没有for="#{choiceRadio.clientId}"的异常和 hmtl-output似乎告诉我绑定有效。但事实并非如此,我觉得我错过了一些巨大的东西。

编码:

    <p:selectOneRadio binding="#{choiceRadio}" value="#" layout="custom">
        <f:selectItems value="#" />
    </p:selectOneRadio>

    <h:panelGrid columns="1">
        <ui:repeat var='choice' value='#{item.items3}'>
            <p:radioButton for="#{choiceRadio.clientId}" />#{choice.name}
        </ui:repeat>
    </h:panelGrid>

</h:form>

例外:

HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Cannot find component 'j_idt34:0:j_idt36:2:j_idt46:j_idt82' in view.
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:606)
    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
root cause

javax.faces.FacesException: Cannot find component 'j_idt34:0:j_idt36:2:j_idt46:j_idt82' in view.
    org.primefaces.component.radiobutton.RadioButtonRenderer.findSelectOneRadio(RadioButtonRenderer.java:126)
    org.primefaces.component.radiobutton.RadioButtonRenderer.encodeEnd(RadioButtonRenderer.java:35)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
    com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:523)
    com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:984)
    com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
    com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    org.primefaces.component.lightbox.LightBoxRenderer.encodeMarkup(LightBoxRenderer.java:52)
    org.primefaces.component.lightbox.LightBoxRenderer.encodeEnd(LightBoxRenderer.java:32)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:59)
    org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
    org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:46)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
    com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:523)
    com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:984)
    com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:304)
    com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105)
    javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
    org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55)
    org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
    org.primefaces.component.outputpanel.OutputPanelRenderer.encodeEnd(OutputPanelRenderer.java:46)
    javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1786)
    com.sun.faces.facelets.component.RepeatRenderer.encodeChildren(RepeatRenderer.java:104)
    com.sun.faces.facelets.component.UIRepeat.process(UIRepeat.java:523)
    com.sun.faces.facelets.component.UIRepeat.encodeChildren(UIRepeat.java:984)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    javax.faces.component.UIComponent.encodeAll(UIComponent.java:1782)
    com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402)
    com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
    javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
note The full stack trace of the root cause is available in the JBoss Web/7.0.13.Final logs.

JBoss Web/7.0.13.Final

没有 ui:repeat 我没有任何异常,但没有 ui:repeat 我也没有任何内容:

    <p:selectOneRadio  id="myRadio" value="#{cartBean.selectedChoice}" layout="custom">
        <f:selectItems value="#{item.items3}" />
    </p:selectOneRadio>

    <h:panelGrid columns="1">

            <p:radioButton for="myRadio" value="hh" itemIndex="0"/>

    </h:panelGrid>

</h:form>
4

1 回答 1

2

for属性radioButton必须是idselectOneRadio所指的。

添加id到您的selectOneRadio并在按钮中引用它:

<p:selectOneRadio id="myRadio" binding="#{choiceRadio}" value="#" layout="custom">
    <f:selectItems value="#" />
</p:selectOneRadio>

<h:panelGrid columns="1">
    <ui:repeat var='choice' value='#{item.items3}'>
        <p:radioButton for="myRadio" />#{choice.name}
    </ui:repeat>
</h:panelGrid>

编辑

您可能需要在 element 之前添加所有NamingContainers的 id ,例如:。ViewRootidfor="form_id:myRadio"

如果不确定元素的确切绝对值id是什么,请在 FireBug (Firefox) 或开发人员工具 (Chrome) 中查看它,或id在 html 输出源中搜索给定的(在本例中为“myRadio”)并跳过可能的数字-之间。

所以这

id="iterateCategories:0:iterateItems:2:lightForm:radioForm"

会成为

iterateCategories:iterateItems:lightForm:radioForm

作为你的绝对身份。

于 2012-10-23T10:38:00.573 回答