Actaully, I am working on a Struts application which contains more than 100
actions and tiles and validation forms, it is extremely difficult to do
version control if different things are touched. In order to better control
the source code, I extended ActionServelt, TilePlugin and ValidationPlugin,
now I can config them as following,

<servlet>
<servlet-name>action
<servlet-class>com.company.project.struts.CoolActionServlet
<config>/WEB-INF/struts-config

where /WEB-INF/struts-config is a directory, CoolActionServlet will
recursively seach all the folders under it to build a comma seperated string
containing all the config files in ".xml" extension and how cool is that.

Tiles config can be in another directory, validation another.

You only need to override one method in each class to implement this
feature. It is more difficult to handle Tiles since it doesn't use Common
Digister. It reads old the config format as well, so Struts team may
consider to change the Struts to do this as well, it saved a lot of trouble
of maintaining a huge file.

Regards


On 8/12/06, Laurie Harper <[EMAIL PROTECTED]> wrote:

Kevin Maeer wrote:
> I want to split the validation.xml file into multiple files so some
pages can be
> more easily reused. If I save the new file under /WEB-INF/ and add it to
the
> ValidatorPlugIn "pathnames" in struts-config.xml everything works fine.
>
> If I move the new file out into the class hierarchy and change the
> ValidatorPlugIn entry to point to the new location, it all turns to
custard and
> I get the following in the logs:
>
> Loading validation rules file from
>
'/nz/ac/otago/corpserv/paper/web/struts/forms/validation/paper-search-validation
> ..xml'
> Skipping validation rules file from
>
'/nz/ac/otago/corpserv/paper/web/struts/forms/validation/paper-search-validation
> ..xml'.  No stream could be opened.
> javax.servlet.ServletException: Skipping validation rules file from
>
'/nz/ac/otago/corpserv/paper/web/struts/forms/validation/paper-search-validation
> ..xml'.  No stream could be opened.
>       at
> org.apache.struts.validator.ValidatorPlugIn.initResources(
ValidatorPlugIn.java:2
> 26)
>       at
> org.apache.struts.validator.ValidatorPlugIn.init(ValidatorPlugIn.java
:162)
>
> Is it possible to specify a location that isn't under web-inf for the
validation
> file and if so how is it specified? All the examples I've googled, that
have the
> file not under web-inf, use the old style "pathname" property to specify
the
> location.

The 'pathnames' property expects paths relative to the web application
root, so you aren't required to store your validation files under
WEB-INF. However, in this case it looks like you're trying to place them
in WEB-INF/classes/nz/ac/... so you still need the path to start with
'/WEB-INF/classes/nz/ac...'

It may also be possible to place the validation files inside a jar in
WEB-INF/lib, though in that case I'm not sure what syntax would be
required for Struts to find them. I believe the 1.3.x series is loading
at least some of the validator config from the struts.jar by default, so
there may be a way to get it to do the same for your validation rules
files too, but you'll have to dig in the code a bit to find out, unless
someone else can offer suggestions.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Yujun Liang
[EMAIL PROTECTED]

Reply via email to