Sunday 24 November 2013

OAF – How to create a switcher region programmatically.


Create the switcher bean
OASwitcherBean status = (OASwitcherBean)createWebBean(pageContext,OAWebBeanConstants.SWITCHER_BEAN,null,null);
status.setViewUsageName(“myVO1″);
status.setViewAttributeName(“LovFlag”);
status.setDataType(“VARCHAR2″);
status.setLabel(“Status”);
//Create our first case, in this scenario it is a pick list
OAMessageChoiceBean approve = (OAMessageChoiceBean)createWebBean(pageContext,OAWebBeanConstants.MESSAGE_CHOICE_BEAN,null,”Case1″);
approve.setViewUsageName(“myVO1″);
approve.setViewAttributeName(“BonusStatus”);
approve.setDataType(“VARCHAR2″);
approve.setPickListViewUsageName(“PickListVO1″);
approve.setListDisplayAttribute(“Meaning”);
approve.setListValueAttribute(“Code”);
//Create our second case, here this is a pick list as above but with a different pick list vo source
OAMessageChoiceBean others = (OAMessageChoiceBean)createWebBean(pageContext,OAWebBeanConstants.MESSAGE_CHOICE_BEAN,null,”Case2″);
others.setViewUsageName(“myVO1″);
others.setViewAttributeName(“BonusStatus”);
others.setDataType(“VARCHAR2″);
others.setPickListViewUsageName(“PickList2VO1″);
others.setListDisplayAttribute(“Disp”);
others.setListValueAttribute(“Code”);
others.setDisabled(Boolean.TRUE);
//Add the two created cased to the switcher bean
status.setNamedChild(“Case1″,approve);
status.setNamedChild(“Case2″,others);
//Now add the switcher to what ever region you need to in your page, in the below case it is being added to a OATableBean
table.addIndexedChild(status);
Note: The above code assumes the cases of “Case1″ and “Case2″ are being returned as string values in the VO myVO1.LovFlag field which will drive the switcher case decision.


 

No comments:

Post a Comment