我无法访问我的模型在dynaForm primefaces中的attributs

时间:2016-03-04 15:29:22

标签: jsf primefaces primefaces-extensions

我的问题是我无法访问dynaForm中我的模型的attributs。 (我正在使用spring jsf primfaces。)

https://stackoverflow.com/a/12863019/5046362

谢谢你的帮助。

这是我的代码

public class Colonne {
    private String nomColonne;
    private String typeColonne;
    private int index;

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Colonne() {
        super();
    }

    public Colonne(String nomColonne, String typeColonne, int i) {
        super();
        this.nomColonne = nomColonne;
        this.typeColonne = typeColonne;
        this.index=i;
    }

    public String getNomColonne() {
        return nomColonne;
    }

    public void setNomColonne(String nomColonne) {
        this.nomColonne = nomColonne;
    }

    public String getTypeColonne() {
        return typeColonne;
    }

    public void setTypeColonne(String typeColonne) {
        this.typeColonne = typeColonne;
    }
}

这是我的managedBean

public class MonBean implements Serializable{
    private static final long serialVersionUID = -5773011533863117274L;
    private GestionTableImpl gestionTable;
    private Table table;
    private  DynaFormModel model;

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    public  DynaFormModel initialize() { 
        System.out.println("1");
        model = new DynaFormModel();  

        Colonne col = new Colonne("a","b",0 );  
        DynaFormRow row = model.createRegularRow();  
        row.addControl(col, "columnName");
        row.addControl(col, "columnType"); 
        row.addControl(col, "add");  


        col = new Colonne("c","d",1 );  
        row = model.createRegularRow();    
        row.addControl(col, "columnName");
        row.addControl(col, "columnType"); 
        row.addControl(col, "add");  


        col = new Colonne("e","f", 2);  
        row = model.createRegularRow();  
        row.addControl(col, "columnName");
        row.addControl(col, "columnType"); 
        row.addControl(col, "add");  

        return model;
    }  



    public DynaFormModel getModel() {  
        return model;  
    }  

    public void setModel(DynaFormModel model) {
        this.model = model;
    }

    public Table getTable() {
        return table;
    }

    public void setTable(Table table) {
        this.table = table;
    }

}

1 个答案:

答案 0 :(得分:0)

您要将#{monBean.initialize()}分配给dynaForm值属性,请改用#{monbean.model}

此外,您必须更改initialize类的MonBean方法才能返回void,并使用@PostConstruct注释此方法。

这样在执行时它不会失败,你的IDE也不会抱怨它。