In an earlier post we saw how to add ADF components in a page at runtime. It is easy enough. After some time I got a bit confused as to how to remove components, either predefined or these dynamically created components at runtime.
This is easy too and I cursed myself for getting stuck over such a trifle issue.
Let's assume that you have a panel group layout whose child components you want to remove and you have bound this panel group layout in your backing bean.
In the event handler method of the action on which you want the components to be removed, do this:
getMyPanelGroupLayout().getChildren().clear();
Simple isn't it? Since ADF exposes children of any component in form of a List, adding and removing any component is as easy as adding or removing to a list. Here I have removed all the child components of the panel group layout using 'clear()'. If you want to selectively remove components, based on id or name or any other property, you can traverse the list and remove the components which meet your criteria.
This is easy too and I cursed myself for getting stuck over such a trifle issue.
Let's assume that you have a panel group layout whose child components you want to remove and you have bound this panel group layout in your backing bean.
In the event handler method of the action on which you want the components to be removed, do this:
getMyPanelGroupLayout().getChildren().clear();
Simple isn't it? Since ADF exposes children of any component in form of a List, adding and removing any component is as easy as adding or removing to a list. Here I have removed all the child components of the panel group layout using 'clear()'. If you want to selectively remove components, based on id or name or any other property, you can traverse the list and remove the components which meet your criteria.
Comments