[英]component.namingContainer.parent skips h:form
我做了一个复合组件,它的内部是一个<f:ajax>标记,其“ render”属性是cc的参数。
像这样的东西:
...
<cc:attribute name="additionalAjaxRenderIds" type="java.lang.String"></cc:attribute>
...
<h:commandLink value="test" action="#{myBean.someAction}" id="testLink" >
<f:ajax execute="@this" render="#{cc.attrs.additionalAjaxRenderIds} "/>
</h:commandLink>
...
我在表单中使用了该抄送,这已经在外部命名容器中了:
<h:form id="myForm">
...
<mycomp:myComponent id="myCC" additionalAjaxRenderIds=":#{component.namingContainer.parent.clientId}:myPanel" />
<h:panelGroup id="myPanel">
...
</h:panelGroup>
...
</h:form>
问题是,如果我写
additionalAjaxRenderIds=":#{component.namingContainer.clientId}:myPanel"
我收到此错误:
<f:ajax> contains an unknown id ':j_idt44:myForm:myCC:myPanel' - cannot locate it in the context of the component testLink
而如果我使用这个(+ .parent):
additionalAjaxRenderIds=":#{component.namingContainer.parent.clientId}:myPanel"
错误是:
<f:ajax> contains an unknown id ':j_idt44:myPanel' - cannot locate it in the context of the component testLink
而不是预期的ID:
':j_idt44:myForm:myPanel'
所以看来我抄送的命名容器的父级不是表单,而是外部namingcontainer
有什么方法可以:1,获得正确的父级(窗体)2,在将EL作为参数传递之前评估EL(这样我就可以将计算出的clientId传递给我的cc而不是EL表达式,因此该组件不会引用到commandLink标记,但到h:form放在我的CC)
我知道我可以用
additionalAjaxRenderIds=":#{component.namingContainer.parent.clientId}:myForm:myPanel"
但我不喜欢那种解决方案
另外,将表单的prependId属性设置为false会破坏整个组件查找(结果也是ajax标记)
在构建组件时不评估EL表达式,但是在访问属性时不评估EL表达式。 换句话说,它们是运行 时而不是buildtime 。 #{component}
指的是在评估EL表达式时的当前 UI组件,在您的特定情况下为<h:commandLink>
。 这解释了不同的结果。
您需要以不同的方式处理此问题,而不使用#{component}
。
例如
<h:form id="myForm" binding="#{myForm}">
...
<mycomp:myComponent id="myCC" additionalAjaxRenderIds=":#{myForm.clientId}:myPanel" />
<h:panelGroup id="myPanel">
...
</h:panelGroup>
...
</h:form>
要么
<h:form id="myForm">
...
<mycomp:myComponent id="myCC" additionalAjaxRenderIds=":#{myPanel.clientId}" />
<h:panelGroup id="myPanel" binding="#{myPanel}">
...
</h:panelGroup>
...
</h:form>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.