Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > [Strus] ActionForm not dispalyed

Reply
Thread Tools

[Strus] ActionForm not dispalyed

 
 
Hamvil
Guest
Posts: n/a
 
      02-28-2005
Hi,

I have a problem with with the struts framework. I've already looked
in the news for an answer but i've found nothing.

Basically i would like to fill a form with the data obtained from a
database. Here follow a small part of the code:

try {
actionForm = registerManager.loadProfile(id);
} catch (Exception e) {}

basically actionForm is the one passed by the execute mathod.

The method loadProfile returns an object RegisterBean (which extends
ActionForm) that contain the user data loaded from the database.

After the output is forwarded to edit.jsp, but nothing is displayed in
the form.

If for example i replace the previous code with:

((RegisterBean)actionForm).setName("Something");

everything works fine and the name is correctly displayed in the form.

It seems that by assigning to the actionForm another object the struts
environment lost the binding with the form.

Can anyone help me???

Thanks
Roberto
 
Reply With Quote
 
 
 
 
Wendy Smoak
Guest
Posts: n/a
 
      02-28-2005
"Hamvil" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...

> Basically i would like to fill a form with the data obtained from a
> database. Here follow a small part of the code:
>
> try {
> actionForm = registerManager.loadProfile(id);
> } catch (Exception e) {}
>
> basically actionForm is the one passed by the execute mathod.
>
> The method loadProfile returns an object RegisterBean (which extends
> ActionForm) that contain the user data loaded from the database.


I don't think you're supposed to construct your own form-- there's more to
it than the data. If you look at the API, you'll see some other attributes
that your own form is probably missing.
http://struts.apache.org/api/org/apa...ctionForm.html

There is a way to ask the framework to make you a new form bean, but in this
case you don't really need that.

Instead of trying to replace the form bean with your own, try copying all of
the matching properties into it with:
BeanUtils.copyProperties( form, objectFromDatabase );

The Struts example webapp has an example of prepopulating a form. Using
forms as Data Transport Objects is generally frowned upon as it
unnecessarily couples your data access layer to Struts.

--
Wendy


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: IP address dispalyed on desktop , how Jordon Computer Support 1 11-12-2010 08:40 PM
Re: IP address dispalyed on desktop , how Bucky Breeder Computer Support 0 11-12-2010 07:43 PM
Re: IP address dispalyed on desktop , how RickMerrill Computer Support 0 11-12-2010 06:29 PM
Re: IP address dispalyed on desktop , how alan Computer Support 10 11-12-2010 02:32 PM
Re: IP address dispalyed on desktop , how Mike Easter Computer Support 2 11-11-2010 04:08 PM



Advertisments