如何访问Composite的父命名容器? [英] How to access the parent Naming Container of Composite?

查看:131
本文介绍了如何访问Composite的父命名容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP 2.0 <ui:component>,其中有一个<p:dataTable>,其中的一列使用Composite来呈现某些内容的特殊边框.现在,我需要在位于内容中的ajax呈现的属性中标识<p:dataTabe>.

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. Now I need to identify the <p:dataTabe> in a ajax rendered attribute that is located in the content.

<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>

我的BorderBox:

My 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

但是component.namingContainer.parent接缝为空.

当我用以下语句替换<p:commandButton>时:

When I replace the <p:commandButton> with this statements:

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}

我得到以下输出:

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: 

我不知道这是什么问题:请问我确定列表的想法完全错误,还是有一些错误,或者有更好的方法? (但是我不能为dateTable使用固定的绝对标识符!)

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? (But I can not use fix absolute identifyer for the dateTable!)

版本:Glassfish 3.1.2上的Primeface 3.2,Mojarra 2.1.6

推荐答案

我有解决此问题的方法.如果找不到其他解决方案,则可以使用它作为替代方案.解决方案是jsf和javascript之间的混合体.为您的表定义一个小部件(例如"myTable").

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. For your table you define a widget (e.g. "myTable").

<p:dataTable id="dataTable" var="userItem" ...  widgetVar="myTable"/>

这是一个名为"myTable"的全局javascript变量.此小部件对象包含一个ID.为您的命令按钮(h:commandButton而非p:commandButton)定义onklick事件:

It is a global javascript variable named "myTable" is created. this widget object contains an id. For you command button (h:commandButton not p:commandButton) you define onklick event:

<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-您显式输入表单ID或使用我的Jquery函数
更新-myTable.id是一个表ID(恰好是div包装器)
流程-@ all,@ this,@ form等.


formId - you enter the form ID explicitly or use my Jquery function
update - myTable.id is a Table ID (exactly div wrapper)
process - @all, @this, @form etc..

这篇关于如何访问Composite的父命名容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