Tuesday, October 10, 2017

Swapping Values

1. Create a page with two text boxes and swap button
2. Enter the values in text boxes and click on swap button
3. The values should get swapped

Code:

  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
  {
    super.processFormRequest(pageContext, webBean);

      if (pageContext.getParameter("swap")!=null) {
          String texta = pageContext.getParameter("swapa");
          String textb = pageContext.getParameter("swapb");
         
          OAMessageTextInputBean  swapa = (OAMessageTextInputBean)webBean.findChildRecursive("swapa") ;
          OAMessageTextInputBean  swapb = (OAMessageTextInputBean)webBean.findChildRecursive("swapb") ;
          swapa.setValue(pageContext,textb);       
          swapb.setValue(pageContext,texta);   
      }
}

Output for Swapping.


No comments:

Post a Comment