Swapping The Value From One Field to Another Field

Ratings:
(4)
Views:319
Banner-Img
  • Share this blog:

In this lesson, we are going to see how to swap 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);

}

}

 

Check out related blogs:

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox