How do you invoke the method invokeMethod in IDynamicAccess

Hello,

I have a button definition as follows,





Adapter class as follows …

class BaseAdapter extends Adapter implements IDynamicAccess {

protected HashMap controlRegistration = new HashMap();
Pages pages = null;

public String findDynamicAccessProperties() {
return new String{“page0”, “page0.secc0”, “page0.secc0.butc0”};
}

public Class getClassForProperty(String property) {
if(property.equals(“page0”))
return Page.class;
if(property.equals(“page0.secc0”))
return Section.class;
if(property.equals(“page0.secc0.butc0”))
return Button.class;
return null;
}

public void setPropertyValue(String propertyName, Object value) {
// do not have to implement; Casabac only sets on the level
// of simple data types
}

public Object getPropertyValue(String propertyName) {
try {
return controlRegistration.get(propertyName);
} catch (Throwable t) {
System.out.println("SHOULD NEVER HAPPEN - " + t);
}
throw new IllegalArgumentException("Could not find object "
+ propertyName);
}

public void invokeMethod(String methodName) {
System.out.println("invokeMethod " + methodName);
if(methodName.equals(“page0.secc0.butc0.onAction”))
System.out.println(“called via invokeMethod”);
}

public void init()
{
pages = new Page[1];
pages[0] = new Page();
controlRegistration.put(“page0”, pages[0]);

	Section body = new Section();
	pages[0].addSection(body);
	controlRegistration.put("page0.secc0", body);
	
	Button butt = new Button(0, "Save", null);
	body.addButton(butt);
	controlRegistration.put("page0.secc0.butc0", butt);

}
}

And would like to invoke the method onAction. My BaseAdapter has an array of Page instance, which holds an array of Section instances, which itself contains an array of Controls instances, the 0th element being instance of Button control.

I am able to invoke the method using the Bean Property, but would like to use IDynamicAccess to invoke the methods, so that I don’t have to define an interface for each of my control. Could some one please show by example of how to use the method invokeMethod defined in IDynamicAcccess ? Or point me to the right direction if invokeMethod is not for that purpose

Thanks a ton.