• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

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:

59

Now on the main region create Controller and write the logic in Process Form Request, and the code is :

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);

}

}

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.

60

If we want to place or clear the text what we entered then write the following additional code:

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);

}

}

Summary
Review Date
Reviewed Item
Swapping The Value From One Field to Another Field
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Swapping The Value From One Field to Another Field"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.