[英]How to access the parent Naming Container of Composite?
I have a JSP 2.0 <ui:component>
, within that is a <p:dataTable>
with a column that uses a Composite to render a special border about some content. 我有一个JSP 2.0 <ui:component>
,其中有一个<p:dataTable>
,其列使用Composite来呈现关于某些内容的特殊边框。 Now I need to identify the <p:dataTabe>
in a ajax rendered attribute that is located in the content. 现在我需要在位于内容中的ajax呈现属性中标识<p:dataTabe>
。
<ui:component>
<p:dataTable id="dataTable" var="userItem" ... />
<p:column>
<my:borderBox id="borderBox">
<p:commandButton
action="#{userController.doDelete(userItem.id)}"
value="delete"
update="?????"/> <!-- How to address the dateTable? -->
</my:borderBox>
</p:column>
</p:dataTable>
<ui:component>
My BorderBox: 我的BorderBox:
<html xmlns:composite="http://java.sun.com/jsf/composite" ...>
<composite:interface>
<composite:attribute name="styleClass" default="" type="java.lang.String"/>
</composite:interface>
<composite:implementation>
<h:panelGroup ...>
...
<composite:insertChildren/>
</h:panelGroup>
</composite:implementation>
My idea was to use something like 我的想法是使用类似的东西
update=":#{component.namingContainer.parent.namingContainer.clientId}:dateTable
But component.namingContainer.parent
seams to be null. 但是component.namingContainer.parent
接缝为null。
When I replace the <p:commandButton>
with this statements: 当我用这些语句替换<p:commandButton>
时:
Parent ClientId 1: #{component}
Parent ClientId 2: #{component.namingContainer}
Parent ClientId 3: #{component.namingContainer.clientId}
Parent ClientId 4: #{component.namingContainer.parent}
Parent ClientId 5: #{component.namingContainer.parent.namingContainer}
I get this output: 我得到这个输出:
Parent ClientId 1: javax.faces.component.html.HtmlPanelGroup@3d957419
Parent ClientId 2: javax.faces.component.UINamingContainer@23db9e8f
Parent ClientId 3: main_form:profilTabView:dataTable:0:borderBox
Parent ClientId 4:
Parent ClientId 5:
I have no idea what the problem it: mybey my idea to identify the list is complete wrong or there some mistake or there is a better way? 我不知道它有什么问题:mybey我的想法是确定列表是完全错误还是有些错误或有更好的方法? (But I can not use fix absolute identifyer for the dateTable!) (但我不能使用修复绝对标识符作为dateTable!)
Versions: Primeface 3.2, Mojarra 2.1.6 on Glassfish 3.1.2 版本:Primeface 3.2,Glassfish 3.1.2上的Mojarra 2.1.6
I have a workaround for this Problem. 我有一个解决这个问题的方法。 If you can not find another solution, you can use it as an alternative. 如果找不到其他解决方案,可以将其作为替代方案。 The Solution is a mix between jsf and javascript. 解决方案是jsf和javascript之间的混合。 For your table you define a widget (eg "myTable"). 对于您的表,您可以定义一个小部件(例如“myTable”)。
<p:dataTable id="dataTable" var="userItem" ... widgetVar="myTable"/>
It is a global javascript variable named "myTable" is created. 它是一个名为“myTable”的全局javascript变量。 this widget object contains an id. 此小部件对象包含一个id。 For you command button (h:commandButton not p:commandButton) you define onklick event: 对于命令按钮(h:commandButton not p:commandButton),您可以定义onklick事件:
<h:commandButton id="deleteItem" action="#{userController.doDelete(userItem.id)}"
value="delete" onclick="PrimeFaces.ab({formId:$(this).closest('form').attr('id'),source:this.id,process:'@all',update:myTable.id});return false;" />
formId - you enter the form ID explicitly or use my Jquery function formId - 您明确输入表单ID或使用我的Jquery函数
update - myTable.id is a Table ID (exactly div wrapper) 更新 - myTable.id是一个表ID(正好是div包装器)
process - @all, @this, @form etc.. 过程 - @all,@ this,@ form等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.