Skip to Content
author's profile photo Former Member
Former Member

Forwarding a variabe in request scope

When i am trying to forward a variable in request scope along with action, i am not not able to retrieve the value in action class.As in config.xml one action will call other action in LayoutConfig.xml I couldnt retrieve the vaue in action class.So anyone please suggest me in this criteria.

regards

Anuradha

Add a comment
10|10000 characters needed characters exceeded

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 04, 2009 at 01:34 PM

    Hi Steve,

    You can pass the variable to an action class by making below changes to config.xml

    <forward name="success" path="/b2b/maintainbasket.do?showonly=true"/>
    

    This variable will now be available in com.sap.isa.isacore.action.order.MaintainBasketDispatcherAction class.

    But if you try to access this variable in a subsequent action after MaintainBasketDispatcherAction than you wont

    find it there because of the scope of context. For this once you are there in MaintainBasketDispatcherAction, you

    can set the variable in session like

    userSessionData.setAttribute("showonly","true");
    

    Now this variable is available in session scope and you can delete it in the subsequent action class after making use.

    userSessionData.removeAttribute("showonly");
    

    Same applies if you are passing the variable through jsp also.Hope this helps you.

    Regards,

    Arshi

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 05, 2009 at 06:03 PM

    Actually my action in jsp will call another action in layout config.xml .Means it is not a action class.It is just a forwarder.That will call another.I will paste my code here.Pls gothru once

    JSP:

    document.forms[0].action=' transactiondetails.do"/>?transId='+transvalue;

    documen.forms[0].submit

    config.xml

    <action path="/b2c/transactiondetails" forward="UIArea : transactionDetails"/>

    LayoutConfig.xml

    getTransactionDetails.do"

    title="b2c.transactiondetails.title"/>

    config.xml

    <action path="/b2c/getTransactionDetails" type="com.sap.isa.isacore.action.loyalty.ZGetTransactiondetailsAction">

    <forward="succecc" path="UIInclude:/b2c/transactionDetails.inc.jsp"/>

    </action>

    now i want the value of transId in JSP page

    when i am trying get by using request.getAttribute(transId)

    It is throwing null pointer excption.

    becos here it is not directly calling by action class .I think it is not fowarding.But i shuld follow this path.

    Is there any solution for this

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Steve,

      Try to pass your parameter in layoutconfig.xml instead of in Java Script function of JSP Page.

      JSP:

      document.forms[0].action='<isa:webappsURL name="/b2c/transactiondetails.do"/>?transId='+transvalue;

      documen.forms[0].submit

      config.xml

      <action path="/b2c/transactiondetails" forward="UIArea : transactionDetails"/>

      LayoutConfig.xml

      <UIComponent name="transactionDetails" action="/b2c/getTransactionDetails.do"

      title="b2c.transactiondetails.title"/>

      config.xml

      <action path="/b2c/getTransactionDetails" type="com.sap.isa.isacore.action.loyalty.ZGetTransactiondetailsAction">

      <forward="succecc" path="UIInclude:/b2c/transactionDetails.inc.jsp"/>

      </action>

      Try below it may work.

      JSP:
      document.forms[0].action='<isa:webappsURL name="/b2c/transactiondetails.do"/>;
      documen.forms[0].submit
      
      config.xml
      <action path="/b2c/transactiondetails" forward="UIArea : transactionDetails"/>
      
      
      LayoutConfig.xml
      <UIComponent name="transactionDetails" action="/b2c/getTransactionDetails.do?transId="transvalue" title="b2c.transactiondetails.title"/>
      
      config.xml
      <action path="/b2c/getTransactionDetails" type="com.sap.isa.isacore.action.loyalty.ZGetTransactiondetailsAction">
      <forward="succecc" path="UIInclude:/b2c/transactionDetails.inc.jsp"/>
      </action>
      

      You will get transld value in action class ZGetTransactiondetailsAction and get the attribute from request object by getParameter/getAttribute method also you can set this parameter/attribute again in request object in ZGetTransactiondetailsAction and then retrieve it again on transactionDetails.inc.jsp page from request object.

      If getAttribute do not work try getParameter method.

      I hope this will help you.

      eCommerce Developer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 06, 2009 at 04:22 AM

    Thanks for the reply, .But I still have a doubt.

    How dol I pass transvalue to layoutconfig.xml

    If it is to pass to javascript the function jsget(transvalue) is used

    But how to pass to Layout-config

    Actually I am retrieving that value from jsp

    Can you please help me with this.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Steve,

      Is there any specific reason to pass value in layout-config.xml. As you can not pass Variable in config.xml and layout-config.xml.

      you can pass fix value like "transid=001" But you can't pass variable like "transid=transvalue"

      You can set this variable in Usersessiondata object and retrieve it in your Action class as Arshi has describe. As per my knowledge you cannot pass variable in request parameter in config.xml/layout-config.xml.

      I hope you understand the reason.

      Let us know if you have any question.

      eCommerce Developer

  • author's profile photo Former Member
    Former Member
    Posted on Oct 06, 2009 at 08:17 AM

    Can you tell me how to set variable in Usersessiondata and retrieve in action class.As I am new to this framework.Please guide me

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Steve,

      Suppose you want to set the data in session from a jsp than you can do it like

      String test = "data to be passed";
      UserSessionData userSessionData = UserSessionData.getUserSessionData(request.getSession());
      userSessionData.setAttribute("TEST",test);
      

      Now to fetch this data in the action class just write but after retrieving the value from the session dont forget to delete the session

      variable as it eats on system resources and if the number of logins is high than even a small string can take good space.

      String data = (String) userSessionData.getAttribute("TEST");
      userSessionData.removeAttribute("TEST");
      

      But if you are planning to set the data in session from config.xml or layout-config.xml file than as per my understanding you cant do it.One more thing you cant set data in request or any context from javascript as you cant write java code in a javascript method.Hope this helps you.

      Regards,

      Arshi

  • author's profile photo Former Member
    Former Member
    Posted on Oct 06, 2009 at 09:50 AM

    Is this the right way.Because I need to the value when on click of that only .So I have used anchor tag.This will be in dynamic content of a table.

    <td>

    transactiondetails.do"/>" id="transId" name="transId" <%userSessionData.setAttribute(transId,"<%=transaction.getTransactionId()%>")%> >

    <%=transaction.getTransactionId()%>

    </a>

    </td>

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.