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.

 View Only
Expand all | Collapse all

Generate Dynamic columns based on Webservice output

  • 1.  Generate Dynamic columns based on Webservice output

    Posted Thu November 20, 2008 12:45 PM

    Hi All,

    i am experiencing the following problem.

    Is there any way to increase the table columns dynamically based on the output of webservice. My requirement is that when i change the dropdown value it completes the server side action and refresh the client side( in this case table is client side control ) control then updates the no of columns dynamically after every refresh.

    looking forward for yours quick response.

    [/b]


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


  • 2.  RE: Generate Dynamic columns based on Webservice output

    Posted Thu November 20, 2008 05:41 PM

    In your action, you can lookup the table control, and use the jsf UIComponent apis (every jsf control is an instance of UIComponent; see Oracle Java Technologies | Oracle) to add and remove columns to the table control. Here’s an example:

    public void myAction() {
    // lookup table by its id (“my-table”)
    UIData table = (UIData) findComponentInRoot(“my-table”);
    // get list of table’s children
    List columns = table.getChildren();
    // remove existing columns
    while (!columns.isEmpty())
    columns.remove(0);

    // invoke webservice
    String[] columnHeaders = getMyWebService().getResult().getMyColumnHeaders();
    // add new column control for each column header returned by ws
    for (int i = 0; i < columnHeaders.length; i++) {
    // create new column control and add it to table
    HtmlTableColumn column = new HtmlTableColumn();
    columns.add(column);
    
    // create header text-control and add it to column
    HtmlOutputText header = new HtmlOutputText();
    header.setValue(columnHeaders[i]);
    column.setHeader(header);
    
    // create column-content text-control and add it to column
    HtmlOutputText content = new HtmlOutputText();
    // create value-binding expression
    // this example assumes table's row-variable is "row", and is bound to an array of string-arrays:
    String contentExpression = "#{row[" + i + "]}";
    // if the table was instead bound to an array of typed row objects
    // (and the column's header text was the same as the name of the row property
    // to use to display the column's content), you might use the following expression instead:
    // String contentExpression = "#{row." + columnHeaders[i] + "}";
    ValueBinding contentBinding = getFacesContext().getApplication().createValueBinding(contentExpression);
    content.setValueBinding("value", contentBinding);
    }
    

    }

    Justin


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