简体   繁体   English

如何在EL中获取当前组件的id

[英]How to get id of current component in EL

I'm working with JSF and PrimeFaces, but I need to get the value of the id of a component. 我正在使用JSF和PrimeFaces,但我需要获取组件id的值。 Because I'm building dinamycally panels with diferent id, to show a the panel I need to compare if is the current panel, then show it. 因为我正在构建具有不同id的dinamycally面板,以显示我需要比较的面板,如果是当前面板,则显示它。

For example if I've the next panel 例如,如果我有下一个面板

<p:outputPanel id="#{bean.getID}" autoUpdate="true"
   renderer=#{@this.id == bean.currentPanel}
>
</p:outputPanel>

And Bean 和豆

public class Bean(){
  private int numberPanels =0;
  private int currentPanel = 0;

  public int getID(){
     //...a process that return different ID
  }
  // getter's and setters

} }

Obviously, @this.id doesn't work. 显然, @this.id不起作用。 So, how to get the value of ID of componente ne JSF with PrimeFaces? 那么,如何使用PrimeFaces获取componente ne JSF的ID值?

There is an implicit #{component} object in the EL scope that evaluates to the current UI component. EL范围中有一个隐式的#{component}对象,它评估当前的UI组件。 Given this information, you'll get the following attribute: 根据此信息,您将获得以下属性:

rendered="#{component.id eq bean.currentPanel}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM