Sunday, May 22, 2005

Steps to dynamically bind a dynamically created view object

1. Expose the method recreateDynamicViewObjectWithNewQuery(String newSQL) to the client in the AM. This method will basically find the view object, remove it, create a new instance of vo from the query and executes the query:
findViewObject(DYNAMIC_VO_NAME).remove();
ViewObject vo = createViewObjectFromQueryStmt(DYNAMIC_VO_NAME,newSQL);
vo.executeQuery();
2. In the Client side(controller), override the prepareModel. The overriden method should
- unset the tokenvalidation through : ctx.getBindingContainer().setEnableTokenValidation(false);
- Unbind the rowsetIterator from the dynamicqueryiteratorbinding through : ctx.getBindingContainer(). findIteratorBinding(DYNAMIC_VO_ITER_NAME).bindRowSetIterator(null,false);
- call the method exposed by AM to bind the newSQL to the view object.
- remove the control binding by name. removeControlBinding(ctx,DYNAMIC_VO_RANGE);(basically remove the control binding from the iterator binding list and remove it from the binding container).
removeControlBinding:
---------------------------
DCBindingContainer bc = ctx.getBindingContainer();
DCControlBinding binding = bc.findCtrlBinding(name);
binding.getDCIteratorBinding().removeValueBinding(binding);
bc.removeControlBinding(binding);
- recreate the control binding and add it to the binding container:addDynamicRangeBinding(ctx,DYNAMIC_VO_RANGE, DYNAMIC_VO_ITER_NAME);
addDynamicRangeBinding
-------------------------------
DCBindingContainer bc = ctx.getBindingContainer();
JUCtrlRangeBinding dynamicRangeBinding =
new JUCtrlRangeBinding(null,bc.findIteratorBinding(iterName),null);
bc.addControlBinding(bindingName,dynamicRangeBinding);
- Execute super.prepareModel(ctx);
- Reset the tokenvalidation through : ctx.getBindingContainer().setEnableTokenValidation(true);

No comments: