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

后端 未结 2 1118
孤城傲影
孤城傲影 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

    That's something you should be doing with Validator. Converter is just to convert from String to Object and Object to String. You are trying to validate in a Converter.

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

    That's not correct, you don't need to pass a parameter to a Converter. it should be -

    How do I access a parameter in a Converter in JSF?

    You can use FacesContext -

    context.getExternalContext().getRequestParameterMap();
    

    I think you got a whole lot of readings to do. Best of luck!

    If you want to add attributes to your converter, then use StateHolder -

    public class ValueConverter implements Converter, StateHolder {
    

提交回复
热议问题