Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
sarabjeet singh
How to redirect using " sendredirect " in processaction
30 giugno 2011 22.21
Risposta

sarabjeet singh

Punteggio: New Member

Messaggi: 15

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Hi guys,
Here is my code through which i m trying to redirect to another portlet(Portlet 2) in process action of Portlet1.But i dont know what parameters should i put in th "sendredirect" function .Can someone please help me !I

public void processAction(ActionRequest actionRequest, ActionResponse actionResponse)throws IOException, PortletException
{
//do some task and then redirect to portlet2
actionResponse.sendRedirect(/html/portlet2/view.jsp);
}
Error:portlet2 cannot be resolved to variable.
manasa chandri
RE: How to redirect using " sendredirect " in processaction
30 giugno 2011 22.45
Risposta

manasa chandri

Punteggio: Regular Member

Messaggi: 152

Data di Iscrizione: 27 settembre 2010

Messaggi recenti

Hi sarabjeet singh,

where you are developing sendredirect, ext portlet or plugin portlet?



Thanks & Regards
Manasa.chandri
devi nimmagadda
RE: How to redirect using " sendredirect " in processaction
30 giugno 2011 22.50
Risposta

devi nimmagadda

Punteggio: Regular Member

Messaggi: 109

Data di Iscrizione: 9 dicembre 2010

Messaggi recenti

Hi,

try this.


The sendRedirect(String location, String renderUrlParamName) method
instructs the portal/portlet-container to set the appropriate headers and content body to
redirect the user to a different URL. A fully qualified URL or a full path URL must be
specified. If a relative path URL is given, an IllegalArgumentException must be
thrown.cviii

The portlet container must attach a render URL with the currently set portlet mode,
window state and render parameters on the ActionResponse and the current public
render parameters. cix The attached URL must be available as query parameter value
under the key provided with the renderUrlParamName parameter. cx
New values for portlet mode, window state, private or public render parameters must be
encoded in the attached render URLcxi, but are not remembered after the redirect is
issued.
sarabjeet singh
RE: How to redirect using " sendredirect " in processaction
1 luglio 2011 3.11
Risposta

sarabjeet singh

Punteggio: New Member

Messaggi: 15

Data di Iscrizione: 17 maggio 2011

Messaggi recenti

Hi devi,

Thanks for the reply....but i m really new to portlet development....can u please give me a piece of working code where user has been sucessfully redirected to some other portlet on the same portlet window after he clicks the submit button of a form...would be really helpful...

and
Manasa i m using plugin portlets for development.
manasa chandri
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 21.21
Risposta

manasa chandri

Punteggio: Regular Member

Messaggi: 152

Data di Iscrizione: 27 settembre 2010

Messaggi recenti

Hi sarabjeet singh,

In Plugin portlet sendRedirect to portlet is not comming, i also tried that one, but it is not comming,

sample code:


HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(res);
httpResponse.sendRedirect(redirect);




Thanks & Regards
Manasa.chandri
Jignesh Thakkar
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 21.41
Risposta

Jignesh Thakkar

Punteggio: New Member

Messaggi: 24

Data di Iscrizione: 9 maggio 2010

Messaggi recenti

Hi sarabjeet singh,

You can not redirect to any jsp of any other portlet2 using relative path from your portlet. You have yo use an alternate way to do this.

1) To redirect to the other jsp of the same portlet
2) Redirect to an URL of the Liferay Page on which your put your portlet2 and Writedown your custom code in render method of portlet2. It will work.

For e.g. Suppose you have 2 pages in one LR community say page1 and page2, on page1 you had put your portlet1 and on page2 you had put on portlet2. Now from page1 after doing some action, if you want to redirect to portlet2 then you have to write your code on your processaction like this

actionResponse.sendRedirect(themeDisplay.getPortalURL() + "/web/ + themeDisplay.getScopeGroup().getGroupName() + "/page2") even you can give the url as a hardcod value.

It will redirect request to render method of portlet2. Now do whatever stuff you want to do with portlet2, you have to do it in render method. and then redirect to jsp page of that portlet.

let me know if you need more information
manasa chandri
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 22.09
Risposta

manasa chandri

Punteggio: Regular Member

Messaggi: 152

Data di Iscrizione: 27 settembre 2010

Messaggi recenti

Hi,


In plugin portlet actionRequest and actionResponse will not come, only httpresponse and httprequest will come.
creating action class in struts plugin portlet is

public class Sample extends Action{


public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

// coding of our integration logic here...

return super.execute(mapping, form, request, response);
}
}

give me suggestion.


Thanks & Regards
Manasa.chandri
Jignesh Thakkar
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 22.26
Risposta

Jignesh Thakkar

Punteggio: New Member

Messaggi: 24

Data di Iscrizione: 9 maggio 2010

Messaggi recenti

Hi

Then you can redirect using httpServletResponse like this

response.sendRedirect("URL");
devi nimmagadda
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 22.36
Risposta

devi nimmagadda

Punteggio: Regular Member

Messaggi: 109

Data di Iscrizione: 9 dicembre 2010

Messaggi recenti

hi,

but HttpServletResponse , sendRedirect is not working. that is the problem we r facing..........


thanks for ur reply..
Jignesh Thakkar
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 22.43
Risposta

Jignesh Thakkar

Punteggio: New Member

Messaggi: 24

Data di Iscrizione: 9 maggio 2010

Messaggi recenti

Hi

Are you redirecting to an URL or any jsp file of other portlet?

Are you redirecting from render method or action method?

If you are redirecting from render method, it will not work, But if you are redirecting from action method it will work...
devi nimmagadda
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 22.50
Risposta

devi nimmagadda

Punteggio: Regular Member

Messaggi: 109

Data di Iscrizione: 9 dicembre 2010

Messaggi recenti

Hi,

In plugin portlet only one method is present that is execute () code below.


public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

return xxx;
}

this is the procedure for plugin portlet. I am redirecting url ..

Thanks for your reply...
Jignesh Thakkar
RE: How to redirect using " sendredirect " in processaction
3 luglio 2011 22.56
Risposta

Jignesh Thakkar

Punteggio: New Member

Messaggi: 24

Data di Iscrizione: 9 maggio 2010

Messaggi recenti

Hi

Now i got the thing why you are not able to redirect because you are using struts portlet.

So here you can do an alternative to redirect. on the basis of some condition, you can return mapping.findfarward("failure") or mapping.findforward("success") and based on that you can redirect to failure or success.jsp respectively.

And when you request reach to jsp, you can write below code in it.

<script type="text/javascript">
window.location.replace("YOUR LIFERAY PAGE URL");
</script>

I have done the same thing in my code and its working for me.

So try this and let me know still you face any problem.