如何更新具有特定ID的元素

时间:2015-03-04 14:26:05

标签: jsf primefaces composite-component

我想要做的是每次复选(取消)复选框时更新orderList。

我的组件无法访问面部错误。该组件位于formid="form"

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,{{1} },:form:panelGridChoice:orderList

这是我的观点

:form:orderList

<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

1 个答案:

答案 0 :(得分:1)

这可能非常烦人,所以在这种情况下我通常会按照样式类来定位组件。尝试将styleClass="orderList"添加到<p:orderList>,并使用@(.orderList)定位。