我需要访问组件标签属性,例如:
<h:inputtext id="input_age"/>
来自支持 bean,例如:
public class UserInfo {
String inputAgeId;
public UserInfo() {
inputAgeId = { /*code to access component tag attribute*/ }.getStyleClass();
}
}
UIViewRoot view = FacesContext.getCurrentInstance().getViewRoot();
然后你可以使用view.find("component_id") http://docs.oracle.com/javaee/6/api/javax/faces/component/UIComponent.html#findComponent%28java.lang.String%29以获得正确的组件。拥有该组件后,您可以使用获取属性() http://docs.oracle.com/javaee/6/api/javax/faces/component/UIComponent.html#getAttributes%28%29得到一个Map<String, Object>
具有组件的所有属性。
如果您始终访问相同的内容,您可以将其绑定到支持 bean https://stackoverflow.com/q/4532955/1073063反而。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)