Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

At times we need to pass a value from one iView to another and depending on the parameter passed, another iView is required to pull the data.

Here in this Blog, I will discuss two methods to achieve the same, and compare the two solutions:-

Solution (A)

Follow each step to build the solution:

1)    You are using iview Sender and iView Receiver. Say your receiver iview has the PCD location as “portal_content/com.MyFolder/com.MyiViews/com.ReceiveriView”.

2)    Open this iview(Receiver) and preview it. Right click on that popup page, click on properties and copy the Address URL starting /irj.

3)    To send a parameter from the sender iview (say on click of a link), you would need to call the receiver iview through window.open, adding a parameter with a question mark (?) at the end of the pcd location(that you copied at above step# 2). So in the example taken here, it would look something like

type=<"text/javascript">

function openParam()

      {

          String MyParameter = “Test”;

         window.open("/irj/servlet/prt/portal/prtroot/pcd!3aportal_content! com.MyFolder!2fcom.MyiViews!2fcom.ReceiveriView?Parameter="+MyParameter);  

     }

* (This piece of JavaScript code needs to be added in the jsp of the sender iview par file). You need to call the above defined function openParam() on click of which the parameter needs to be passed.

4)    Now Open the jsp of the receiver iview par file and add the following piece of code

    <%String Parameterreceived = request.getParameter("Parameter");%>

5)    Do not forget to import the following in your receiver par file        

    <%@ page import = "com.sapportals.portal.prt.component.IPortalComponentRequest" %>

    <%@ page import = "javax.servlet.http.HttpServletResponse" %>

    This solution will definitely solve the purpose of passing the parameter from one iView to another but the question is, is this the secured way of doing so?

    Yes the answer is NO because the opened page will have the complete information of the parameter passed, and anybody can tweak in the parameter to try for different similar option/reports. Now lets see how we can get it secured.

    Solution (B)

    1)  The sender iView par should have the form something similar to the following

         <form id="TheForm" method="post" action="###" target="TheWindow">

         <input type="hidden" name="something" value="something" />

          </form>

     

    2)  The address URL of the receiver ivew shall be put under action. In this example the action would be

    "/irj/servlet/prt/portal/prtroot/pcd!3aportal_content!com.MyFolder!2fcom.MyiViews!2fcom.ReceiveriView”

    3)    Call the function openParam() on click of which the parameter needs to be passed. This function shall be defined in the sender par file as following:-

    <script>

    function openParam(myparam)

         {

              var f = document.forms[0].elements[0];

              f.value = myparam;

              window.open('','TheWindow');

              document.getElementById('TheForm').submit();

         }

    </script>

    4)   Open the jsp of the receiver iview par file to recognize the parameter sent

         <%String Parameterreceived = request.getParameter("something");%>

    5)    Do not forget to import the following in your receiver par file  

    <%@ page import = "com.sapportals.portal.prt.component.IPortalComponentRequest" %>

    <%@ page import = "javax.servlet.http.HttpServletResponse" %>

    6)    Your iview is now ready to send and receive any parameter, via hidden value

    Benefit of Solution B over A is that the later is passing hidden parameter to another iview.

    This would restrict the passed parameter to be reflected on the URL of the opened page. It is a secured way of passing values.

    5 Comments
    Labels in this area