You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frost, Gary [IT]" <Ga...@ssmb.com.au> on 2002/12/11 06:32:56 UTC

Validator with separate modules (Tiles too)

Hi,

Sorry if this has already been asked and answered, I tried a search on it,
but came up with nothing matching.

Anyway.... I'm using a recent nightly build of struts (about a week old),
and am using struts broken into various modules.

E.g.
/myapp
/myapp/admin
/myapp/coolstuff

So 	/myapp if configured from 	/config/struts-config.xml
	/myapp/admin from		/config/admin/struts-config.xml
/myapp/coolstuff		/config/coolstuff/struts-config.xml
The tiles configs 
	/myapp if configured from 	/config/tiles-config.xml
	/myapp/admin from		/config/admin/tiles-config.xml
/myapp/coolstuff from		/config/coolstuff/tiles-config.xml
The validator configs 
	/myapp if configured from 	/config/validator-config.xml
	/myapp/admin from		/config/admin/validator-config.xml
		/myapp/coolstuff from
/config/coolstuff/validator-config.xml


Which makes it nice to track/control the config files on a per module basis.

My query/problem is that it seems that each struts-config.xml file must
include it plugin configs each associated config files for each module, if I
fail to do this then the config is not necessarily loaded, it seems to be
whichever module gets loaded first set the tiles and validator rules
globally.

I.e. if my /myapp/admin/struts-config contains the plugin code
	<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
		<set-property property="pathnames"
	
value="/WEB-INF/config/admin/validator-config.xml"
	</plug-in>
	<plug-in className="org.apache.struts.tiles.TilesPlugin" >
	  <set-property property="definitions-config"
	
value="/WEB-INF/config/admin/tiles-config.xml"/>
	</plug-in>

Then when I start the webapp and check the logfile (I have loggin turned to
max), I see that the rules for these two plugins get loaded, and if I go to
an action (tiles definition) in the admin module, everything works fine, the
tiles come together, the validators all work sweet etc.  However if I go to
an action (tiles definition) in the coolstuff module it cant find the tiles
definition, or the validator definition etc.

The only way I can get round it is to put all of the validator.xml configs
and tiles.xml configs in each of the struts-config.xml files.

So, is there anyway for each module to have its own TileFactory and
ValidatorFactory, and hence each one loads the appropriate definitions.
Failing that any other suggestions (was thinking something like having all
the definitions in the 'root' config file, and forcing somehow that one to
be that is read, but I'm not sure I like that idea)

All help/comments appreciated

Gary

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Validator with separate modules (Tiles too)

Posted by Cedric Dumoulin <ce...@apache.org>.
  Hi,

  Tiles now allow to have one Tiles factory for each module (since 2/3 
weeks). But, for backward compatibility, you need to enable it. Add the 
following property value in your Tiles plugin declaration:
    <set-property property="moduleAware" value="true" />

  Remember that you need to declare the Tiles plugin in each module, so 
in each struts-config file.

        Cedric

Frost, Gary [IT] wrote:

>Hi,
>
>Sorry if this has already been asked and answered, I tried a search on it,
>but came up with nothing matching.
>
>Anyway.... I'm using a recent nightly build of struts (about a week old),
>and am using struts broken into various modules.
>
>E.g.
>/myapp
>/myapp/admin
>/myapp/coolstuff
>
>So 	/myapp if configured from 	/config/struts-config.xml
>	/myapp/admin from		/config/admin/struts-config.xml
>/myapp/coolstuff		/config/coolstuff/struts-config.xml
>The tiles configs 
>	/myapp if configured from 	/config/tiles-config.xml
>	/myapp/admin from		/config/admin/tiles-config.xml
>/myapp/coolstuff from		/config/coolstuff/tiles-config.xml
>The validator configs 
>	/myapp if configured from 	/config/validator-config.xml
>	/myapp/admin from		/config/admin/validator-config.xml
>		/myapp/coolstuff from
>/config/coolstuff/validator-config.xml
>
>
>Which makes it nice to track/control the config files on a per module basis.
>
>My query/problem is that it seems that each struts-config.xml file must
>include it plugin configs each associated config files for each module, if I
>fail to do this then the config is not necessarily loaded, it seems to be
>whichever module gets loaded first set the tiles and validator rules
>globally.
>
>I.e. if my /myapp/admin/struts-config contains the plugin code
>	<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
>		<set-property property="pathnames"
>	
>value="/WEB-INF/config/admin/validator-config.xml"
>	</plug-in>
>	<plug-in className="org.apache.struts.tiles.TilesPlugin" >
>	  <set-property property="definitions-config"
>	
>value="/WEB-INF/config/admin/tiles-config.xml"/>
>	</plug-in>
>
>Then when I start the webapp and check the logfile (I have loggin turned to
>max), I see that the rules for these two plugins get loaded, and if I go to
>an action (tiles definition) in the admin module, everything works fine, the
>tiles come together, the validators all work sweet etc.  However if I go to
>an action (tiles definition) in the coolstuff module it cant find the tiles
>definition, or the validator definition etc.
>
>The only way I can get round it is to put all of the validator.xml configs
>and tiles.xml configs in each of the struts-config.xml files.
>
>So, is there anyway for each module to have its own TileFactory and
>ValidatorFactory, and hence each one loads the appropriate definitions.
>Failing that any other suggestions (was thinking something like having all
>the definitions in the 'root' config file, and forcing somehow that one to
>be that is read, but I'm not sure I like that idea)
>
>All help/comments appreciated
>
>Gary
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>  
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>