Foros de discusión

Friendly URL shows previous page

Micael Ericsson, modificado hace 7 años.

Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
I recently discovered that friendly urls is pointing to previous page for our portlet pages .
We are running: Liferay 6.2 with JSF 2.2.
Each portlet is a wizard with 3 or more (xhtml)pages . Friendly url are configured in portlets xxx-friendly-url-routes.xml.
When running:
- First page in wizard shows no friendly url.
- Second page shows first page friendly url and so on.

If I remove friendly url settings and look at the url for second page it has a facesViewIdRender param with the value of first page. This explains why wrong friendly urls is shown.

But why does facesViewIdRender has the value of previous page?

This has been working before, but in latest release we upgraded to latest liferay third party jars and a couple of more changes. Hard to guess what affected friendly url.
thumbnail
Neil Griffin, modificado hace 7 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,

Thanks for reporting this issue. Please let us know the exact versions of the Liferay Faces jars that you are using in your portlet. Maybe you could provide a listing of all your jars under tomcat/webapps/your-portlet/WEB-INF/lib.

Neil
Micael Ericsson, modificado hace 7 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Attached file are jars for current portlet.

Archivos adjuntos:

thumbnail
Neil Griffin, modificado hace 7 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,

Do you have some custom modifications to the bridge implementation jar? I noticed the filename is com.liferay.faces.bridge.impl-4.0.1-TRM.jar

Also, can you provide us with an SSCCE portlet so that we can reproduce the issue?

Thanks,

Neil
Micael Ericsson, modificado hace 7 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Neil Griffin:
Hi Micael,

Do you have some custom modifications to the bridge implementation jar? I noticed the filename is com.liferay.faces.bridge.impl-4.0.1-TRM.jar

Also, can you provide us with an SSCCE portlet so that we can reproduce the issue?

Thanks,

Neil


com.liferay.faces.bridge.impl-4.0.1-TRM.jar is based on SNAPSHOT version of the same. At some point we encountered a problem with the latest SNAPSHOT release so we stayed with an older working version which we labeled TRM.

I hope I'll have the time to setup a SSCCE portlet. I'll will get back as soon as possible.
Micael Ericsson, modificado hace 7 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Hi Neil

Sorry for the delay, but here come a TestPortlet where friendly url is one step wrong.
Attached zip-file contains root pom for building. If there is a build problem I also included the built war-file and a theme for better lookemoticon.
Supplied image shows testPortletPage1.xhtml with friendly url /intro, which obviously is not what it should be.

Regards,
Micael

Archivos adjuntos:

thumbnail
Neil Griffin, modificado hace 7 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,

I tried to build the TestPortlet project that you attached, but BaseController.java and WebUtils.java can't find the following imports:
import se.trm.security.principal.AttributePrincipal;
import se.trm.security.principal.PrincipalSecurityContext;
import se.trm.security.principal.PrincipalSecurityContextHolder;


Is there another dependency that is needed?

Thanks,

Neil
Micael Ericsson, modificado hace 7 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Neil Griffin:
Hi Micael,

I tried to build the TestPortlet project that you attached, but BaseController.java and WebUtils.java can't find the following imports:
import se.trm.security.principal.AttributePrincipal;
import se.trm.security.principal.PrincipalSecurityContext;
import se.trm.security.principal.PrincipalSecurityContextHolder;


Is there another dependency that is needed?

Thanks,

Neil


Hi

No extra dependency. These are security file placed, for some reason, in Java dir. Totally forgot about these.
I built a new version of the portlet where I removed these dependencies.

/Micke

Archivos adjuntos:

Micael Ericsson, modificado hace 7 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Hi Neil

Is my supplied project working?

I have a another question which can be tested with the same project. I am using NetBeans version 8.2 and for some time Code Completion has stopped working. After some testing I could pinpoint it down to pom.xml and actually a Liferay dependency.
	<dependency>
			<groupid>com.liferay.faces</groupid>
			<artifactid>com.liferay.faces.alloy</artifactid>
		</dependency>

With the above dependency Code Completion is not working. Witout it Code Completion is working. Rather strange I would say. Do you have explanation or even better a solution?

Regards,
Micael
thumbnail
Neil Griffin, modificado hace 7 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,

Apologies, somehow I missed that you attached a new version of TestPortlet.zip

I just tried to build it and although the problem with WebbUtils.java is gone, BaseController.java still has compile failures due to the aforementioned missing classes.

Regarding the NetBeans problem, I think you might be running into FACES-2966 which is fixed in our latest -SNAPSHOTs.

Neil
Micael Ericsson, modificado hace 7 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Hi Neil

New version included. Now I did what I should done first time - searched and removed all security reference.

Regards,
Micael

Archivos adjuntos:

thumbnail
Neil Griffin, modificado hace 6 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,

I tried to deploy the portlet but there is another problem.

Specifically, testPortletTemplate.xhtml has this markup:
	<f:metadata>
		<f:event type="preRenderView" listener="#{testPortletController.initPage}" />
	</f:metadata>

