Laurie Harper a écrit :

Sure.
DynaActionForm dForm = (DynaActionForm) form;
dForm.set( "name", person.getName() );

You can also use BeanUtils to copy properties from the Person to the Form bean:
BeanUtils.copyProperties( dForm, person );

Il get this error:

javax.servlet.ServletException: Invalid property name 'name'
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:516) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:423) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

*root cause*

java.lang.IllegalArgumentException: Invalid property name 'name'
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:600)
    org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:413)
fr.lifl.existant.struts.action.ChoisirHomonyme.execute(ChoisirHomonyme.java:67) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

?

Thanx,

Manu.


Did you specify a 'name' property in your form bean declaration in struts-config.xml? 'Dyna' forms only have the properties you specify. I've never used them, but I think the 'lazy' versions allow you to use arbitrary properties without having to declare them.

Yes name is specified. I think it needs more explanations. My action sequence is:

jsp0 -------> Action1--------> jsp1 ---------> Action2 --------> jsp2
                        |                                               |
                  Formbean1                             Formbean2

I would like to pre-populate Formbean2 in Action1 to put default values in jsp1. Formbean2 specifies a name property. Unfortunately, when i code this

DynaActionForm dForm = (DynaActionForm) form;
dForm.set( "name", person.getName() );

in Action1 dForm refers to Formbean1 (not Formbean2). Formbean1 is used to get informations entered in jsp0. Since Formbean1 does not specify a name property (it does not need any), i get an error.

My question is then:

How to populate Formbean2 in Action1?

Thanx,

Manu.

--
Emmanuel Leguy                  LIFL - UMR8022 CNRS - Bat M3
Tel: +33 3 28 77 85 32          USTL - Universite de Lille 1
Fax: +33 3 28 77 85 37          59655 VILLENEUVE D'ASCQ CEDEX - FRANCE

mailto:[EMAIL PROTECTED]        
http://www.lifl.fr/ANNUAIRE/employee.php?login=leguye

Ce mail est signe par un certificat X509 fourni par le CNRS
La verification de ce certificat peut etre faite a l'adresse suivante: http://igc.services.cnrs.fr/CNRS-Standard/recherche.html

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to