Foren

How to change language file content in portlet dynamically?

Mathias Kissig, geändert vor 12 Jahren.

How to change language file content in portlet dynamically?

New Member Beiträge: 7 Beitrittsdatum: 19.02.12 Neueste Beiträge
Hello everyone,

I am relatively new to Liferay and I am using liferay-portal-6.1.0-ce-ga1 with Tomcat 7.0.23. I am currently developing a portlet which should display the content of the Language.properties file, allow manual changes to the content and overwrite the existing file with the changes. And all of this should happen while the portal and the portlet is running.
The portlet is implemented by extending MVCPortlet and so far, I have managed to read the content of the .properties file and display it in <aui:input type="textarea" .../>. But it is not possible to save the new content to the existing file. I tried to achieve it with "low-level" Java operations and although the code is executed without any problems or exceptions, nothing happens.


if (file.exists() &amp;&amp; file.canWrite()) {
	Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF8"));
	out.write(content);
	out.close();
}


I assume that Liferay or the Portlet still has a file handle open on this file and thus my save operation is only executed after this handle is been released. So I assume, that I have to extend a special class or use a specific Liferay/Portlet mechanism in order to save the content to the .properties file.

Any ideas or hints on how to solve this issue?

Many thanks for your help and with best regards,
Mathias