This discussion is archived
10 Replies Latest reply: Nov 26, 2012 2:03 PM by user12294571 RSS

Unable to set the render flag for a field from controller .

user12294571 Newbie
Currently Being Moderated
Hi , I am trying to hide a particular field in a search page base on the value of a search parameter.
I tried the follwoing code but its throwing error message . Can some one help me where I am doing wrong ?
Based on debug messages its throwing error @ OARow row = (OARow)testvo.first();

I wrote the following code in CO.

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

        String a = pageContext.getParameter("AuthorizationStatus");
        OAViewObject testvo = (OAViewObject)pageContext.getApplicationModule(webBean).findViewObject("PoSearchVO");

        OARow row = (OARow)testvo.first(); // tried with getCurrentRow()

        if (a.equalsIgnoreCase("Approved")) 
     {
            row.setAttribute("SummaryFlagRender", Boolean.FALSE);
        } 
     else 
     {
            row.setAttribute("SummaryFlagRender", Boolean.TRUE);
        }
    }
Error message :
oracle.apps.fnd.framework.OAException: java.lang.NullPointerException
     at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
     at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(Unknown Source)
     at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(Unknown Source)
     at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
     at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
     at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
     at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
     at _OA._jspService(_OA.java:71)
     at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
     at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
     at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
     at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
     at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
     at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
     at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
     at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
     at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
     at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
     at java.lang.Thread.run(Thread.java:595)
  • 1. Re: Unable to set the render flag for a field from controller .
    keerthioaf Expert
    Currently Being Moderated
    Hi ,

    The filed you are trying to hide is in which region ??

    Regards ,
    Keerthi
  • 2. Re: Unable to set the render flag for a field from controller .
    Gyan Darpan Guru
    Currently Being Moderated
    Hi,

    Use below code.


    //You are trying to set the boolean value to a varchar field.
    public void processFormRequest(OAPageContext pageContext,  OAWebBean webBean) {
            super.processFormRequest(pageContext, webBean);
     
            String a = pageContext.getParameter("AuthorizationStatus");
            OAViewObject testvo = (OAViewObject)pageContext.getApplicationModule(webBean).findViewObject("PoSearchVO");
     
            OARow row = (OARow)testvo.first(); // tried with getCurrentRow()
     
            if (a.equalsIgnoreCase("Approved")) 
         {
                row.setAttribute("SummaryFlagRender", "N");//Replaced False with N
            } 
         else 
         {
                row.setAttribute("SummaryFlagRender", "Y");//Replaced True with Y
            }
        }
    Another Issue is Null Pointer exception.
    //recheck whether the view instance name is PoSearchVO or PoSearchVO1
    OAViewObject testvo = (OAViewObject)pageContext.getApplicationModule(webBean).findViewObject("PoSearchVO");
    if(testvo!=nulll) //Always make a habit of null check...
    OARow row = (OARow)testvo.first(); // tried with getCurrentRow()
    Regards,
    Gyan
  • 3. Re: Unable to set the render flag for a field from controller .
    user12294571 Newbie
    Currently Being Moderated
    Keerthi,
    I am trying to hide field in the table region of a simple search form based on a field value in search region.
  • 4. Re: Unable to set the render flag for a field from controller .
    user12294571 Newbie
    Currently Being Moderated
    Gyan,
    Thanks for your reply. I will try this and let you know. The only reason I used boolean is the render property takes true or flase even though the field is varchar.
  • 5. Re: Unable to set the render flag for a field from controller .
    user12294571 Newbie
    Currently Being Moderated
    Gyan,
    I tried with the code you suggest , its trying to set the value of a field, but my requirement is to change the property for
    "Rendered" on the field so that based on search parameters we can hide result table column.
    After searching online, I modified the controller code as follows


    1.Created a new transient attribute (Testrender) with type "Boolean" and always updateable.
    2.changed the "Rendered" property value on the field I want to hide as ${oa.PoSearchVO1.Testrender}.
    3. Modified the controller code as follows :

     
            OAApplicationModule am = pageContext.getApplicationModule(webBean); 
    
            OAViewObject testvo = (OAViewObject)am.findViewObject("PoSearchVO1"); 
    
            OADBTransaction txn = am.getOADBTransaction(); 
    
    
            if (testvo != null) 
            { 
              OARow row = (OARow)testvo.first(); 
                if (a.equalsIgnoreCase("Approved")) 
                   { 
                     row.setAttribute("Testrender", Boolean.FALSE); 
                   } 
                else 
                  { 
                     row.setAttribute("Testrender", Boolean.TRUE); 
                  } 
            } 
    But now when i run the page and populate the search field and click "Go" its hiding the field but throwing the following error and the search results are also bad.
    Its using only the value of one search parameter but not the second one .
     
    The search cannot be executed because the table has pending changes that would be lost. 
    I think the vo is getting dirty when I update the transient attribute value. So I used txn.rollback ,then search is working fine but its not hiding the field.
    So can you please let me know how to proceed from here ?
  • 6. Re: Unable to set the render flag for a field from controller .
    user12294571 Newbie
    Currently Being Moderated
    Guys ,
    Can you please help me on this .

    Thanks
    Sri.
  • 7. Re: Unable to set the render flag for a field from controller .
    keerthioaf Expert
    Currently Being Moderated
    Hi Sri ,

    This error comes when you are using a transient attribute which makes the VO as dirty


    Now in the setter of that Transient Attribute in VORowImpl just use populateAttribute method
    instead of setSttributeInternal.

    public void setSelectFlag(String val)
    {

    //setSttributeInternal(SELECTFLAG, val); // please comment this and use below code

    populateAttribute(SELECTFLAG, val);
    }


    Keerthi
  • 8. Re: Unable to set the render flag for a field from controller .
    user12294571 Newbie
    Currently Being Moderated
    Keerthi,
    I didn't see VORowImpl in vo ,how can I build that?

    Thanks
    sri
  • 9. Re: Unable to set the render flag for a field from controller .
    SumitSharma Expert
    Currently Being Moderated
    Dear Sri,
    Trying to fix the dirty bit issue for a case like yours might not be the best of approaches. You can simplify the process by using a separate PVO for your PPR based rendering logic. Use the new PVO and follow the second approach that you have mentioned. This would work.
    Do ensure to update the rendering attribute definition in the region to refer to the new PVO than the existing VO that you are using.

    Regards
    Sumit
  • 10. Re: Unable to set the render flag for a field from controller .
    user12294571 Newbie
    Currently Being Moderated
    Thank You Both of you.
    Sumit and Keerthi,
    Thank you so much for your help on this issue.
    Now I am able to hide columns based on the search parameter value.
    It took long time for me but finally I am able to do it without any issues.

    I am able to achieve it both ways
    1. Build the code in the RowImpl.java as Keerthi suggested.
    2. Build the code using second VO which will resolve the main VO dirty sitaution as Sumit suggested.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points