如何在JSF Primefaces中获取完整的元素ID(ID的路径)

时间:2014-06-28 15:02:28

标签: jquery jsf jsf-2 primefaces

我有一个模板文件,包含顶部,左侧,右侧,中间,底部布局部分。在我的一个.xhtml页面中,我包含了我的模板ui:composition template =“template”并定义了我的页面的左侧和中间部分。左侧部分是一个菜单,其中包含2个项目,用于更改页面中心部分的内容。中心部分是一个面板,里面有2个面板,所以当我单击菜单中的一个项目时,它会选择显示其中一个子面板。 Panel有一个id =“panel1”。 Menuitem有action =“#{bean.setpanel(1或2)}”update =“panel1”,但它不起作用,因为它们不在同一个“空格”中。我无法弄清楚如何调用处于中心的panel1,从左侧菜单 - 我怎样才能找出该元素id的完整路径(main:bla:bla:panel1或者像这样的smth)以及我是怎么做的弄清楚如何从不同的“空间”中调用该元素。

1 个答案:

答案 0 :(得分:-1)

检查一下,看看它是否需要..如果您需要有关代码的说明,请询问。

 var path = $(this)
      .parentsUntil('body') //target parent
      .andSelf() //include this element in the following string array
      .map(function() { //build an array out of the results in the provided format
        return this.nodeName + ':eq(' + $(this).index() + ')';
      }).get().join('>'); //put it into string and between each result add '>'