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

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

问题描述

我有一个 JSP 2.0 ,其中有一个 ,其中有一列使用 Composite 来呈现特殊的关于某些内容的边界.现在我需要在位于内容中的 ajax 渲染属性中识别 .

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>

我的边框:

<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 接缝为 null.

But component.namingContainer.parent seams to be null.

当我用这个语句替换 时:

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天全站免登陆