on 10-04-2009 12:18 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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>
<a href="<isa:webappsURL name="/b2c/transactiondetails.do"/>" id="transId" name="transId" <%userSessionData.setAttribute(transId,"<%=transaction.getTransactionId()%>")%> >
<%=transaction.getTransactionId()%>
</a>
</td>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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='<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>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
7 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.