留言板

Hooking in Custom JSPs and Language property files

thumbnail
Dave Kliczbor,修改在12 年前。

Hooking in Custom JSPs and Language property files

Junior Member 帖子: 77 加入日期: 11-7-12 最近的帖子
Hello there,

I'm trying to deploy custom language strings with my hook plugin. First, I created some custom JSPs and deployed them via a .war file into LR 6.1 CE. I registered them via the <custom-jsp-dir> element in liferay-hook.xml. Deployed fine and worked. So far, no problem.

The problem arises when I try to insert "multiple" hooks. I want to provide one additional language string. So, I created a folder named "content", inserted a CustomLogin_de.properties with my translated string and (following this documentation) added an <language-properties> element in liferay-hook.xml:
<hook>
	<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
	<language-properties>content/CustomLogin_de.properties</language-properties>
</hook>

On deploying, I get the following error in my log:
Caused by: org.dom4j.DocumentException: Error on line 7 of document  : The content of element type "hook" must match "(portal-properties?,language-properties*,custom-jsp-dir?,custom-jsp-global?,indexer-post-processor*,service*,servlet-filter*,servlet-filter-mapping*,struts-action*)".

Finding the pattern again in portal-impl.jar\com\liferay\portal\definitions\liferay-hook_6_0_0.dtd, I have to assume that the DTD only allows one type of hook in the liferay-hook.xml file.

But how do I deploy hooks of different types in one war file?

Side question: Did I understand it correctly that I can use "MyPluginName_de.properties"? From the docs, I assume that I cannot use "Language_de.properties", as this would overwrite the standard language file. Or does it? (What I actually need would be overwriting the _entries_ instead of the whole file ... if a key exists in my additional file, it should overwrite the key from the standard language file)
thumbnail
Pankaj Kathiriya,修改在12 年前。

RE: Hooking in Custom JSPs and Language property files (答复)

Liferay Master 帖子: 722 加入日期: 10-8-5 最近的帖子
Hi ,
The sequence of tags should be as below.
Language property and Portal property file shoud be defined first and then custom-jsp-dir should be defined.
<hook>
<language-properties>content/CustomLogin_de.properties</language-properties>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
</hook>

And It will work.



Thanks,
Pankaj
thumbnail
Dave Kliczbor,修改在12 年前。

RE: Hooking in Custom JSPs and Language property files

Junior Member 帖子: 77 加入日期: 11-7-12 最近的帖子
Pankaj Kathiriya:

Language property and Portal property file shoud be defined first and then custom-jsp-dir should be defined.
<hook>
<language-properties>content/CustomLogin_de.properties</language-properties>
<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
</hook>

Thanks, that was the right hint.

I need to read up on DTD syntax ... I thought the list of elements was a list of exclusive alternatives. Correct interpretation is a list of inclusive alternatives... and, inherently, the allowed sequence. Therefore: Inside <hook>, the elements have to be in this order:
<!--ELEMENT hook (portal-properties?, language-properties*, custom-jsp-dir?,
custom-jsp-global?, indexer-post-processor*, service*, servlet-filter*,
servlet-filter-mapping*, struts-action*)-->

Another point I found out: One has to use the filename "Language_XX.properties". This does not overwrite the original Language_XX.properties (like I feared when I took into account the behaviour of the custom JSPs), but merely overwrites and adds entries to it. And it has to reside in "WEB-INF/classes/content/".

So, my liferay-hook.xml now looks like this:
<!--?xml version="1.0"?-->


<hook>
	<language-properties>content/Language_de.properties</language-properties>
	<custom-jsp-dir>/custom_jsps</custom-jsp-dir>
</hook>

And it works. Yay!