Skip to Content
Author's profile photo Former Member

Passing hidden parameter from one iview to another

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.

    Assigned Tags

        5 Comments
        You must be Logged on to comment or reply to a post.
        Author's profile photo Former Member
        Former Member
        Portal eventing is another possibility and is fully supported by things like Web Dynpro. Try searching EPCF in the SAP help pages for more details.
        Author's profile photo Former Member
        Former Member
        I think this best approach in case of PAR file and light framework pages as passing hidden parameters are not possible through EPCF. More to that EPCF always make the parameter visible in address bar which potential threat in terms of data security

        Thanks Atul

        Author's profile photo Former Member
        Former Member
        Blog Post Author
        Yes you are right. This can also be achieved by portal eventing. In my blog, I have mentioned two methods. Method A is what the portal eventing can do. Instead of window.open, EPCM.doNavigate can be used. But the purpose of this blog was to overcome the problem of parameter which is seen in the URL on the address bar. The method B clearly shows how to pass the hidden parameter, which is not possible through EPCF. So it maintains the data security.
        Author's profile photo Former Member
        Former Member
        I think this best approach in case of PAR file and light framework pages as passing hidden parameters are not possible through EPCF. More to that EPCF always make the parameter visible in address bar which potential threat in terms of data security

        Thanks Atul

        Author's profile photo Former Member
        Former Member
        I think this best approach in case of PAR file and light framework pages as passing hidden parameters are not possible through EPCF. More to that EPCF always make the parameter visible in address bar which potential threat in terms of data security

        Thanks Atul