Saturday, January 11, 2014

Create a simple update page

After creating a simple search page lets add simple update functionality to the same page.

1> Create a new button region


2> Change ID (ButtonRN) and region style(pageButtonBar)


3> Create a new item to this Button region



4> Change Id(Save), Item Style(submitButton), prompt(Save) and attribute set as
                       /oracle/apps/fnd/attributesets/Buttons/Apply


5> Create another item and Change Id(Cancel), Item Style(submitButton),
     prompt(Cancel) and attribute set as  /oracle/apps/fnd/attributesets/Buttons/Cancel


6> Since we need to write some command update functionality now we will add a page controller


7> Name xxhwhrnicCO under webui package


8> Now we need to write some logic for update functionality, add below methods to the AMImpl file
     (xxhwhrnicAMImpl) for commit or rollback the changes.

public void apply()
    {
     getTransaction().commit();
    }

public void rollback()
    {
     getTransaction().rollback();
    }


9> Call these methods from controller(xxhwhrnicCO) for update logic
     Import below beans and replace processRequest and processFormRequest methods
     with below logic.
    I guess logic is self explanatory :)

import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.layout.OAQueryBean;

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processRequest(pageContext, webBean);
OAQueryBean queryBean = (OAQueryBean)webBean.findChildRecursive("QueryRN");
queryBean.clearSearchPersistenceCache(pageContext);
}
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
OAApplicationModule am = pageContext.getApplicationModule(webBean);
if (pageContext.getParameter("Save") != null)
{
am.invokeMethod("apply");
pageContext.forwardImmediately("OA.jsp?page=/xxhw/oracle/apps/per/nic/webui/xxhwhrnicPG ",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
else if (pageContext.getParameter("Cancel") != null)
{
am.invokeMethod("rollback");
pageContext.forwardImmediately("OA.jsp?page=/xxhw/oracle/apps/per/nic/webui/xxhwhrnicPG ",
null,
OAWebBeanConstants.KEEP_MENU_CONTEXT,
null,
null,
false, // retain AM
OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
}
}

> In case any error populates to import some packages, just import those



 >> Lets add list of values (LOV) to our search column Adding LOV
 

No comments:

Post a Comment