You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Alain Del Giust <ja...@noos.fr> on 2002/11/01 20:58:28 UTC
DynaActionFormClass
Hi All,
I'd like to use Dynamic Forms but not "only" based on "struts-config.xml" file.
I have build an application using Struts-b2.
I have modified the following files.
I am not smart developer so perhaps it will be better to use an abstract class for DynaActionFormClass as I only override "introspect" method.
Thanks for your help.
Alain
1. http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd
so that it will be possible to add the attribute "dynaClassName" to "form-bean" element.
Exemple: <form-bean name="MyDynaForm" type="fr.sssw.struts.action.MyDynaActionForm" dynaClassName="fr.sssw.struts.action.MyDynaActionFormClass" />
2. org.apache.struts.config.FormBeanConfig
so that it will take care of the above "dynaClassName" attribute
// -----------------------------------------------------------------------------------------------------------------
protected String dynaClassName = null;
public String getDynaClassName() {
return (this.dynaClassName);
}
public void setDynaClassName(String dynaClassName) {
if (configured) {
throw new IllegalStateException("Configuration is frozen");
}
this.dynaClassName = dynaClassName;
}
// -----------------------------------------------------------------------------------------------------------------
3. org.apache.struts.action.DynaActionFormClass
so that "createDynaActionFormClass" method could create a new DynaActionFormClass based on the value of the above "dynaClassName" attribute if it exists.
// -----------------------------------------------------------------------------------------------------------------
protected static Class parameterTypes[] = {FormBeanConfig.class};
public static DynaActionFormClass createDynaActionFormClass(FormBeanConfig config) {
synchronized (lock) {
if (dynaClasses == null) {
dynaClasses = new HashMap();
}
DynaActionFormClass dynaClass = (DynaActionFormClass) dynaClasses.get(config.getName());
if (dynaClass == null) {
String dynaClassName = config.getDynaClassName();
if (dynaClassName != null) {
try {
Class clazz = Class.forName(dynaClassName);
Constructor constructor = clazz.getDeclaredConstructor(parameterTypes);
Object constructorValues[] = { config };
dynaClass = (DynaActionFormClass )constructor.newInstance(constructorValues);
} catch (Exception e) {
System.out.println(e);
}
} else {
dynaClass = new DynaActionFormClass(config);
}
dynaClasses.put(config.getName(), dynaClass);
}
return (dynaClass);
}
}
// -----------------------------------------------------------------------------------------------------------------
4. org.apache.struts.action.DynaActionFormClass
so that the constructor access specifier changes to "protected" from "private" to allow inheritence
// -----------------------------------------------------------------------------------------------------------------
protected DynaActionFormClass(FormBeanConfig config) {
introspect(config);
}
// -----------------------------------------------------------------------------------------------------------------
Alain
Re: DynaActionFormClass
Posted by Alain Del Giust <ja...@noos.fr>.
I am a little bit confused.
Here is my problem:
There is in exteNd Director a screen where you can define your forms.
The properties are stored in a database and there is an API to get each
property define for the a particular form.
Basically :
return a Collection of fields for a named form.
The collection defines
the name
the type (checkbox, radio, selectbox ...)
the default value
pretty much the same way it is done with <form-property>
So I used the "introspect" method from DynaActionFormClass to set the
DynaProperty.
here is an excerpt of my code:
Collection documentFields =
m_cmgr.getDocumentFields(m_context,docType.getDocTypeID());
Iterator iterFields = documentFields.iterator();
while (iterFields.hasNext()) {
EbiDocField field = (EbiDocField)iterFields.next();
DocFieldExt docFieldExt =
DocFieldExt.getDocFieldExt(field.getExtensionMeta());
// set the dynaProperty
DynaProperty dynaProperty = new DynaProperty(field.getFieldName(),
docFieldExt.getClassType());
propertiesMap.put(dynaProperty.getName(), dynaProperty);
if (DocListExt.class.isAssignableFrom(docFieldExt.getClass())) {
// options for select box and radio
DocListExt docListExt = (DocListExt )docFieldExt;
// set the dynaProperty
dynaProperty = new DynaProperty(docListExt.getItemHolderName(),
docListExt.getItemHolderClassType());
propertiesMap.put(dynaProperty.getName(), dynaProperty);
}
docFieldsExt.add(docFieldExt);
}
Thus, at the app server startup every thing is all set for all the forms
property and I just have to call the same JSP (with in the request the id of
my form, actually docTypeID) to see it dynamically change according to what
it should reflect.
Excuse me if I misunderstood your previous answer and those explanation are
not from any help to let you understand my problem.
Alain
----- Original Message -----
From: "James Mitchell" <jm...@telocity.com>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, November 01, 2002 10:07 PM
Subject: RE: DynaActionFormClass
> Why don't you just set the value in the action prior to forwarding to your
> jsp? You can easily do that using a value from the bundle.
>
>
> James Mitchell
> Software Engineer/Struts Evangelist
> http://www.open-tools.org
>
> "Only two things are infinite, the universe and human stupidity, and I'm
not
> sure about the former."
> - Albert Einstein (1879-1955)
>
>
> > -----Original Message-----
> > From: Alain Del Giust [mailto:java.dev@noos.fr]
> > Sent: Friday, November 01, 2002 3:59 PM
> > To: Struts Developers List
> > Subject: Re: DynaActionFormClass
> >
> >
> > From my understanding if I want to create a Dynamic Form I have to use
> > struts-config.xml to configure the properties of the form.
> >
> > Example:
> >
> > <form-property name="email" type="java.lang.String "/>
> > <form-property name="password" type="java.lang.String "/>
> > <form-property initial="false" name="rememberMe"
> > type="java.lang.Boolean "/>
> >
> > But I don't want to do that because those properties are define
elsewhere
> > (database for example, actually I am trying to integrate Struts Framwork
> > with one part of Novell/SilverStream exteNd Director Framework)
> >
> > That's why I think that I "need" to override DynaActionFormClass.
> >
> >
> > Alain
> >
> >
> > ----- Original Message -----
> > From: "Craig R. McClanahan" <cr...@apache.org>
> > To: "Struts Developers List" <st...@jakarta.apache.org>
> > Sent: Friday, November 01, 2002 9:15 PM
> > Subject: Re: DynaActionFormClass
> >
> >
> > >
> > >
> > > On Fri, 1 Nov 2002, Alain Del Giust wrote:
> > >
> > > > Date: Fri, 1 Nov 2002 20:58:28 +0100
> > > > From: Alain Del Giust <ja...@noos.fr>
> > > > Reply-To: Struts Developers List <st...@jakarta.apache.org>
> > > > To: struts-dev@jakarta.apache.org
> > > > Subject: DynaActionFormClass
> > > >
> > > > Hi All,
> > > >
> > > > I'd like to use Dynamic Forms but not "only" based on
> > "struts-config.xml" file.
> > > >
> > > > I have build an application using Struts-b2.
> > > >
> > > > I have modified the following files.
> > > > I am not smart developer so perhaps it will be better to use
> > an abstract
> > class for DynaActionFormClass as I only override "introspect" method.
> > > >
> > >
> > > I'm having a hard time understanding why the existing facilities don't
> > > support all the functionality you need. What is it you are trying to
do
> > > that is not currently possible?
> > >
> > > > Thanks for your help.
> > > >
> > > > Alain
> > > >
> > >
> > > Craig
> > >
> > >
> > > --
> > > 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>
>
>
>
> --
> 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>
RE: DynaActionFormClass
Posted by James Mitchell <jm...@telocity.com>.
Why don't you just set the value in the action prior to forwarding to your
jsp? You can easily do that using a value from the bundle.
James Mitchell
Software Engineer/Struts Evangelist
http://www.open-tools.org
"Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former."
- Albert Einstein (1879-1955)
> -----Original Message-----
> From: Alain Del Giust [mailto:java.dev@noos.fr]
> Sent: Friday, November 01, 2002 3:59 PM
> To: Struts Developers List
> Subject: Re: DynaActionFormClass
>
>
> From my understanding if I want to create a Dynamic Form I have to use
> struts-config.xml to configure the properties of the form.
>
> Example:
>
> <form-property name="email" type="java.lang.String "/>
> <form-property name="password" type="java.lang.String "/>
> <form-property initial="false" name="rememberMe"
> type="java.lang.Boolean "/>
>
> But I don't want to do that because those properties are define elsewhere
> (database for example, actually I am trying to integrate Struts Framwork
> with one part of Novell/SilverStream exteNd Director Framework)
>
> That's why I think that I "need" to override DynaActionFormClass.
>
>
> Alain
>
>
> ----- Original Message -----
> From: "Craig R. McClanahan" <cr...@apache.org>
> To: "Struts Developers List" <st...@jakarta.apache.org>
> Sent: Friday, November 01, 2002 9:15 PM
> Subject: Re: DynaActionFormClass
>
>
> >
> >
> > On Fri, 1 Nov 2002, Alain Del Giust wrote:
> >
> > > Date: Fri, 1 Nov 2002 20:58:28 +0100
> > > From: Alain Del Giust <ja...@noos.fr>
> > > Reply-To: Struts Developers List <st...@jakarta.apache.org>
> > > To: struts-dev@jakarta.apache.org
> > > Subject: DynaActionFormClass
> > >
> > > Hi All,
> > >
> > > I'd like to use Dynamic Forms but not "only" based on
> "struts-config.xml" file.
> > >
> > > I have build an application using Struts-b2.
> > >
> > > I have modified the following files.
> > > I am not smart developer so perhaps it will be better to use
> an abstract
> class for DynaActionFormClass as I only override "introspect" method.
> > >
> >
> > I'm having a hard time understanding why the existing facilities don't
> > support all the functionality you need. What is it you are trying to do
> > that is not currently possible?
> >
> > > Thanks for your help.
> > >
> > > Alain
> > >
> >
> > Craig
> >
> >
> > --
> > 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>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: DynaActionFormClass
Posted by Alain Del Giust <ja...@noos.fr>.
>From my understanding if I want to create a Dynamic Form I have to use
struts-config.xml to configure the properties of the form.
Example:
<form-property name="email" type="java.lang.String "/>
<form-property name="password" type="java.lang.String "/>
<form-property initial="false" name="rememberMe"
type="java.lang.Boolean "/>
But I don't want to do that because those properties are define elsewhere
(database for example, actually I am trying to integrate Struts Framwork
with one part of Novell/SilverStream exteNd Director Framework)
That's why I think that I "need" to override DynaActionFormClass.
Alain
----- Original Message -----
From: "Craig R. McClanahan" <cr...@apache.org>
To: "Struts Developers List" <st...@jakarta.apache.org>
Sent: Friday, November 01, 2002 9:15 PM
Subject: Re: DynaActionFormClass
>
>
> On Fri, 1 Nov 2002, Alain Del Giust wrote:
>
> > Date: Fri, 1 Nov 2002 20:58:28 +0100
> > From: Alain Del Giust <ja...@noos.fr>
> > Reply-To: Struts Developers List <st...@jakarta.apache.org>
> > To: struts-dev@jakarta.apache.org
> > Subject: DynaActionFormClass
> >
> > Hi All,
> >
> > I'd like to use Dynamic Forms but not "only" based on
"struts-config.xml" file.
> >
> > I have build an application using Struts-b2.
> >
> > I have modified the following files.
> > I am not smart developer so perhaps it will be better to use an abstract
class for DynaActionFormClass as I only override "introspect" method.
> >
>
> I'm having a hard time understanding why the existing facilities don't
> support all the functionality you need. What is it you are trying to do
> that is not currently possible?
>
> > Thanks for your help.
> >
> > Alain
> >
>
> Craig
>
>
> --
> 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>
Re: DynaActionFormClass
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Fri, 1 Nov 2002, Alain Del Giust wrote:
> Date: Fri, 1 Nov 2002 20:58:28 +0100
> From: Alain Del Giust <ja...@noos.fr>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
> To: struts-dev@jakarta.apache.org
> Subject: DynaActionFormClass
>
> Hi All,
>
> I'd like to use Dynamic Forms but not "only" based on "struts-config.xml" file.
>
> I have build an application using Struts-b2.
>
> I have modified the following files.
> I am not smart developer so perhaps it will be better to use an abstract class for DynaActionFormClass as I only override "introspect" method.
>
I'm having a hard time understanding why the existing facilities don't
support all the functionality you need. What is it you are trying to do
that is not currently possible?
> Thanks for your help.
>
> Alain
>
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>