on 01-04-2006 10:52 AM
Hi,
I am trying to pass a variable value from a JSPDynpage based iview to a webdynpro based iview.
I am using Httpsession and storing the value in it.
Although Iam able to access the session from both components the value somehow gets lost.
Below is the code I have written for the same :
<b>JSPDynapge : </b>
IPortalComponentRequest req = (IPortalComponentRequest)this.getRequest();
IPortalComponentResponse res= (IPortalComponentResponse)this.getResponse();
HttpSession session =
req.getServletRequest().getSession();
session.setAttribute("Employee_Id","12345678");
req.getServletResponse(true).sendRedirect("/irj/portal");
<b>Webdynpro : </b>
HttpSession session = ((com.sap.tc.webdynpro.services.sal.adapter.core.IWebContextAdapter)WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest().getSession();
String abc = (String)session.getAttribute("Employee_Id");
The value it shows in webdynpro is NULL.
Could somebody tell me where I am going wrong,or is there any other approach for the same problem.
Regards,
Kshitij Agrawal
Hi ,
One doubt,why dont you use portal client eventing supported by Portal runtime.
you can raise event from JspDynpage
EPCM.raiseEvent('urn:....' , 'MethodName' , evtData);
In your webdynpro subscripe to this portal eventing
WDPortalEventing.subscribe("urn:..." , "MethodName" ,wdThis.wdGetEvenBinnenAction());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In you JspDynpage, i suppose you have a UiElement say button.
<hbj:button
id="Send_Button"
text="SendEventToAOB"
onClientClick="sendEventToAOB('Kaart Event is binnen')"
tooltip="Submit"
width=""
design="EMPHASIZED" >
</hbj:button>
You need to have a javascript inside your page like
<script>
function sendEventToAOB(evtData)
{
EPCM.raiseEvent('urn:/civ/nedg' , 'KaartToAob' , evtData);
}
</script>
You can see that i have passed string parameter to javascript function.You can also do it with out parameter and inside the javascript decide which value object that you want to pass.
Hi Kshitji,
Your question was
How do I pass the values while using EPCM.(the event data)and not how to access the data in webdynpro.Doesn't matter anyway.
In the View(s) in wdDoInit method you can subscripe to the portal event.
WDPortalEventing.subscribe("urn:/civ/nedg" , "KaartToAob" ,wdThis.wdGetMyEventBinnenAction());
You have to create a action of your choice(MyEventBinnen) with parameter as "dataObject" of type string.
so your MyEventBinnen should be something like this
public void onActionMyEventBinnen(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String dataObject )
{
//@@begin onActionKaartEvenBinnen(ServerEvent)
IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
String dialogText = dataObject;
IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText,controllerInfo.findInEventHandlers("ok"),"ok");
dialog.setWindowSize( 50, 50);
dialog.open();
//@@end
}
It is also good practice to unsubscripe your portal event.
So you can write the following code in your wdDoExit method.
WDPortalEventing.unsubscribe("urn:/civ/nedg" , "KaartToAob" ,wdThis.wdGetMyEventBinnenAction());
Hi Baskaran,
Thanks once again for the piece of code you sent.
I have implemented the same for myself , but webdynpro fails to subscribe to the event.I mean it does not go the required event handler at all.
This is what i have given :
<b>JSPDynpage : </b>
EPCM.raiseEvent("urn:com.EPCMEvent","pass_Event",evtdata);
This is on click of a button
<b>Webdynpro : </b>
WDPortalEventing.subscribe("urn:com.sap.EPCMEvent","pass_Event",wdThis.wdGetEvent_EPCMAction());
in wdDoinit()
In the event handler I am trying to display the values...but nothing comes.
Could you please tell me where Iam going wrong.
Regards,
Kshitij Agrawal
Hi
Can you post your JspDynpage piece of coding.
First see if the EPCM worked correctly in Jspdynpage.
After raising event put this code
alert("Eventdata is "+evtData);
IF alert is coming that means EPCM is executed.
Built in the eventhandler to display your won string and not from the parameter dataObj.
Hi,
I <b>alert window does popup</b> with the correct data.The problem is in webdynpro.
I have given a confirmation window in the event handler.The <b>confirmation dialog does not even open/popup.</b>
Following is some of the code :
<b>wdDoinit in Webdynpro : </b>
WDPortalEventing.subscribe("urn:com.sap.EPCMEvent","pass_Event",wdThis.wdGetEvent_EPCMAction());
<b>Jsp page : </b>
function callPass(evtdata)
{
EPCM.raiseEvent("urn:com.EPCMEvent","pass_Event",evtdata);
alert("Eventdata is "+evtdata);
}
<b>Java class : </b>
IPortalComponentRequest req = (IPortalComponentRequest)this.getRequest();
IPortalComponentResponse res= (IPortalComponentResponse)this.getResponse();
HttpServletRequest request = (HttpServletRequest)req.getServletRequest();
HttpServletResponse response = (HttpServletResponse)req.getServletResponse(true);
String u="DOMS_Customer";
String p="domscust";
response.resetBuffer();
response.reset();
IAuthentication I_auth = UMFactory.getAuthenticator();
response.reset();
response.resetBuffer();
request.setAttribute("j_user",u);
request.setAttribute("j_password",p);
try
{
ILogonAuthentication I_logon_auth = UMFactory.getLogonAuthenticator();
I_logon_auth.logon(request,response,"default");
HttpSession session = req.getServletRequest().getSession(true);
session.setAttribute("Employee_Id","123456789");
response.sendRedirect("/irj/portal");
}
catch(Exception e)
{
res.write(e.getLocalizedMessage());
}
Below is the entire event handler :
public void onActionEvent_EPCM(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String dataObject )
{
//@@begin onActionEvent_EPCM(ServerEvent)
wdContext.currentContextElement().setCustNum(dataObject);
String dt =dataObject;
final IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow
(
dt,
wdControllerAPI.getControllerInfo().findInEventHandlers("OnEventOK"),
"YES"
);
dialog.open();
//@@end
}
Hi Kshitij,
I am not sure if your controller info is correct.
Controllerinfo should be like this
String dt =dataObject+" Check EPCM portal event";
IWDControllerInfo controllerInfo = wdControllerAPI.getViewInfo().getViewController();
final IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow
(
dt,
wdControllerAPI.getControllerInfo().findInEventHandlers("OnEventOK"),
"YES"
);
dialog.open();
If this above code is not working then you can try to display a confirmation message
IWDMessageManager manager = wdComponentAPI.getMessageManager();
manager.reportSuccess("EPCM event testing");
Now after 6 years, when i come across this forum while searching SDN.
The problem here was that JspDynpage URN is urn:com.EPCMEvent
WebDynpro subscription urn is urn:com.sap.EPCMEvent"
They are not matching(see the .sap added in WebDynpro URN ).
This was the reason why the event was not triggering.
I have edited this just for the sake of the people who come across this forum with simillar problem.
User | Count |
---|---|
86 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.