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.


#TechXchangePresenter
 View Only
  • 1.  Setting "control params" dynamically for an applet

    Posted Mon December 27, 2010 07:48 PM

    In our view we have an applet control. We need to set some “control params” for the applet dynamically when the view loads. How to achieve this?

    Vikas.


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


  • 2.  RE: Setting "control params" dynamically for an applet

    Posted Tue December 28, 2010 06:21 PM

    You can add as many Control Parameters (as children) to the Applet Control that you like. The names and values of the Control Params can be bound to your needs.

    Regards,
    –mark


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


  • 3.  RE: Setting "control params" dynamically for an applet

    Posted Tue December 28, 2010 08:21 PM

    Mark, I am able to do so “manually” in my applet properties in the designer. For example, I can set control parameter name1 with a value of “ZZZ”. But our requirement is to “dynamically” set them, when the page view is initialized.

    For example, we query a database table for employees. Depending on the results, I will have control parameters like name1=“ABC”, name2=“DEF” and this could go on (depending on the query result).

    Any idea?


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


  • 4.  RE: Setting "control params" dynamically for an applet

    Posted Wed December 29, 2010 06:25 PM

    Ok. The basic approach is that prior to the page being rendered you’ll create instances of the UIParameter, configure them and add them to the jsf component tree as children of your applet.

    The easiest way to add a child to the applet (or any component) to create a control accessor for your applet. Right click on your applet in the canvas, and select Create Control Accessor. This will create a java method like:

    	/**
    * Getter method for the control with id='defaultForm:applet'
    */
    public com.webmethods.caf.faces.component.output.Applet getApplet()  {
    return (com.webmethods.caf.faces.component.output.Applet)findComponentInRoot("defaultForm:applet");
    }

    Then, override the beforeRenderResponse() and do the following:

    • Get a reference to the applet component (see above)
    • Clear out any previous children of the applet
    • Fetch your dynamic params (custom business logic)
    • For each dyanmic param, create a UIParam and add it to the child list of the applet

    as in the following:

    	@Override
    protected void beforeRenderResponse() {
    super.beforeRenderResponse();
    
    //clear old children from previous request
    Applet applet = getApplet();
    List<UIComponent> children = applet.getChildren();
    children.clear();
    
    //get params from somewhere
    UIParameter p1 = new UIParameter();
    p1.setName("p1");
    p1.setValue("v1");
    children.add(p1);
    }

    Hope this helps.
    –mark


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


  • 5.  RE: Setting "control params" dynamically for an applet

    Posted Wed December 29, 2010 11:24 PM

    Thank you very much. It worked !!


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


  • 6.  RE: Setting "control params" dynamically for an applet

    Posted Thu December 30, 2010 06:39 PM