[ 
https://issues.apache.org/struts/browse/STR-3132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43491#action_43491
 ] 

Laurent MORIN commented on STR-3132:
------------------------------------

it's because of naming conventions i used to define  generic action mappings 
(with wild cards)

and in some cases, i need to use a specific form.

In general :

/myEntity/aFunction/prepare.do  => Initialize a screen to realize "aFunction" 
on "myEntity"
/myEntity/aFunction/validate.do  => Validate a screen to realize "aFunction" on 
"myEntity"

By convention in this case i will use the entity to identify the form that will 
be used by the action (myEntityForm)
But sometimes, it is more logical to use a form specific for the function and 
not for the entity.


For exemple : criteria / List / Detail

/customer/create/prepare.do (use customerForm)
/customer/create/validate.do (use customerForm)

/customer/update/prepare.do (use customerForm)
/customer/update/validate.do (use customerForm)


*****************************
/customer/search/prepare.do (use searchCustomerForm)
/customer/search/validate.do (use searchCustomerForm)

in that case it's better to use a specific criteria form


I hope those explanations will help you.

Thanks, Laurent



> Improve wildcards resolution in action-mappings
> -----------------------------------------------
>
>                 Key: STR-3132
>                 URL: https://issues.apache.org/struts/browse/STR-3132
>             Project: Struts 1
>          Issue Type: Improvement
>          Components: Core
>    Affects Versions: 1.3.8
>         Environment: Struts 1.3.8
>            Reporter: Laurent MORIN
>             Fix For: Pending Review
>
>
> Hello 
> In my struts-config.xml, i define generic mappings using wildcards to 
> normalize actions suite.
> The is no posibility actualy to define 2 action mappings with the same path 
> structure but not the same configuration.
> My exemple is :
>       <action path="/*/*/prepare"
>                       name="{1}Form" scope="session"
>                       validate="false"
>                       command="prepare-{2}-{1}" catalog="cctp-{1}"
>                       forward="/{1}/{2}/prepare/rooting.do">
>       </action>
>       <action path="/*/*/prepare"
>                       name="{2}Form" scope="session"
>                       validate="false"
>                       command="prepare-{2}-{1}" catalog="cctp-{1}"
>                       forward="/{1}/{2}/prepare/rooting.do">
>       </action>
> Struts always retrieve the second one, even if the mapping is not correct 
> (wrong form name, wrong command ...)
> The only way i found to enable this behavior, is to setup the following 
> property in action servlet (web.xml)
>               <init-param>
>                       <param-name>configFactory</param-name>
>                       
> <param-value>org.apache.struts.config.impl.CustomMatcherModuleConfigFactory</param-value>
>               </init-param>
> And Then redfine , ModuleConfigFactory, ModuleConfigImpl and 
> ActionConfigMatcher.
> Just to redefine the method "match" in ActionConfigMatcher as following:
>     public ActionConfig match(String path) {
>       ActionConfig config = null;
>       if (compiledPaths.size() > 0) {
>           if (log.isDebugEnabled())
>               log.debug("Attempting to match '" + path + "' to a wildcard 
> pattern");
>           if (path.length() > 0 && path.charAt(0) == '/')
>               path = path.substring(1);
>           HashMap vars = new HashMap();
>           Iterator i = compiledPaths.iterator();
>           do {
>               if (!i.hasNext())
>                   break;
>               Mapping m = (Mapping) i.next();
>               if (wildcard.match(vars, path, m.getPattern())) {
>                   if (log.isDebugEnabled())
>                       log.debug("Path matches pattern '" + 
> m.getActionConfig().getPath() + "'");
>                   ActionConfig lTempconfig = convertActionConfig(path, 
> m.getActionConfig(), vars);
>                   
>                   // Test if ActionConfig is correct before returning it
>                   if(StringUtils.isNotBlank(lTempconfig.getName()) && 
> lTempconfig.getModuleConfig().findFormBeanConfig(lTempconfig.getName()) == 
> null) {
>                       // The form doesn't exists
>                       log.debug("FormBean not defined '" + 
> lTempconfig.getName() + "' config ignored");
>                   } else {
>                       config =lTempconfig;
>                   }
>                   
>               }
>           } while (true);
>       }
>       return config;
>     }
> In that exemple i just test formBean config but it is important to chek all 
> actionConfigs such as class, command ...
> thanks
> LAurent MORIN

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to