Which invokes BaseController.initPage() and throws a NullPointerException here:
		if (!FacesContext.getCurrentInstance().isPostback()) {


Here is the stacktrace:
java.lang.NullPointerException
at se.trm.web.util.BaseController.initPage(BaseController.java:100)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:328)
at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:341)
at org.jboss.el.parser.AstPropertySuffix.invoke(AstPropertySuffix.java:58)
at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at com.sun.faces.facelets.tag.jsf.core.DeclarativeSystemEventListener.processEvent(EventHandler.java:128)
at javax.faces.component.UIComponent$ComponentSystemEventListenerAdapter.processEvent(UIComponent.java:2584)
at javax.faces.event.SystemEvent.processListener(SystemEvent.java:108)
at javax.faces.event.ComponentSystemEvent.processListener(ComponentSystemEvent.java:118)
at com.sun.faces.application.ApplicationImpl.processListeners(ApplicationImpl.java:2187)
at com.sun.faces.application.ApplicationImpl.invokeComponentListenersFor(ApplicationImpl.java:2135)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:289)
at com.sun.faces.application.ApplicationImpl.publishEvent(ApplicationImpl.java:247)
at javax.faces.application.ApplicationWrapper.publishEvent(ApplicationWrapper.java:726)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:107)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
at com.liferay.faces.bridge.internal.BridgePhaseHeaderRenderCommon.executeRender(BridgePhaseHeaderRenderCommon.java:191)

Note that I upgraded to the latest -SNAPSHOT versions of our dependencies in order to help me diagnose any problems in our latest source:
<!-- Liferay faces -->
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.alloy</artifactId>
<version>3.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.bridge.api</artifactId>
<version>4.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.bridge.impl</artifactId>
<version>4.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.bridge.ext</artifactId>
<version>3.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.util</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.portal</artifactId>
<version>2.0.1-SNAPSHOT</version>
</dependency>

Are you seeing this problem in your environment?

Thank you,

Neil
Micael Ericsson, modificado hace 6 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Hi Neil

I don't have this problem in my environment. But I made a couple of changes to the code and hopefully it will work in your environment. This is the problem when I try to break out a portlet with lots of connections to a self service portlet.

Included is the new project.

Regards,
Micael

Archivos adjuntos:

Micael Ericsson, modificado hace 6 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Hi Neil

Have you had time to test my latest uploaded project?

Regards,
Micael
thumbnail
Neil Griffin, modificado hace 6 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,

I had time today to try the latest version of your portlet.

It is not working with our latest SNAPSHOT jars for two reasons:

1. The project did not contain src/main/resources/msgs.properties
(I fixed that locally in order to keep moving forward)

2. We might have a regression with FACES-2921. That's probably what com.liferay.faces.bridge.impl-4.0.1-TRM.jar is for. I've asked Kyle Stiemann to take a look at it. If this is indeed a regression, then after Kyle provides a fix then I will be able to continue trying to reproduce the issue.

Kind Regards,

Neil
thumbnail
Neil Griffin, modificado hace 6 años.

RE: Friendly URL shows previous page

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Micael,
Just wanted to let you know that we were able to get your test portlet to render in our environment. Kyle is currently investigating the friendly URL problem.
Kind Regards,
Neil
thumbnail
Kyle Joseph Stiemann, modificado hace 6 años.

RE: Friendly URL shows previous page

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Micael,
The URL that appears in the browser's URL bar is a portlet action URL rendered in the form's action parameter. This URL contains the faces view id of the initially rendered view (as the value of the facesViewIdRender) so that the view can be restored by JSF during the RESTORE_VIEW phase. Since the action URL is rendered during the initial GET request for the view (long before the navigation outcome is chosen), there is no way for it to contain the view id of the navigation case outcome. On top of that, as you may have noticed, the action URL always contains the p_auth token to prevent Cross Site Request Forgery .

To get a friendly URL to appear in the browser without the p_auth parameter and with the correct view, you need to perform a POST-REDIRECT-GET instead of a POST during action navigation. Executing a POST-REDIRECT-GET will cause a friendly render URL to appear instead of a friendly action URL once navigation completes. In your portlet, all you need to do is add "?faces-redirect=true" to the outcome of each navigation case and change your testportlet-friendly-url-routes.xml file to map render URLs (<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>) instead of action URLs (<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>). I've attached a patch file which can do this for your example portlet:

patch -p1 < ~/Downloads/redirect-patch.diff

- Kyle

Archivos adjuntos:

Micael Ericsson, modificado hace 6 años.

RE: Friendly URL shows previous page

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Hi Kyle

Thank you for the explanation and possible solution to the problem.

Previous we had the "?faces-redirect=true" on outcome urls, but that was mostly because of another bug which now is fixed. The "?faces-redirect=true" caused alot of other problems for us, mostly regarding redirect and our error management.

Is there another way to fix our friendly url problem?
Is it standard praxis to have "?faces-redirect=true" on all outcome?

Regards,
Micael
thumbnail
Kyle Joseph Stiemann, modificado hace 6 años.

RE: Friendly URL shows previous page

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Micael,

Is there another way to fix our friendly url problem?

I don't think so.

Is it standard praxis to have "?faces-redirect=true" on all outcome?

Not necessarily, but if you want friendly, bookmarkable URLs, you'll need to use ?faces-redirect=true to perform a POST-REDIRECT-GET to ensure that the final URL that appears is a render URL.

Previous we had the "?faces-redirect=true" on outcome urls, but that was mostly because of another bug which now is fixed. The "?faces-redirect=true" caused alot of other problems for us, mostly regarding redirect and our error management.

Could you describe those bugs here? Maybe we can help you resolve them.

- Kyle