Search This Blog

Saturday, March 19, 2016

11. OAF Swapping The Value From One Field to Another Field

Swapping The Value From One Field to Another Field


In this lesson we are going to see how to swap a values from one field to another.
Steps to follow:
  1. Create a Page and create Message Component Layout Region
  2. Create two items one Message Text Input and other is Message Styled Text with prompts as “Enter some Text :” and “Entered Text :”.
  3. Create one button so that when we click on button swapping process to done.
  4. Create Controller and write the Swapping logic in ProcessFormRequest.
We already know that how to create a page and how to create a region, the following figure shows the page structure in JDeveloper:

Swapping in OAF Page StructureSwapping in OAF Page Structure

Now on the main region create Controller and write the logic in Process Form Request, and the code is :
 
[sql]public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processFormRequest(pageContext, webBean);
 if(pageContext.getParameter(“item3”)!=null)
 {
   String name=pageContext.getParameter(“item1”);
   OAMessageStyledTextBean mst=(OAMessageStyledTextBean)webBean.findChildRecursive(“item2”);
   mst.setValue(pageContext,name);
 }
}[/sql]

In the above program item1 is id value of the Message Input Text item, item2 is the Id value of the Message Styled Text.
Rebuild the code and run the page to see the output.
Enter some text in the field and click on swap button for swapping.

Swapping Values in OAF Java code

If we want to place or clear the text what we entered then write the following additional code:
 
[sql]public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
 super.processFormRequest(pageContext, webBean);
  if(pageContext.getParameter(“item3”)!=null)
  {
   String name=pageContext.getParameter(“item1”);
   OAMessageStyledTextBean mst=(OAMessageStyledTextBean)webBean.findChildRecursive(“item2”);
   mst.setValue(pageContext,name);
   OAMessageTextInputBean mtib =(OAMessageTextInputBean)webBean.findChildRecursive(“item1”);
   mtib.setValue(pageContext,null);
  }
}[/sql]

No comments:

Post a Comment