You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pedro Salgado <sa...@04web.com> on 2004/01/03 17:28:39 UTC
dynaform populate
Can anyone help me on this?
I am trying to pass a populated DynaActionForm to a JSP file and I can't
figure out how can I populate the form...
I have the following sequence:
- form A (name : gotoUserPrefsForm, id : String - user id)
- action ViewUserPreferences (uses form A)
- form B (name : userPrefsForm, severall attributes)
ViewUserPreferences {
/** @param form this is form A. */
... execute(..., form, ...) {
int id = FormUtils.getIntValue(form, "id");
UserPreferences prefs = service.getUserPreferences("id");
// here starts the problem!!!
// gets the form bean configuration
FormBeanConfig fc = config.findFormBeanConfig(mapping.getName());
// this is supposed to be form B
DynaValidatorForm dynaForm = // how do I create a new instance with
the FormBeanConfig?...
dynaForm.set("background", prefs.getBackground());
request.setAttribute("userPrefsForm", dynaForm);
}
}
Any ideas?
Pedro Salgado
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: dynaform populate
Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hi again,
i have this for one property:
<html:text name="bean" property="foo"/><html:errors property="foo"/>
on submit, the "normal" validation-flow runs...
you have an html!!!-formular (the generated one which you can see via
browser, and its source),
named like your formbean-name in struts-config.xml
you only got the "filled" textfield via a "normal" javaBean
after submitting, in your corresponding actionClass you
get an ActionForm-object, (base of DynaValidatorForm)
with these values...(came from html-form)
please look also here,
there you see, that formBeans are not! model-components of
MVC-(web).apps.
http://jakarta.apache.org/struts/userGuide/building_model.html
section (2.3)
greetings
Matthias
-----Original Message-----
From: Pedro Salgado [mailto:salgado.pc@04web.com]
Sent: Saturday, January 03, 2004 6:37 PM
To: Struts Users Mailing List
Subject: Re: dynaform populate
On 04/01/2004 17:16, "Matthias Wessendorf"
<ma...@matthias-wessendorf.de>
wrote:
> Hi Pedro,
>
> the properties are!!! important!!!
>
>
>
> i do the following in an action:
>
> request.setAttribute("helperBean",myValueObject);
>
> return mapping.findForward("updateFormularPage");
>
>
>
> and have something like that in
> the forwarded jsp
>
> <struts-html:form action="/myActionPath">
> <struts-html:text name="helperBean" property="foo"/>
>
I didn't knew html:text had a name attribute :)
I usually use
<html:text property="background" styleClass="field_required"/> (I
supposed, in this case, the name attribute is the form-bean name defined
on the struts config file)...
One more question, if you have validation errors (after submitting the
form), you still have to pass the form properties to your helperBean or
the JSP page automatically presents the previous sent values (just like
doing a back on the browser)?
Thank you again,
Pedro Salgado
> ...
>
> </struts-html:form>
>
>
> it works fine!
>
>
> Regards, Matthias
>
>
>
> -----Original Message-----
> From: Pedro Salgado [mailto:salgado.pc@04web.com]
> Sent: Saturday, January 03, 2004 6:08 PM
> To: Struts Users Mailing List
> Subject: Re: dynaform populate
>
>
> On 04/01/2004 16:55, "Matthias Wessendorf"
> <ma...@matthias-wessendorf.de>
> wrote:
>
>> Hi Pedro,
>>
>> with:
>>
>> FormBeanConfig fbc = new FormBeanConfig();
>> fbc.setName("myForm");
>> DynaActionFormClass dafc =
>> DynaActionFormClass.createDynaActionFormClass(fbc);
>> DynaActionForm formBean = (DynaActionForm) dafc.newInstance();
>> formBean.set("property", businessObject.getProperty());
>> request.setAttribute("userPrefsForm",formBean);
>> //End
>>
>> you can create a dynaBean.
>> i had the problem long time ago two.
>>
>> why are willing to use dynaBeans for populating a JSP-Form-Page?
>>
>> i use "ValueObjects" or "HelperBeans" instead, which i store in
>> request and with there properties the formfilds get filled to!
>
> What you are telling me is that if I store a bean with the same name
> as the form, the html tag lib will interpret it as being the form,
> right?
>
> Thank you very much!
>
> Pedro Salgado
>
>>
>> look
>> http://rollerjm.free.fr/images/ClassStruts1_1.gif
>> an nice diagramm :-)
>>
>> greetings
>> Matthias
>>
>>
>>
>> -----Original Message-----
>> From: Pedro Salgado [mailto:salgado.pc@04web.com]
>> Sent: Saturday, January 03, 2004 5:29 PM
>> To: Struts Users Mailing List
>> Subject: dynaform populate
>>
>>
>>
>> Can anyone help me on this?
>> I am trying to pass a populated DynaActionForm to a JSP file and I
>> can't figure out how can I populate the form...
>>
>> I have the following sequence:
>>
>> - form A (name : gotoUserPrefsForm, id : String - user id)
>> - action ViewUserPreferences (uses form A)
>> - form B (name : userPrefsForm, severall attributes)
>>
>>
>> ViewUserPreferences {
>>
>> /** @param form this is form A. */
>> ... execute(..., form, ...) {
>>
>> int id = FormUtils.getIntValue(form, "id");
>>
>> UserPreferences prefs = service.getUserPreferences("id");
>>
>> // here starts the problem!!!
>> // gets the form bean configuration
>> FormBeanConfig fc =
>> config.findFormBeanConfig(mapping.getName());
>>
>> // this is supposed to be form B
>> DynaValidatorForm dynaForm = // how do I create a new instance
>> with the FormBeanConfig?...
>>
>>
>> dynaForm.set("background", prefs.getBackground());
>>
>> request.setAttribute("userPrefsForm", dynaForm);
>>
>> }
>>
>> }
>>
>>
>> Any ideas?
>>
>> Pedro Salgado
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: dynaform populate
Posted by Pedro Salgado <sa...@04web.com>.
On 04/01/2004 17:16, "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
wrote:
> Hi Pedro,
>
> the properties are!!! important!!!
>
>
>
> i do the following in an action:
>
> request.setAttribute("helperBean",myValueObject);
>
> return mapping.findForward("updateFormularPage");
>
>
>
> and have something like that in
> the forwarded jsp
>
> <struts-html:form action="/myActionPath">
> <struts-html:text name="helperBean" property="foo"/>
>
I didn't knew html:text had a name attribute :)
I usually use
<html:text property="background" styleClass="field_required"/> (I supposed,
in this case, the name attribute is the form-bean name defined on the struts
config file)...
One more question, if you have validation errors (after submitting the
form), you still have to pass the form properties to your helperBean or the
JSP page automatically presents the previous sent values (just like doing a
back on the browser)?
Thank you again,
Pedro Salgado
> ...
>
> </struts-html:form>
>
>
> it works fine!
>
>
> Regards, Matthias
>
>
>
> -----Original Message-----
> From: Pedro Salgado [mailto:salgado.pc@04web.com]
> Sent: Saturday, January 03, 2004 6:08 PM
> To: Struts Users Mailing List
> Subject: Re: dynaform populate
>
>
> On 04/01/2004 16:55, "Matthias Wessendorf"
> <ma...@matthias-wessendorf.de>
> wrote:
>
>> Hi Pedro,
>>
>> with:
>>
>> FormBeanConfig fbc = new FormBeanConfig();
>> fbc.setName("myForm");
>> DynaActionFormClass dafc =
>> DynaActionFormClass.createDynaActionFormClass(fbc);
>> DynaActionForm formBean = (DynaActionForm) dafc.newInstance();
>> formBean.set("property", businessObject.getProperty());
>> request.setAttribute("userPrefsForm",formBean);
>> //End
>>
>> you can create a dynaBean.
>> i had the problem long time ago two.
>>
>> why are willing to use dynaBeans for populating a JSP-Form-Page?
>>
>> i use "ValueObjects" or "HelperBeans" instead, which i store in
>> request and with there properties the formfilds get filled to!
>
> What you are telling me is that if I store a bean with the same name as
> the form, the html tag lib will interpret it as being the form, right?
>
> Thank you very much!
>
> Pedro Salgado
>
>>
>> look
>> http://rollerjm.free.fr/images/ClassStruts1_1.gif
>> an nice diagramm :-)
>>
>> greetings
>> Matthias
>>
>>
>>
>> -----Original Message-----
>> From: Pedro Salgado [mailto:salgado.pc@04web.com]
>> Sent: Saturday, January 03, 2004 5:29 PM
>> To: Struts Users Mailing List
>> Subject: dynaform populate
>>
>>
>>
>> Can anyone help me on this?
>> I am trying to pass a populated DynaActionForm to a JSP file and I
>> can't figure out how can I populate the form...
>>
>> I have the following sequence:
>>
>> - form A (name : gotoUserPrefsForm, id : String - user id)
>> - action ViewUserPreferences (uses form A)
>> - form B (name : userPrefsForm, severall attributes)
>>
>>
>> ViewUserPreferences {
>>
>> /** @param form this is form A. */
>> ... execute(..., form, ...) {
>>
>> int id = FormUtils.getIntValue(form, "id");
>>
>> UserPreferences prefs = service.getUserPreferences("id");
>>
>> // here starts the problem!!!
>> // gets the form bean configuration
>> FormBeanConfig fc =
>> config.findFormBeanConfig(mapping.getName());
>>
>> // this is supposed to be form B
>> DynaValidatorForm dynaForm = // how do I create a new instance
>> with the FormBeanConfig?...
>>
>>
>> dynaForm.set("background", prefs.getBackground());
>>
>> request.setAttribute("userPrefsForm", dynaForm);
>>
>> }
>>
>> }
>>
>>
>> Any ideas?
>>
>> Pedro Salgado
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: dynaform populate
Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hi Pedro,
the properties are!!! important!!!
i do the following in an action:
request.setAttribute("helperBean",myValueObject);
return mapping.findForward("updateFormularPage");
and have something like that in
the forwarded jsp
<struts-html:form action="/myActionPath">
<struts-html:text name="helperBean" property="foo"/>
...
</struts-html:form>
it works fine!
Regards, Matthias
-----Original Message-----
From: Pedro Salgado [mailto:salgado.pc@04web.com]
Sent: Saturday, January 03, 2004 6:08 PM
To: Struts Users Mailing List
Subject: Re: dynaform populate
On 04/01/2004 16:55, "Matthias Wessendorf"
<ma...@matthias-wessendorf.de>
wrote:
> Hi Pedro,
>
> with:
>
> FormBeanConfig fbc = new FormBeanConfig();
> fbc.setName("myForm");
> DynaActionFormClass dafc =
> DynaActionFormClass.createDynaActionFormClass(fbc);
> DynaActionForm formBean = (DynaActionForm) dafc.newInstance();
> formBean.set("property", businessObject.getProperty());
> request.setAttribute("userPrefsForm",formBean);
> //End
>
> you can create a dynaBean.
> i had the problem long time ago two.
>
> why are willing to use dynaBeans for populating a JSP-Form-Page?
>
> i use "ValueObjects" or "HelperBeans" instead, which i store in
> request and with there properties the formfilds get filled to!
What you are telling me is that if I store a bean with the same name as
the form, the html tag lib will interpret it as being the form, right?
Thank you very much!
Pedro Salgado
>
> look
> http://rollerjm.free.fr/images/ClassStruts1_1.gif
> an nice diagramm :-)
>
> greetings
> Matthias
>
>
>
> -----Original Message-----
> From: Pedro Salgado [mailto:salgado.pc@04web.com]
> Sent: Saturday, January 03, 2004 5:29 PM
> To: Struts Users Mailing List
> Subject: dynaform populate
>
>
>
> Can anyone help me on this?
> I am trying to pass a populated DynaActionForm to a JSP file and I
> can't figure out how can I populate the form...
>
> I have the following sequence:
>
> - form A (name : gotoUserPrefsForm, id : String - user id)
> - action ViewUserPreferences (uses form A)
> - form B (name : userPrefsForm, severall attributes)
>
>
> ViewUserPreferences {
>
> /** @param form this is form A. */
> ... execute(..., form, ...) {
>
> int id = FormUtils.getIntValue(form, "id");
>
> UserPreferences prefs = service.getUserPreferences("id");
>
> // here starts the problem!!!
> // gets the form bean configuration
> FormBeanConfig fc =
> config.findFormBeanConfig(mapping.getName());
>
> // this is supposed to be form B
> DynaValidatorForm dynaForm = // how do I create a new instance
> with the FormBeanConfig?...
>
>
> dynaForm.set("background", prefs.getBackground());
>
> request.setAttribute("userPrefsForm", dynaForm);
>
> }
>
> }
>
>
> Any ideas?
>
> Pedro Salgado
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: dynaform populate
Posted by Pedro Salgado <sa...@04web.com>.
On 04/01/2004 16:55, "Matthias Wessendorf" <ma...@matthias-wessendorf.de>
wrote:
> Hi Pedro,
>
> with:
>
> FormBeanConfig fbc = new FormBeanConfig();
> fbc.setName("myForm");
> DynaActionFormClass dafc =
> DynaActionFormClass.createDynaActionFormClass(fbc);
> DynaActionForm formBean = (DynaActionForm) dafc.newInstance();
> formBean.set("property", businessObject.getProperty());
> request.setAttribute("userPrefsForm",formBean);
> //End
>
> you can create a dynaBean.
> i had the problem long time ago two.
>
> why are willing to use dynaBeans for populating a JSP-Form-Page?
>
> i use "ValueObjects" or "HelperBeans" instead, which i store in
> request and with there properties the formfilds get filled to!
What you are telling me is that if I store a bean with the same name as the
form, the html tag lib will interpret it as being the form, right?
Thank you very much!
Pedro Salgado
>
> look
> http://rollerjm.free.fr/images/ClassStruts1_1.gif
> an nice diagramm :-)
>
> greetings
> Matthias
>
>
>
> -----Original Message-----
> From: Pedro Salgado [mailto:salgado.pc@04web.com]
> Sent: Saturday, January 03, 2004 5:29 PM
> To: Struts Users Mailing List
> Subject: dynaform populate
>
>
>
> Can anyone help me on this?
> I am trying to pass a populated DynaActionForm to a JSP file and I
> can't figure out how can I populate the form...
>
> I have the following sequence:
>
> - form A (name : gotoUserPrefsForm, id : String - user id)
> - action ViewUserPreferences (uses form A)
> - form B (name : userPrefsForm, severall attributes)
>
>
> ViewUserPreferences {
>
> /** @param form this is form A. */
> ... execute(..., form, ...) {
>
> int id = FormUtils.getIntValue(form, "id");
>
> UserPreferences prefs = service.getUserPreferences("id");
>
> // here starts the problem!!!
> // gets the form bean configuration
> FormBeanConfig fc =
> config.findFormBeanConfig(mapping.getName());
>
> // this is supposed to be form B
> DynaValidatorForm dynaForm = // how do I create a new instance
> with the FormBeanConfig?...
>
>
> dynaForm.set("background", prefs.getBackground());
>
> request.setAttribute("userPrefsForm", dynaForm);
>
> }
>
> }
>
>
> Any ideas?
>
> Pedro Salgado
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
RE: dynaform populate
Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Hi Pedro,
with:
FormBeanConfig fbc = new FormBeanConfig();
fbc.setName("myForm");
DynaActionFormClass dafc =
DynaActionFormClass.createDynaActionFormClass(fbc);
DynaActionForm formBean = (DynaActionForm) dafc.newInstance();
formBean.set("property", businessObject.getProperty());
request.setAttribute("userPrefsForm",formBean);
//End
you can create a dynaBean.
i had the problem long time ago two.
why are willing to use dynaBeans for populating a JSP-Form-Page?
i use "ValueObjects" or "HelperBeans" instead, which i store in
request and with there properties the formfilds get filled to!
look
http://rollerjm.free.fr/images/ClassStruts1_1.gif
an nice diagramm :-)
greetings
Matthias
-----Original Message-----
From: Pedro Salgado [mailto:salgado.pc@04web.com]
Sent: Saturday, January 03, 2004 5:29 PM
To: Struts Users Mailing List
Subject: dynaform populate
Can anyone help me on this?
I am trying to pass a populated DynaActionForm to a JSP file and I
can't figure out how can I populate the form...
I have the following sequence:
- form A (name : gotoUserPrefsForm, id : String - user id)
- action ViewUserPreferences (uses form A)
- form B (name : userPrefsForm, severall attributes)
ViewUserPreferences {
/** @param form this is form A. */
... execute(..., form, ...) {
int id = FormUtils.getIntValue(form, "id");
UserPreferences prefs = service.getUserPreferences("id");
// here starts the problem!!!
// gets the form bean configuration
FormBeanConfig fc =
config.findFormBeanConfig(mapping.getName());
// this is supposed to be form B
DynaValidatorForm dynaForm = // how do I create a new instance
with the FormBeanConfig?...
dynaForm.set("background", prefs.getBackground());
request.setAttribute("userPrefsForm", dynaForm);
}
}
Any ideas?
Pedro Salgado
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org