Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Al Krinker
Common message.properties file?
May 25, 2011 2:40 PM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

Is there a way to have common message.properties file that gets used by all portlets? Let say that you have 20 portlets that have "User Name" as a label of the input field on jsp... and now you want to change it to "First Name".. and now you need to change 20 message.properties files...

Is there a way to make global one and change it only once?
Hitoshi Ozawa
RE: Common message.properties file?
May 25, 2011 2:49 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Do you mean something like Language.properties in \portal-impl\src\content? (ROOT\WEB-INF\lib\portal-impl.jar)
Al Krinker
RE: Common message.properties file?
May 25, 2011 2:54 PM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

Yes! Can I make some common file just like Language.properties?

I tried creating global.properties under liferay-portal-6.0.5\tomcat-6.0.26\webapps\ROOT\WEB-INF\classes

and referring to it by

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>errors</value>
<value>global</value>
</list>
</property>
</bean>

but no luck....
Hitoshi Ozawa
RE: Common message.properties file?
May 25, 2011 3:41 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Have you looked in hooks?

http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/overriding-a-language-properties-file
Al Krinker
RE: Common message.properties file?
May 25, 2011 3:49 PM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

Hi Hitoshi,

Yes, I have, but I dont think it will work for me... Let me explain. What I am trying to do is to have a way for someone with minimum programming skills to be able to modify property file, restart the server and see immediate results... I also looked into storing labels into DB, but it def would require significant amount of effort to rewrite what I already have at this point...

Then again, now thinking about it, hook might give me the same result in the end, just will require more steps for the user...

Is there anything easier that I may use? If not, hooks will work.

Thank you for your help!
Al Krinker
RE: Common message.properties file?
May 25, 2011 4:13 PM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

Just tried editing ROOT\WEB-INF\lib\portal-impl.jar directly to include
testme.test=HELLO WORLD!
in
Language.properties
Language_en.properties
Language_en_US.properties

and got this error
Caused by: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: No message found under code 'testme.test' for locale 'en_US'.

also tried to create a hook by
<hook>
<language-properties>content/Language_en_US.properties</language-properties>
<language-properties>content/Language_en.properties</language-properties>
<language-properties>content/Language.properties</language-properties>
</hook>

and placing those files under liferay-plugins-sdk-6.0.5\hooks\globalLabels-hook\docroot\WEB-INF.... same thing.

Am i doing something wrong?
Al Krinker
RE: Common message.properties file?
May 25, 2011 4:27 PM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

p.s. I am trying to access it in my jsp by calling

<spring:message code="testme.test"/>
Hitoshi Ozawa
RE: Common message.properties file?
May 25, 2011 5:39 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Probaby because your spring:message tag isn't in the liferay namespace:
<liferay-ui:message key="testme.test" />
Al Krinker
RE: Common message.properties file?
May 26, 2011 6:55 AM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

ah. Make sense! Thank you
Al Krinker
RE: Common message.properties file?
May 27, 2011 6:22 AM
Answer

Al Krinker

Rank: New Member

Posts: 17

Join Date: March 11, 2011

Recent Posts

found another way by modifying catalina.properties file... it worked better for me since i kept my code unchanged and did not have to use liferay specific tags...

once again, thank you for your help!!!