IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only
Expand all | Collapse all

Using Enum property for Dropdown or RadioButton Group

  • 1.  Using Enum property for Dropdown or RadioButton Group

    Posted 01/06/11 08:47 AM

    Hello,

    I am trying to achieve the following:

    1. populate a single-select dropdown or a radio button group with all possible values of an Enum.
    2. Bind the value of the component to a Java bean proptery of type Enum.

    This code is used to populate the dropdown:

    public List<SelectItem> getQuotationTypeItems() {
    QuotationTypeEnum[] values = QuotationTypeEnum.values();
    List<SelectItem> list = new ArrayList<SelectItem>(values.length);
    for (QuotationTypeEnum value : values) {            
    list.add(new SelectItem(value.name(), value.getDisplayValue()));            
    }
    
    return list;
    }

    The getters and setters of the property the component is bound to are as follows:

    public QuotationTypeEnum getQuoteType() {
    return this.quoteType;
    }
    
    public void setQuoteType(QuotationTypeEnum quoteType) {
    this.quoteType = quoteType;
    }

    where QuotationTypeEnum is a java enum.

    The dropdown is populated correctly but the selected value is not bound. I receive the error message: {0}: Validation Error: Value is not valid

    Is CAF not supporting converting enums - that would be strange because JSF supports enum conversion out of the box.

    Any help is appreciated.

    Regards,
    Mathias


    #webMethods-BPMS
    #webMethods
    #MWS-CAF-Task-Engine


  • 2.  RE: Using Enum property for Dropdown or RadioButton Group

    Posted 01/06/11 11:46 AM

    Hi Mathias,
    Since you are mapping the value of the dropdown/radio-button-group to a QuotationTypeEnum you need a small correction in your list of options:

    public List getQuotationTypeItems() {
    QuotationTypeEnum[] values = QuotationTypeEnum.values();
    List list = new ArrayList(values.length);
    for (QuotationTypeEnum value : values) {
    list.add(new SelectItem(value, value.getDisplayValue()));
    }
    return list;
    }

    Otherwise, the list of options would contain a String as value, not a QuotationTypeItem.
    Hope this helps,
    Javier


    #MWS-CAF-Task-Engine
    #webMethods
    #webMethods-BPMS