Hi,

here is the solution I found for my issue :

I have this form-bean and action definitions in the struts-config.xml :

----
<form-bean name="formXXX" class="default.formClassXXX" (...)>
 (...)
</form-bean>

(...)

<action path="processFormXXX"
            name="formXXX"
            (...)>
  (...)
</action >
----

In some identified cases (determined during run-time), I want the
java class "custom.formClassXXX" to be used for the implementation
of the form-bean "formXXX" instead of "default.formClassXXX".

My solution uses multiple module configuration (since struts 1.1) :

I create a new module configuration, let's say struts-custom.xml
in which I only declare the following :

----
<form-bean name="formXXX" class="custom.formClassXXX" (...)>
 (...)
</form-bean>

(...)

<!-- The action have the same definition as in the struts-config.xml,
    -  except that local forward definition (if any) may have the attribute
    -  contextRelative set to "true"
    -->
<action path="processFormXXX"
            name="formXXX"
            (...)>
  (...)
</action >
----
I declare this new module in web.xml as follow :
----
(...)
<servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>(...)</servlet-class>
  <init-param>
      <param-name>config</param-name>
      <param-value>/WEB-INF/conf/struts-config.xml</param-value>
    </init-param>
    <init-param>
      <param-name>config/custom</param-name>
      <param-value>/WEB-INF/conf/struts-custom.xml</param-value>
    </init-param>
 (...)
</servlet>
(...)
----

and, in the jsp page that contains the form, I make the following :

----
<[EMAIL PROTECTED] (...) 
              import="org.apache.struts.util.ModuleUtils"
              (...) %>
(...)
<%
  // determine wether the customClass needs to be used (true) or not (false)
  boolean needsCustom= (...) ;
  java.lang.String modulePrefix= "" ;
  if (needsCustom) {
    modulePrefix= "/custom" ;
  }
  ModuleUtils.getInstance().selectModule(modulePrefix,request,application) ;
%>

(...)

<html:form action="processFormXXX" (...) >
(...)
</html:form>
(...)
----

And this works fine !

Gilles


Le Mardi 5 Octobre 2004 11:15, gilles a écrit :
> Hi,
>
> Is it possible to associate several ActionForm or DynaActionForm
> subclasses to one form of a struts based application ?
>
> What I would like is that specific reset() and validate() methods
> be called for a given form according to values that have been
> given by users through former forms.
>
> Does anyone have an idea of how to perform such behavior ?
>
> I tried to alter the struts configuration (ModuleConfig Instance)
> on the fly, but it didn't work (cf. my posting of september 29 :
> "altering module configuration during run-time"
> http://mail-archives.apache.org/eyebrowse/[EMAIL PROTECTED]
>he.org&msgNo=118628 )
>
> Thanks
>
> Gilles
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to