掲示板

JSF managed property commandLink problem

7年前 に Micael Ericsson によって更新されました。

JSF managed property commandLink problem

Regular Member 投稿: 169 参加年月日: 12/12/11 最新の投稿
In my current JSF portlet I wish to add cache of some data. One approach is to create a bean with application scope to store cache data and access that from view scoped bean via managed property. This was setup according to https://www.mkyong.com/jsf2/injecting-managed-beans-in-jsf-2-0/ without any problem. The application scoped bean retrieves and caches data properly.

But now I have a problem with my h:commandLink navigation. From my start page I use the following code (with in h:from) to load next pages portlet with data.
<h:commandLink action="#{valjUppdragController.submitUppdrag}"
value="Load #{uppdrag.namn}">
<f:setPropertyActionListener target="#{valjUppdragController.uid}" value="#{uppdrag.id}" />
<f:setPropertyActionListener target="#{valjUppdragController.ansokanUrl}" value="#{uppdrag.ansokanUrl}" />
<f:param name="uppdragId" value="#{uppdrag.id}" />
</h:commandLink>

Links based on this code doesn't call action method in controller class and thus next page is not loaded.
Removing managed property and everything works again.

In what way does managed property effect form/links? and which is the proper way to solve this?
thumbnail
7年前 に Vernon Singleton によって更新されました。

RE: JSF managed property commandLink problem

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
Hi Micael,

Micael Ericsson:
Links based on this code doesn't call action method in controller class and thus next page is not loaded.
Removing managed property and everything works again.

In what way does managed property effect form/links? and which is the proper way to solve this?

Hmm ... does this working example approximate what you are trying to do?

In any case, if that example does not help, you will need to attach a short self-contained example demonstrating this issue. Looking forward to helping you with this. Let us know what you find.

- Vernon
7年前 に Micael Ericsson によって更新されました。

RE: JSF managed property commandLink problem

Regular Member 投稿: 169 参加年月日: 12/12/11 最新の投稿
Hi Vernon

"this working example" does what I need to do. Is it possible to get the complete example to verify WEB-INF settings and code against my portlet?

My portlet is not a self-contained example at the moment. I'll try to put this together soon.

Any ideas why adding "managed property" to my portlet stopped h:commandLink from working or suggestions what to try?
I tried different setup of h:commandLink but nothing that helped me.

/Micael
thumbnail
7年前 に Vernon Singleton によって更新されました。

RE: JSF managed property commandLink problem

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
Hi Micael,
Micael Ericsson:
"this working example" does what I need to do. Is it possible to get the complete example to verify WEB-INF settings and code against my portlet?

The web application that is used for that example can be found here.
Micael Ericsson:
Any ideas why adding "managed property" to my portlet stopped h:commandLink from working or suggestions what to try?
I tried different setup of h:commandLink but nothing that helped me.

Did you notice the CommandBackingBean.java in the working example? It has a managed property which is the model bean. I am not sure if that matches the way you are adding your managed property and how you are using the managed property. It is difficult to guess how you added the managed property, I would need the short, self contained, example.
7年前 に Micael Ericsson によって更新されました。

RE: JSF managed property commandLink problem

Regular Member 投稿: 169 参加年月日: 12/12/11 最新の投稿
Hi Vernon

After examine supplied project and compared to mine I couldn't find any that suggested the difference.
Testing a bir more and this is perhaps not linked to using managed property. More it looks lika a problem with new release of faces bridge-impl.

I development I am using com.liferay.faces.bridge.impl-4.0.1-SNAPSHOT.jar, due to some other bug fixes. The previos working version is from 2016-10-04. When I testad managed property a new version of this Snapshot was released (2016-10-31 or 2016-11-14) and that version cause the problem with non clickable links. Switching to old snapshot version and links worked again.

I will continue to work on this next week, but it would be nice if you could reproduce this behaviour using latest snapshot of bridge impl.

Regards,
Micael (with a 'c').
thumbnail
7年前 に Vernon Singleton によって更新されました。

RE: JSF managed property commandLink problem

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
Hi Micael,

Micael Ericsson:
When I testad managed property a new version of this Snapshot was released (2016-10-31 or 2016-11-14) and that version cause the problem with non clickable links. Switching to old snapshot version and links worked again.

Could you tell us which version of Liferay you are using and which jars you have in the WEB-INF/lib of your portlet war?

Micael Ericsson:
I will continue to work on this next week, but it would be nice if you could reproduce this behaviour using latest snapshot of bridge impl.

I am using the latest com.liferay.faces.bridge.impl-4.0.1-SNAPSHOT and the working example is still working with all of the latest Liferay Faces snapshots.

I also took a few moments to attach a short self-contained example, since you had not found time to do so. This example works with the latest snapshots. It also works with the latest production releases of our jars. The example link is clickable, and works just fine and clicking the link does call the action method in the controller class.

Hope that helps.
7年前 に Micael Ericsson によって更新されました。

RE: JSF managed property commandLink problem

Regular Member 投稿: 169 参加年月日: 12/12/11 最新の投稿
Hi Vernon

Liferay version 6.2 CE GA6
WEb-INF/lib in included image. Jars marked in yellow are our own.

Building supplied project gave me an build error:
Failed to execute goal on project com.mycompany.my.jsf.portlet: Could not resolve dependencies for project com.mycompany:com.mycompany.my.jsf.portlet:war:1.0-SNAPSHOT:
The following artifacts could not be resolved:
com.liferay.faces:com.liferay.faces.bridge.ext:jar:5.0.1-SNAPSHOT,
com.liferay.faces:com.liferay.faces.bridge.impl:jar:4.0.1-SNAPSHOT,
com.liferay.faces:com.liferay.faces.portal:jar:3.0.1-SNAPSHOT,
com.liferay.faces:com.liferay.faces.util:jar:3.0.1-SNAPSHOT:
Could not find artifact com.liferay.faces:com.liferay.faces.bridge.ext:jar:5.0.1-SNAPSHOT -> [Help 1]

添付ファイル:

thumbnail
7年前 に Vernon Singleton によって更新されました。

RE: JSF managed property commandLink problem

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
Hi Micael,

Micael Ericsson:
Liferay version 6.2 CE GA6

Make sure you are using the dependencies given when you put in your version of Liferay and JSF here.

Micael Ericsson:
WEb-INF/lib in included image. Jars marked in yellow are our own.

If you want to use snapshot versions, you will probably need to build the Liferay Faces jars from source or add the sonatype snapshot repository to your ~/.m2/settings.xml. As I stated previously, the attached example "also works with the latest production releases of our jars", so you do not have to use the snapshot repository if you do not want to, but you do have to use the correct versions of the Liferay Faces jars as shown when selecting your version of Liferay and JSF here.

Micael Ericsson:
Building supplied project gave me an build error:
... Could not find artifact com.liferay.faces:com.liferay.faces.bridge.ext:jar:5.0.1-SNAPSHOT -> [Help 1]

Version 5.x of bridge ext is not correct for Liferay 6.2, so make sure you use the versions instructed for Liferay 6.2 and JSF 2.2.

Hope that helps,
Vernon