h:dataTable composite component, cc.attrs.var, IllegalArgumentException

后端 未结 1 998
独厮守ぢ
独厮守ぢ 2021-01-14 19:08

I\'m trying to create my own dataTable like the primefaces one. The problem is that cc.attrs.var when used throws a IllegalArgumentException. So I\'m wondering

1条回答
  •  无人及你
    2021-01-14 19:44

    As per the UIData#setValueExpression() javadoc, it's not allowed to have an EL expression in var attribute.

    Throws: IllegalArgumentException - if name is one of id, parent, var, or rowIndex

    Your best bet is to create a backing component wherein you manually evaluate and set the var attribute of the UIData component bound to during the postAddToView event.

    
        
        
    
    
        
    
        
            
        
    
    

    @FacesComponent("yourTableComposite")
    public class YourTableComposite extends UINamingContainer {
    
        private UIData table;
    
        public void init() {
            table.setVar((String) getAttributes().get("var"));
        }
    
        public UIData getTable() {
            return table;
        }
    
        public void setTable(UIData table) {
            this.table = table;
        }
    
    }
    

    Note that I fixed the to be . The can only be used in /.

    See also:

    • Initialize a composite component based on the provided attributes
    • How does the 'binding' attribute work in JSF? When and how should it be used?

    0 讨论(0)
提交回复
热议问题