Fórumok

Moving from one portlet to another

Francis Zabala, módosítva 11 év-val korábban

Moving from one portlet to another

New Member Bejegyzések: 13 Csatlakozás dátuma: 2012.02.01. Legújabb bejegyzések
Hello, I would like to apologize in advance as I am currently frustrated right now in Liferay portal development and might have sarcastic remarks.

Anyway, here we go. I currently have 2 portlets, formPortlet and welcomePortlet. formPortlet does not extend MVCPortlet and currently has 2 methods, renderForm and processAction. The jsps for the formPortlet is a form that accepts data entered by the user. Here's what's going on, after clicking on the submit button of the form, (action value of form is <portlet:actionURL/>), it goes onto executing processAction and redisplays the same form. The data is saved though so no worries about that. I can't seem to get it move forward to the welcomePortlet.

I tried this actionResponse.sendRedirect("welcome/view.jsp") but I only get this error:

java.lang.IllegalArgumentException: myrewards is not a valid redirect.

I have been trying to move the user from formPorlet to welcomePortlet for hours now but I am really stuck. Can anyone please help me?

Regards,
Francis
thumbnail
Priyanka Dhingra, módosítva 11 év-val korábban

RE: Moving from one portlet to another

Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
Hi,
I dont think so this is possible like this.
You need to use Inter Portlet Communication for this

Regards
Priyanka
Francis Zabala, módosítva 11 év-val korábban

RE: Moving from one portlet to another

New Member Bejegyzések: 13 Csatlakozás dátuma: 2012.02.01. Legújabb bejegyzések
Hi Priyanka,

For some reason, I am not surprised by that. Probably just create a javascript way of redirecting instead. I am planning to make a jsp where it will redirect the user to the welcomePortlet page automatically. Oh man, it has bad design all over it though...

Regards,
Francis
Francis Zabala, módosítva 11 év-val korábban

RE: Moving from one portlet to another

New Member Bejegyzések: 13 Csatlakozás dátuma: 2012.02.01. Legújabb bejegyzések
Wait, do IPC work only when the two portlets are on the same page?
thumbnail
Priyanka Dhingra, módosítva 11 év-val korábban

RE: Moving from one portlet to another

Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
Hi,
i got it that you wanna use javascript for redirection..but tell me one thing how will you access the values of the form without giving it to the event qname????

you cannot go to some entirely separate web application in general and pass some variables to it just using javascript.
Please correct me if i am wrong
Regards
Priyanka
thumbnail
aryan sahu, módosítva 11 év-val korábban

RE: Moving from one portlet to another

Junior Member Bejegyzések: 54 Csatlakozás dátuma: 2012.04.07. Legújabb bejegyzések
hello francis,
you have to provide the absolute URL (e.g. http://my.co/myportal/mywebap/myfolder/myresource.gif) or a full path URI (e.g. /myportal/mywebap/myfolder/myresource.gif).
In your case providing relative url throws java.lang.IllegalArgumentException.
Also take care you havent set any of these before redirection
setPortletMode
setWindowState
setRenderParameter
setRenderParameters
removePublicRenderParamter. hope this helpsemoticon
thumbnail
Jitendra Rajput, módosítva 11 év-val korábban

RE: Moving from one portlet to another

Liferay Master Bejegyzések: 875 Csatlakozás dátuma: 2011.01.07. Legújabb bejegyzések
I think you can redirect from one portlet to another portlet using different Liferay API.

Here is one example that i can suggest you .

First get layout object where your welcome portlet is deployed.



 Layout layout = LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(),
                    isPrivatePage, "/pageName");



isPrivatePage - If your page is private then pass it as true other wise false.
"/pageName" - Friendly URL of page where portlet is placed.

Once you get this layout object then you can try by using below snippet.


LiferayPortletURL portletURL = PortletURLFactoryUtil.create(PortalUtil .getHttpServletRequest(renderRequest), PORTLET_NAME, layout .getPlid(), PortletRequest.RENDER_PHASE);
portletURL.setWindowState(LiferayWindowState.NORMAL);
portletURL.setPortletMode(PortletMode.VIEW);


PortletRequest.RENDER_PHASE - Pass this as argument if you want to call Render Method .
PortletRequest.ACTION_PHASE - Pass this as a last argument if you want to call any action before render method.


Once you have this portletURL then at the end of your processAction method write this line.

actionResponse.sendRedirect(portletURL );


If you want to generate URL in some what different manner then follow this thread.
Francis Zabala, módosítva 11 év-val korábban

RE: Moving from one portlet to another

New Member Bejegyzések: 13 Csatlakozás dátuma: 2012.02.01. Legújabb bejegyzések
Hi Jitendra Rajput,

Sorry for the late reply but we are short on time to try out your advice. I'll try it once our schedule relaxes.

To future viewers:

I didn't know that once processAction or any method doing a processAction type of action, after it's done, renderForm is next to be executed. That is the reason why I can't forward to another page as it keeps rendering the initial view.jsp.

I didn't realize that I will have to create an if else or switch statement to determine which jsps to display based on the result of the processAction. I was under the impression that if I have one method, that is only what it will execute.

In any case of the future viewers need questions, can we not let this thread be a zombie thread? This issue is too silly to be a show stopper during your development.
Francis Zabala, módosítva 11 év-val korábban

RE: Moving from one portlet to another

New Member Bejegyzések: 13 Csatlakozás dátuma: 2012.02.01. Legújabb bejegyzések
Priyanka Dhingra:
Hi,
i got it that you wanna use javascript for redirection..but tell me one thing how will you access the values of the form without giving it to the event qname????

you cannot go to some entirely separate web application in general and pass some variables to it just using javascript.
Please correct me if i am wrong
Regards
Priyanka


Hi Priyanka,

I think you got my scenario wrong.

Here's what's going on.

User fills out the form -> Clicks on the submit button.
What I want is that after the user clicks on the submit button, the users gets redirected to the Welcome Page/Portlet. I will not pass anything or any value from the form to the welcome portlet. What happens is that it just keeps displaying the form again. The data is saved, but it is just silly that if a user presses the submit button, the user should at least see a different screen.