Setting "control params" dynamically for an applet

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?


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.


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?

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:

	protected void beforeRenderResponse() {
		//clear old children from previous request
		Applet applet = getApplet();
		List<UIComponent> children = applet.getChildren();
		//get params from somewhere
		UIParameter p1 = new UIParameter();

Hope this helps.

Thank you very much. It worked !!

BTW. There is a little tutorial available on the topic here: