Foros de discusión

Bridge impl 4.0.1 causes illegal argument exception

Micael Ericsson, modificado hace 7 años.

Bridge impl 4.0.1 causes illegal argument exception

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
Our portlets are running on Liferay 6.2. We would like to move our liferay faces from 4.2.5-ga6 to their new artifact id and version numbers. These are the new dependencies:
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.alloy</artifactId>
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.bridge.api</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.bridge.impl</artifactId>
<version>4.0.1-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.util</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>com.liferay.faces.portal</artifactId>
<version>2.0.0</version>
</dependency>


Upon running portlets with new dependecies IllegalArgumentException is thrown. Debugging class BridgeURLActionImpl I found problem at row 205:
// According to the Bridge Spec, the "javax.portlet.faces.PortletMode"" parameter must not be
// "carried forward to the generated reference." According to a clarification in the Portlet 3.0
// JavaDoc for BaseURL#setProperty(String,String), setting the parameter to null will remove it.
portletURL.setParameter(Bridge.PORTLET_MODE_PARAMETER, (String) null);

Via Git I examined https://github.com/liferay/liferay-portal/blob/6.2.x/portal-impl/src/com/liferay/portlet/PortletURLImpl.java
@Override
public void setParameter(String name, String value, boolean append) {
if ((name == null) || (value == null)) {
throw new IllegalArgumentException();
}
setParameter(name, new String[] {value}, append);
}

In master branch the same method has the following code:
public void setParameter(String name, String value, boolean append) {
if (name == null) {
throw new IllegalArgumentException();
}
if (value == null) {
removeParameter(name);
return;
}
setParameter(name, new String[] {value}, append);
}

According to Liferay version scheme com.liferay.faces.bridge.impl version 4.x should work with Liferay 6.2, but I don't get it to work.

Am I missing something or is this a bug in BridgeURLActionImpl/PortletURLImpl.java combination?
I have tried with 4.0.1-SNAPSHOT of bridge impl. When looking at 4.x version in Git it has the same problem.
thumbnail
Neil Griffin, modificado hace 7 años.

RE: Bridge impl 4.0.1 causes illegal argument exception

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

You might be missing this dependency:
<dependency>
        <groupid>com.liferay.faces</groupid>
        <artifactid>com.liferay.faces.bridge.ext</artifactid>
        <version>3.0.0</version>
    </dependency>


If you visit www.liferayfaces.org there is a new portlet on the home page that will help you choose the correct dependencies for your Liferay + JSF configuration.

Kind Regards,

Neil
Micael Ericsson, modificado hace 7 años.

RE: Bridge impl 4.0.1 causes illegal argument exception

Regular Member Mensajes: 169 Fecha de incorporación: 11/12/12 Mensajes recientes
I include bridge ext and followed version guide line (replaced jsf-api and jsf-impl with javax.faces and javax.faces.api).

Now everything is running as expected with a first test. It looks promising.

The friendly urls are almost there. We have a p_auth tag that needs to be excluded.
Current friendly url mapping:
<route>
<pattern>/ansokan</pattern>
<implicit-parameter name="_facesViewIdRender">/views/ansokan.xhtml</implicit-parameter>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
<ignored-parameter>p_auth</ignored-parameter>
</route>

With first 2 implicit parameter friendly url works except that p_auth is shown. Ignoring or excluding p_auth doesn't work. Should it be possible to exclude p_auth from friendly url?
thumbnail
Kyle Joseph Stiemann, modificado hace 7 años.

RE: Bridge impl 4.0.1 causes illegal argument exception

Liferay Master Mensajes: 760 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Micael,
The p_auth parameter can be removed, but since it protects your portlet from Cross-Site Request Forgery (CSRF), you may not want to do that. Instead it'd probably be better to do something like this:

<route>
<pattern>/ansokan/{p_auth}</pattern>
<implicit-parameter name="_facesViewIdRender">/views/ansokan.xhtml</implicit-parameter>
<implicit-parameter name="p_p_lifecycle">1</implicit-parameter>
</route>


However, if you're sure that you want to remove the paramter, Liferay does give you the option of disabling it. But the p_auth parameter cannot be removed or suppressed using friendly URL features. Instead you need to disable it via portal properties or an init-param. If you are sure you want to remove the parameter, I'd recommend disabling it only for your portlet via an init-param in your portlet.xml:

<init-param>
<name>check-auth-token</name>
<value>false</value>
</init-param>


- Kyle
thumbnail
Juan Gonzalez, modificado hace 7 años.

Moved to Liferay Faces category

Liferay Legend Mensajes: 3089 Fecha de incorporación: 28/10/08 Mensajes recientes
Moved to Liferay Faces category