In this lesson, we are going to see how to swap values from one field to another.
Steps to follow:
We already know that how to create a page and how to create a region, the following figure shows the page structure in JDeveloper:
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.
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
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.