How do I pass a parameter value to a Conversion class in java?

后端 未结 2 1116
孤城傲影
孤城傲影 2020-12-17 05:37

I am trying to pass a value to a conversion class in JSF/SEAM

public class ValueConverter implements Converter {

public Object getAsObject(FacesContext arg0         


        
2条回答
  •  死守一世寂寞
    2020-12-17 06:15

    Bhesh is entirely right. You should be doing the validating job inside a Validator.

    As to the concrete problem, move the out of the (or if you're listening to us) into the input component and then use UIComponent#getAttributes() to obtain it. E.g.

    
        
        
    
    

    with

    Object theMaxOrderSize = component.getAttributes().get("theMaxOrderSize");
    // ...
    

    (where component is the UIComponent argument of the validate() method, it represents the parent input component)

    You can cast it to Integer or whatever object type the #{_cartItem.item.maxOrderSize} represents.

提交回复
热议问题