无法从支持Bean获取自定义组件属性

用户1201957

我有以下自定义PrimeFaces面板

在页面中

<x:myPanel panelName="TEST123" />

和班级

    @FacesComponent(namespace="test",tagName="myPanel", createTag=true)
    public class MyPanel extends Panel {

    public MyPanel() {
           panelName = (String)getAttributes().get("panelName");
    }
}

为什么从类本身获取属性时不起作用

getAttributes().get("panelName");  >> it returns null

我什至还尝试使用以下内容,该类还返回null:

<f:attribute name="panelName" value="TEST123"/>

提前致谢

BalusC

基本上,JSF在幕后创建组件并按如下所示设置属性:

MyPanel myPanel = new MyPanel();
myPanel.getAttributes().put("panelName", "TEST123");

它应该表明,在构造组件属性之前不可能设置它。但是,您正在尝试在构造函数中访问它!

您应该以实际需要它的标准UIComponent方法之一来访问它。例如,大约encodeBegin()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章