首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用特定的ID更新元素

如何用特定的ID更新元素
EN

Stack Overflow用户
提问于 2015-03-04 14:26:04
回答 1查看 4.1K关注 0票数 0

我想要做的是在每次选中复选框(un-)时更新orderList。

由于faces错误,无法访问我的组件。该组件在form中,具有id="form"

代码语言:javascript
复制
14:33:29,614 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-9) Error Rendering View[/pages/view.xhtml]: javax.faces.FacesException: Cannot find component with expression ":form:orderList" referenced from "form:j_idt34:j_idt88:j_idt96:0:j_idt100".

我尝试过几种解决方案,包括::formform:orderListorderListform:panelGridChoice:orderList:panelGridChoice:orderList:form:panelGridChoice:orderList:form:orderList

这是我的观点

代码语言:javascript
复制
<composite:implementation>
    <h:outputStylesheet library="css" name="form.css"  />
    <h:outputScript>
        replaceMedia();
    </h:outputScript>
    <ui:decorate template="answerDecorator.xhtml">
        <ui:define name="additionalForms">
            <h:outputText value="#{cc.attrs.question.additionalExplanation}" styleClass="text-normal" escape="false" />
        </ui:define>
        <ui:define name="component">
        <p:panelGrid id="panelGridChoice" columns="1" cellpadding="0" styleClass="inline" columnClasses="" >
            <p:dataTable var="answer" value="#{cc.attrs.question.possibleAnswers}">
                <p:column headerText="#{msg['survey.question.chooseAnswerList']}" styleClass="thirty-percent">
                    <h:outputText value="#{answer.text}" />
                </p:column>
                <p:column headerText="#{msg['survey.question.chooseAnswer']}" styleClass="ten2-percent" >
                    <p:selectBooleanCheckbox value="#{answer.checked}" >
                        <p:ajax event="change" process="@this" update=":form:orderList" listener="#{cc.attrs.question.setCheckedAnswers}" />
                    </p:selectBooleanCheckbox>
                </p:column>
            </p:dataTable>
            <p:orderList id="orderList" value="#{cc.attrs.question.checkedAnswers2Order}" var="answer" itemLabel="#{answer.text}"
                         converter="entityConverter" itemValue="#{answer}" controlsLocation="left" >
                <f:facet name="caption">#{msg['survey.default.makeOrder']}</f:facet>
            </p:orderList>
        </p:panelGrid>
        </ui:define>
    </ui:decorate>
</composite:implementation>

其中answerDecorator.xhtml被定义为

代码语言:javascript
复制
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:ui="http://java.sun.com/jsf/facelets">
<h:panelGrid columns="1" style="margin-bottom:10px" cellpadding="5" styleClass="borderless survey-panel-max">
    <h:outputText value="#{cc.attrs.question.questionText}" styleClass="text-header"/>
    <h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5" styleClass="borderless top-alignment">
        <ui:insert name="additionalForms" />
    </h:panelGrid>
</h:panelGrid>
<ui:insert name="component" />

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-03-04 14:45:10

这可能真的很烦人,所以在这种情况下,我通常以样式类为目标。尝试将styleClass="orderList"添加到<p:orderList>中,并以@(.orderList)为目标。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28856936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档