I need the properties changes made programatically to persist a server reboot, redeployment, ect. Basically, I need modify the properties file when changes are made. Is this even possible? Currently, I have the properties working but the values dont ever change in the properties folder.
String realPath = getPortletContext().getRealPath("/");
FileInputStream in = new FileInputStream(realPath+"json.properties");
Properties p = new Properties();
p.load(in);
System.out.println(p.getProperty("json"));
in.close();
p.setProperty("json", "test");
System.out.println(p.getProperty("json"));
FileOutputStream out = new FileOutputStream(realPath+"json.properties");
p.store(out, "test");
in.close();
out.close();
System.out.println(com.liferay.util.portlet.PortletProps.get("json"));
com.liferay.util.portlet.PortletProps.set("json", "change");
com.liferay.util.portlet.PortletProps.set("new", "change");
System.out.println(com.liferay.util.portlet.PortletProps.get("new"));
portal.properties:
json=help
new=new1
json.properties
json=blank
output when code is ran:
blank
test
help
change
As you can see above, I have tried using regular java properties and tried using the liferay properties. I need to basically need to get some json, edit it, then save it for later use. I need the changes to persist until edited again.
All of my previous code is junk the way I solved it was to use
Note: I tried this before with no luck and the problem was my imports. make sure that you use
javax.portlet.PortletPreferences; and not the liferay portletpreferences class.