Search code examples
javaxpagesxpages-extlib

XPage - Save property file from JavaBean


After some tries and a lot of Google-ing I ended up asking again =)

I have a Java Bean that creates a TreeSet<String> containing some users for my database to work with. Because it takes some time to create my TreeSet I want to save it to a propertiesfile.

Getting / reading the property file in my Bean was no problem, also setting a Property is easy but how can I create a OutputStream to my resource?

Code snippet:

try {
    Properties userproperties;
    userproperties = new Properties();
    userproperties.load(FacesContextEx.getCurrentInstance().getExternalContext().getResourceAsStream("WEB-INF/user.properties"));

    for (String groupmember : groupmembers) {
        userproperties.setProperty("UserList", groupmember);
    }
    // userproperties.save(OutputStream, comments)

} catch (Exception e) {
    // some errorhandling
}

Solution

  • You can do this via a DXL Import. Create a DXL file on your filesystem and import it into the database.

    Note that webusers must have at least designer rights (advanced ACL settings)

    But it seems there is a bug with 8.5.2, I couldn't get it to work with this version.