cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript code to redirect window

justin_kemp
Participant
0 Kudos

Hi,

I am developing a PAR file (containing a JSP) which I want to redirect to some other page with some parameters at the time of loading of iview. These parameters I am able to get correctly from a Java Bean. Now I am in need of code to redirect the iview (from this par). My current code is like this:

<%@ page import="java.util.ResourceBundle"%>

<%@ taglib uri="htmlb" prefix="hbj" %>

<jsp:useBean id="data" scope="request" class="com.sap.pct.fin.cad.test" />

<jsp:useBean id="cKey" scope="request" class="com.sap.pct.fin.cad.test.CKey" />

<hbj:content id="myContext" >

<hbj:page>

<%= cKey.getJavaScriptForURLCaller() %>

<% ResourceBundle rb = componentRequest.getResourceBundle(); %>

<hbj:form>

<%= cKey.getHiddenFormField() %>

<%= cKey.getJavaScriptForEventReceiver(componentRequest, myContext.getCurrentFormId()) %>

<hbj:textView text="<%=data.getEV_ID()%>" design="HEADER3"/>

</hbj:form>

</hbj:page>

</hbj:content>

Now i want to pass this EV_ID at runtime to some other URL like

http://sdn.sap.com?ABC=data.getEV_ID()

I tried using window.location but no use. Any inputs are welcome.

regards,

Justin

Accepted Solutions (0)

Answers (1)

Answers (1)

harman_shahi
Contributor
0 Kudos

Hi Justin,

You may be able to use JSP for redirection:

javax.servlet.http.HttpServletResponse res = request.getServletResponse(false);
res.sendRedirect(“<your URL here>”);

If you want to use JavaScript, then try the following:

location.href = 'http://www.google.com';

or

document.location.href = 'http://www.google.com';

Hope this helps,

harman

justin_kemp
Participant
0 Kudos

Thanks for the reply Harman,

I tried adding your code but that gives an error "Error occurs during the rendering of jsp component."

Can u provide the same for HTMLB or hbj , or if you can let me know where exactly I shoudl add that code snippet.

praveenkumar_gudapati
Active Contributor
0 Kudos

Hi,

If you just want to redirect away to some other URL, then why are you using HTMLB at all??

You say, I want to redirect while my IView is loading.

This means you want to just calculate some thing in your IView's component and then redirect the request to some URL. So for this usecase you dont require any HTMLB User Interface at all !!

So I think you are missing some thing here in your usecase!!

Regards,

Praveen Gudapati

justin_kemp
Participant
0 Kudos

Hello Praveen,

I am using HTMLB to get parameters from some other events being triggered. After taking these parameters I am suppose to pass this parameters in some URL

Now as soon as the parameters come, I want the URL to be redirected. I used window.location it is working as well but it is changing the complete window and i want only the iview to be loaded again.

Hope I am clear in explaining my requirement.

regards

Justin

praveenkumar_gudapati
Active Contributor
0 Kudos

Hi,

If Events are triggered and you want to to redirect on this event occurance then you should implement the appropriate methods in you JSPDynPage and there you should call this redirect method.

Check this for more:

http://help.sap.com/saphelp_nw70/helpdata/EN/2e/d2a441cd47a209e10000000a155106/frameset.htm

Regards,

Praveen Gudapati

harman_shahi
Contributor
0 Kudos

Catching the event and redirecting would be the best way to do this, but If you want to use Javascript then try one of the follwoing:

1)

self.location.href = url

AND

2)

Make sure you set the "Isolation Method" property of the iView to "URL". This is a must if you only want to reload the iView and not reload the entire window...

hope this helps.

harman