In some cases we need to create a Switcher Bean in existing OAF Pages. We can add this switcher bean programmatically using an extended controller. Sample code is given below:
Feel free to point out if anything is missing/wrong in this blog.
private void addDeleteSwitcher(OATableBean tableBean, OAPageContext pageContext) { OASwitcherBean deleteSwitcher = (OASwitcherBean)tableBean.findChildRecursive("DELETE_SWITCHER"); if (deleteSwitcher == null) { /* * Create Delete Bean Enabled */ OAImageBean deleteBean = (OAImageBean)createWebBean(pageContext, OAWebBeanConstants.IMAGE_BEAN, null,"DELETEROW"); Hashtable paramsWithBinds = new Hashtable(1); paramsWithBinds.put("xxPlanIdParam", new OADataBoundValueFireActionURL(deleteBean, "{$PLAN_ID}")); deleteBean.setFireActionForSubmit("DeleteRow",null,paramsWithBinds,true,true); deleteBean.setSource(OAWebBeanConstants.APPS_MEDIA_DIRECTORY + "deleteicon_enabled.gif"); deleteBean.setShortDesc("Delete this row from the Quality Plan Results"); deleteBean.setLabel("Delete"); deleteBean.setHAlign(OAWebBeanConstants.H_ALIGN_CENTER); /* * Create Delete Bean Disabled */ OAImageBean deleteBeanDisabled = (OAImageBean)createWebBean(pageContext, OAWebBeanConstants.IMAGE_BEAN, null,"DELETEROWDISABLED"); deleteBeanDisabled.setSource(OAWebBeanConstants.APPS_MEDIA_DIRECTORY + "deleteicon_disabled.gif"); deleteBeanDisabled.setShortDesc("Plan Result has been transferred to EAM and cannot be deleted"); deleteBeanDisabled.setLabel("Delete"); deleteBeanDisabled.setHAlign(OAWebBeanConstants.H_ALIGN_CENTER); /* * Create Switch Bean */ deleteSwitcher = (OASwitcherBean)createWebBean(pageContext, OAWebBeanConstants.SWITCHER_BEAN,null,"DELETE_SWITCHER"); deleteSwitcher.setNamedChild("N",deleteBean); deleteSwitcher.setLabel("Delete"); deleteSwitcher.setNamedChild("Y",deleteBeanDisabled); deleteSwitcher.setViewUsageName("ViewResultsVO"); deleteSwitcher.setViewAttributeName("DeleteSwitcherAttribute"); deleteSwitcher.setRendered(true); tableBean.addIndexedChild(deleteSwitcher); } }
Feel free to point out if anything is missing/wrong in this blog.
No comments:
Post a Comment