gpt4 book ai didi

ajax - 错误 : contains an unknown id when used with composite:insertChildren

转载 作者:行者123 更新时间:2023-12-04 05:53:21 24 4
gpt4 key购买 nike

我定义了一个复合组件(实际上是几个),当我尝试重新渲染一个插入了 的组件时我收到提到的错误:

<f:ajax> contains an unknown id ':contentFrm' - cannot locate it in the context of the component j_idt40

如果我简单地替换:
<et:pageContent formId="contentFrm">


<h:form id="contentFrm">
<div>

然后一切正常

这是相关的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
<composite:attribute name="styleClass" default="access-box-content alpha omega grid-12" />
<composite:attribute name="formId" default="#{cc.attrs.id}" />
</composite:interface>
<composite:implementation>
<h:form id="#{cc.attrs.formId}">
<div class="#{cc.attrs.styleClass}">
<composite:insertChildren/>
</div>
</h:form>
</composite:implementation>
</html>

这就是我使用复合 Material 的方式
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition id="landing" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:et="http://java.sun.com/jsf/composite/components"
template="/layout/template.xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:define name="main-content">
<et:pageTitle title="#{msg.trx_lastTrx}" />
<et:tabBar formId="currentTrxFrm">
<et:tab bean="#{accountTransactionBacking}"
prompt="#{msg.trx_currentTrxs}"
reRender=":contentFrm"
tabId="1"
active="true"/>
</et:tabBar>
<et:pageContent formId="contentFrm">
<et:tabContentPanel rendered="#{accountTransactionBacking.selectedTab ==1}">
<ui:include src="/app/summary/currentTrxRG.xhtml" rendered="#{accountTransactionBacking.selectedTab ==1}"/>
</et:tabContentPanel>
</et:pageContent>
</ui:define>
</ui:composition>

TIA

更多的测试.. 使用相同的组件得到相同的结果.. 例如,下面的代码给出了类似的错误(甚至用 render=":accountSummaryLines"替换了 render="accountSummaryLines")。
    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition id="landing" xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:et="http://java.sun.com/jsf/composite/components"
template="/layout/template.xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:define name="main-content">
<et:pageTitle title="#{msg.ls_lastStatement}" />

<et:tabBar formId="acctSummTabFrm">
<et:tab/>
</et:tabBar>

<et:pageContent formId="accountButtonsFrm">

....

<et:div styleClass="accountSummaryLines" divId="lastStatementLines">
<ui:repeat var="row" value="#{lastStatementBacking.lines.data}">
<h:outputText escape="false" value="#{row}" styleClass="grid-12 lastStatementDetail"/><br></br>
</ui:repeat>
</et:div>
<et:div styleClass="access-box-footer">
<h:commandButton styleClass="left" action="#{lastStatementBacking.lines.prevPage}" value="#{msg.buttonPrevPage}" style="float:left;">
<f:ajax render="accountSummaryLines" />
</h:commandButton>
<h:commandButton styleClass="right" action="#{lastStatementBacking.lines.nextPage}" value="#{msg.buttonNextPage}">
<f:ajax render="accountSummaryLines" />
</h:commandButton>
</et:div>
</et:pageContent>
</ui:define>
</ui:composition>

我让这个特定示例工作的唯一方法是使用 render="@form"像这样..

最佳答案

无法找到它,因为复合组件本身就是一个 NamingContainer .真正有效的客户端 ID 将是 :idOfComposite:contentFrm哪里idOfComposite是复合组件本身的(自动)生成的 ID。如果您在 webbrowser 中查看源代码并找到 <form>有问题,然后你会看到它。

你需要给复合组件一个固定的ID

<et:pageContent id="contentFrm">

并在包装复合内容的纯 HTML 元素上准确使用此 ID,例如 <div><span> .
<composite:implementation>
<div id="#{cc.id}">
<h:form>
<div class="#{cc.attrs.styleClass}">
<composite:insertChildren/>
</div>
</h:form>
</div>
</composite:implementation>

关于ajax - 错误 : <f:ajax> contains an unknown id when used with composite:insertChildren,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9814510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com