[opencms-dev] Struts integration

Kenneth Lewelling klewelling at curoalemanz.com
Fri Feb 7 02:38:16 CET 2003


Hello again.

I am working on the Struts integration and ran into a small problem. As far
as I can tell there is no way to perform a specific action when a document
in the sourcecode editor is saved. If this is not the case please ignore the
rest of this message and just let me know how.

First I will present a little background on why I want to do this, then a
possible solution I thought up. Struts uses a configuration file, usualy
name struts-config.xml (Struts can have more than one configuration file you
would just change the name or the namespace). For Struts to be integrated
into OpenCms this file will need to be editable within OpenCms. My solution
to this was add a new folder beneath the system folder in the VFS, where
each Struts application in OpenCms has its own folder. Within the Struts
folder is its configuration file. This file is not intended to be edited
within the VFS, and I address this problem below in the possible solution.
The file is suppose to be edited within the Struts item in the
Administrative view.

The sourcecode editor will work fine for editing the file, however once the
file is saved I need a way to resync the "Action" resouces in the VFS (If
you are not sure what an "Action" resource is please refered to
http://opencmsstruts.sourceforge.net/srs.html , pay special attention to UC4
and UC5). A corollary to syncing with the VFS is parsing the configuration
file and check it against itd dtd, and if it isn't correct do not save the
file and allow the user to fix the problem.

Here is a possible solution:

Add a new method to the I_CmsResourceType interface called resourceEdited()
(or something) that informs the Resource that its contents have been changed
and are about to be saved. Then in the CmsEditor, just before the file is
saved, call the resourceChanged() method. If the method returns false, or
throws an exception then the user is forwarded to an error page and told the
file could not be saved for whatever reason, and then forwarded back to the
editor page.

With this additional method I could create a new Struts Configuration
resource type that implements the resourceEdited() method. That method can
parse the configuration file to make sure it is syntacticly correct then
syncronize the "Action" resources in the VFS.

I wanted to ask this because my solution requires a change to a major
interface and wanted to make sure it was the correct thing to do.

Thank you for any comments
Kenneth Lewelling
http://opencmsstruts.sourceforge.net




More information about the opencms-dev mailing list