8 Replies Latest reply: Nov 14, 2012 1:51 PM by OAF_Monkey RSS

    Table Row values and page forward

    OAF_Monkey
      Hello,

      I have 2 custom pages. 1st page is a search page. Search returns data into a table region in the same page. Each row of the table has a button in it (along with the primary key and other queried values). Upon clicking the button, I need to capture the primary key and then call a new custom page with that key. Eventually want to use that key to construct a dynamic query and based on that want to create an EO/VO etc.

      In the PFR of the co of the search page, I am capturing the row reference and then invoking a custom method in the AM while passing the reference. In the custom method of the AM, I am extracting the primary key (using the reference). I am able to see the key with the SOP messages. This much I am able to do after reading some earlier posts. Not sure how to pass this value while calling a page forward.

      Should I write the primary key to the session value in the AM and then use it in the CO? If yes, how to do it...since the "pageContext.putSessionValue" is not getting recognized in the AM. Pls. clarify the concept. I am not posting my code yet because, I want to understand the concept and try on my own first.

      Also, pls. point me to any earlier posts on this topic.

      Thanks,
        • 1. Re: Table Row values and page forward
          Gyan Darpan
          Hi,

          Making use of session variable is not the right approach.

          You can pass the value as HashMap while forwarding the page.
          HashMap pageParams= new HashMap(1);
          pageParams.put("value",<value>);
          pageContext.setForwardURL(< some page >,KEEP_MENU_CONTEXT, // Keep current menu context
          null,pageParams,// additional URL parameters
          true, // Retain AM
          ADD_BREAD_CRUMB_NO, // Do not display breadcrumbs
          IGNORE_MESSAGES);
          }
          Regards,
          Gyan
          • 2. Re: Table Row values and page forward
            OAF_Monkey
            Gyan,

            Thank you for the feedback. Really the point where I am getting confused is, I am capturing the value of the row level primary key in a 'handler' method in the AM. From there, how do I pass the value to the CO (and then follow what you suggested below). Is the value (variable holding the primary key value) automatically available in the CO as well?

            If my question above is not clear, pls. let me know...I can post my code.

            Thanks,
            • 3. Re: Table Row values and page forward
              Sushant Sharma
              Hi,

              Can you paste your CO and AM code here?

              --Sushant                                                                                                                                                                                                       
              • 4. Re: Table Row values and page forward
                OAF_Monkey
                Thank you for the feedback Sushant. Below are the 2 sections of my code:
                PFR of my CO. Pls. note that the CO is at the page level (MainRN) and not at the table region level (seems to work ok so far...but not sure if the CO needs to be at the page level or at the table region level).
                  public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
                  {
                    super.processFormRequest(pageContext, webBean);
                        OAApplicationModule am = pageContext.getApplicationModule(webBean);
                       // pageContext.getParameter(EVENT_PARAM);
                        String event = pageContext.getParameter(EVENT_PARAM);
                        System.out.println("point0 : got the event" + event ); 
                        if (("JI").equals(event))
                        {         
                        //* Get the identifier of the PPR event source row*
                        String rowReference = pageContext.getParameter(OAWebBeanConstants.EVENT_SOURCE_ROW_REFERENCE);
                        System.out.println("point1 : got the row reference" ); 
                        Serializable[] parameters = { rowReference };
                        System.out.println("point2 : Serialized the params" ); 
                        // Pass the rowReference to a "handler" method in the application module.
                        am.invokeMethod("handleJI", parameters);
                        System.out.println("point3 : invoked the handleJI in the AM" ); 
                         
                        String hpPrimaryKey=pageContext.getParameter("pkey"); 
                        // at this point8, I expect to see the captured primary key.  Need to get it here so that I can put it in another hash map
                        // and then call the page forward while passing the new hash map.
                        System.out.println("point8 : primarykey value in the hashmap is" + hpPrimaryKey); 
                        }
                }
                Handler method "handleJI" in the AM:
                    public void handleJI(String rowReference) {
                        //get a handle to the view object instance
                        OAViewObject SJvo=(OAViewObject)xxObjectVO1();  
                        System.out.println("point4 : got a handle to the view object instance" );
                        xxObjectVORowImpl row= (xxObjectVORowImpl)findRowByRef(rowReference);
                        System.out.println("point5 : found the row using the passed in row reference" );        
                
                       //oracle.jbo.domain.Number primaryKeyValue = (oracle.jbo.domain.Number)row.getAttribute("primarykey");
                       String pkey = null;
                       if (row.getAttribute("primarykey").toString()!=null) {
                           pkey = row.getAttribute("primarykey").toString();    
                       }
                           System.out.println(row.getAttribute("primarykey").toString());
                           // gets me the primary key value here for the row in which the button is clicked
                           System.out.println(pkey);
                          //gets me the primary key value here for the row in which the button is clicked
                
                           //now put the value in the hp.  Is this the right way to do?  how to access this value in the reminder of the PFR so as to 
                           //pass it to a pageforward??
                           HashMap hp = new HashMap(1);
                           hp.put("pkey",pkey);
                        
                         //pageContext.putSessionValue("MySessionuKey",paramUkey);
                         
                
                           System.out.println("point6 : put the value in the hp" );
                
                       }
                • 5. Re: Table Row values and page forward
                  Sushant Sharma
                  Hi,

                  Why are you using HashMap in AM ?

                  As per my understanding, your only requirement is to pass primary key from first page to another page and then you want to do some operation on 2nd page using that primary key... Let me know if this is fine?
                  This can be done from controller only.

                  --Sushant                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                  • 6. Re: Table Row values and page forward
                    OAF_Monkey
                    As I mentioned earlier, I am not sure how to get the value (of the primary key that is captured) from the AM into the CO.
                    Pls. ignore the attempt to write to the hash map in the AM....it was just an attempt on my part (trying to understand and tinker with things a bit...)
                     public void handleJI(String rowReference) {
                            //get a handle to the view object instance
                            OAViewObject SJvo=(OAViewObject)xxObjectVO1();  
                            System.out.println("point4 : got a handle to the view object instance" );
                            xxObjectVORowImpl row= (xxObjectVORowImpl)findRowByRef(rowReference);
                            System.out.println("point5 : found the row using the passed in row reference" );        
                     
                           //oracle.jbo.domain.Number primaryKeyValue = (oracle.jbo.domain.Number)row.getAttribute("primarykey");
                           String pkey = null;
                           if (row.getAttribute("primarykey").toString()!=null) {
                               pkey = row.getAttribute("primarykey").toString();    
                           }
                               System.out.println(row.getAttribute("primarykey").toString());
                               // gets me the primary key value here for the row in which the button is clicked
                               System.out.println(pkey);
                              //gets me the primary key value here for the row in which the button is clicked
                     
                               //now put the value in the hp.  Is this the right way to do?  how to access this value in the reminder of the PFR so as to 
                               //pass it to a pageforward??
                              //HashMap hp = new HashMap(1);
                              // hp.put("pkey",pkey);
                            
                             //pageContext.putSessionValue("MySessionuKey",paramUkey);
                             
                     
                               System.out.println("point6 : put the value in the hp" );
                     
                           }
                    
                     
                    Thanks,

                    Edited by: OAF_Monkey on Nov 14, 2012 9:57 AM
                    • 7. Re: Table Row values and page forward
                      OAF_Monkey
                      Sushanth,

                      Your comment "This can be done from controller only" made me think a bit more. Hence changed my code (referred to an older post) and now getting the primary key in the controller itself. So that issue is now solved.

                      However, I now am trying to create a new EO based off a view. Able to see the view/select from it in TOAD. However, When i try to select that view in the entity object creation, can't see it. Any ides about why wouldn't it show?

                      Thanks,
                      • 8. Re: Table Row values and page forward
                        OAF_Monkey
                        Hello,

                        I went past the issue of not being able to select the table/view while trying to create a EO.

                        The next thing that I am trying to learn is how to use the primary key forwarded from the page1 in creating a VO dynamically/run time. Need to use it to display the queried values from a different table in page2. Any suggestions/ideas on how to do it?

                        Thanks,