Fórum

Solution to deploy portlet with RichFaces A4J on 6.1

thumbnail
Leo Pratlong, modificado 12 Anos atrás.

Solution to deploy portlet with RichFaces A4J on 6.1

Expert Postagens: 363 Data de Entrada: 06/07/10 Postagens Recentes
Hi,

I tried to deploy JSF portlets which use Ajax4Jsf library from RichFaces.
There was a problem on a A4J filter deployment: A4J try to read the web.xml after the deploy. So we need to read this filter before Liferay filters.
The problem was also that Liferay 6.1 rewrite the web.xml and a file called liferay-web.xml (which contains all the third party filters).

Here is a way to make your portlet working with Liferay 6.1 (trunk) if you are confronted to my problem:

1) Create a plugin Ext and override com.liferay.portal.tools.deploy.BaseDeployer (check this patch. I put the code above too because of possible changes on the trunk):
Patch:
--- a/portal-impl/src/com/liferay/portal/tools/deploy/BaseDeployer.java
+++ b/portal-impl/src/com/liferay/portal/tools/deploy/BaseDeployer.java
@@ -1095,9 +1095,21 @@ public class BaseDeployer implements Deployer {
                }
        }
 
-       public String getInvokerFilterContent() {
+       public String getInvokerFilterContent(final File srcFile) throws IOException {
                StringBundler sb = new StringBundler(4);
-
+               
+               /**
+         * EXT: Allow to write some filters which need to be load before those of Liferay.
+         */
+        File filtersToLoad = new File(srcFile + "/WEB-INF/web-filters-to-load.xml");
+        if (filtersToLoad.exists()) {
+            sb.append(FileUtil.read(filtersToLoad));
+            filtersToLoad.delete();
+        }
+        /**
+         * 
+         */
+               
                sb.append(getInvokerFilterContent("ERROR"));
                sb.append(getInvokerFilterContent("FORWARD"));
                sb.append(getInvokerFilterContent("INCLUDE"));[code]

@@ -1108,7 +1120,7 @@ public class BaseDeployer implements Deployer {

public String getInvokerFilterContent(String dispatcher) {
StringBundler sb = new StringBundler(23);
-
+
sb.append("<filter>");
sb.append("<filter-name>Invoker Filter - ");
sb.append(dispatcher);
@@ -1706,7 +1718,7 @@ public class BaseDeployer implements Deployer {
srcFile + "/WEB-INF/liferay-web.xml", liferayWebXmlContent);

webXmlContent =
- webXmlContent.substring(0, x) + getInvokerFilterContent() +
+ webXmlContent.substring(0, x) + getInvokerFilterContent(srcFile) +
webXmlContent.substring(y + 17);

return webXmlContent;

Code description:
- Redefine the method getInvokerFilterContent() :
public String getInvokerFilterContent(final File srcFile) throws IOException


- Add this bloc after the StringBuilder declaration:
/**
         * EXT: Allow to write some filters which need to be load before those of Liferay.
         */
        File filtersToLoad = new File(srcFile + "/WEB-INF/web-filters-to-load.xml");
        if (filtersToLoad.exists()) {
            sb.append(FileUtil.read(filtersToLoad));
            filtersToLoad.delete();
        }
        /**
         * 
         */


- on the method updateLiferayWebXml(File srcFile, String webXmlContent), update the getInvoker... calling line:
webXmlContent =
			webXmlContent.substring(0, x) + getInvokerFilterContent(srcFile) +
				webXmlContent.substring(y + 17);



2) Add a new file on the WEB-INF folder of your portlet, called web-filters-to-load.xml .
3) Put in this new file (no header are needed) the specific filters you want to load first. Delete those filters from your web.xml.
4) Deploy: the web.xml now contains your filters and the web-filters-to-load.xml is deleted.

Thanks to Raymond Augé for his help to identify my problem and for his suggestions!
thumbnail
David H Nebinger, modificado 12 Anos atrás.

RE: Solution to deploy portlet with RichFaces A4J on 6.1

Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
Great writeup! Thanks for sharing!
Jose Miguel Loor, modificado 12 Anos atrás.

RE: Solution to deploy portlet with RichFaces A4J on 6.1

New Member Postagens: 3 Data de Entrada: 13/12/11 Postagens Recentes
Hi

I have stumbled upon the same problem with liferay 6.0.12, but the problem is that the class com.liferay.portal.tools.deploy.BaseDeployer doesn't have any of the methods you suggested changing

can you help me with this ??

thanks
thumbnail
Mika Koivisto, modificado 12 Anos atrás.

RE: Solution to deploy portlet with RichFaces A4J on 6.1

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
You can disable moving filters to liferay-web.xml in plugins by setting liferay-web-xml-enabled=false in liferay-plugin-package.properties. This however also makes some of the Liferay filters injected to not work correctly because they rely on features like regex mapping provided by Invoker Filter. So I would recommend disabling those filters as well. So here's what you should put in your liferay-plugin-package.properties

liferay-web-xml-enabled=false
speed-filters-enabled=false


If you can't live without those filters then you can add them manually to liferay-web.xml and the Invoker Filter in your web.xml in your plugin and they will still work. They just won't be injected automatically.