• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can one action be mapped to more than one ActionForm?

 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem when developing the application using Struts.

We have a list page, which shows 50 records in a page. There is a checkbox for each record, so that the user can select some message to perform some actions.

If the user checked one record, and click update, the JSP for single update will be shown. If the user checked more than one records, and click update, the JSP for multiple update will be shown.

Since the single update, and multiple update contains some difference, for example, for single update, the user can update any fields of the record. But for multiple update, the user canNOT update the fields, instead, he can add some attachments, and change the overall status of the recordS.

Thus, the data captured by 2 views in fact are different, but as both of them perform the update, I group them into the update action.

However, can I do that? Since I need to map an ActionForm to each .do action, but now, I need two, so, how can I do that?

Or simply I should seperate the .do action into two?

Please advice.

Nick
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't sure for my answer..

My answer.
1. you should be keep data in web session scope (Data will display in this page)
2. When user click in check box and click update button, you must use

request.getParameterValues("name");

to get data from checkbox for update data are selected

this answer will help you..
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont want to keep data in the session scope becos:
1. It is not a good practice for keeping many things in the session;
2. It is difficult to determine when to clear the variables inside the session scope;
3. The application invokes BLOB, and thus, it may exceed the max. # of data inside the session.

Thus, I am thinking of, whether I should centralize the actions inside the DispatchAction if I can bind 2 forms into 1 single action, or I should simply define 2 actions with 2 forms.

Nick
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

if I can bind 2 forms into 1 single action, or I should simply define 2 actions with 2 forms.



I don't see the reasoning for 2 forms into 1 single action. But, you can bind 2 actions with 2 forms using BeanUtils.copyProperties.

FirstForm firstForm =(FirstForm) session.getAttribute("firstForm".toString());
SecondForm secondForm = new SecondForm();
BeanUtils.copyProperties(secondForm, firstForm);

I hope this helps.
Shed
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I do want to put the form into the session as a session variable, are there any other ways to do it?

Will this work if the form is in request scope, not session scope?

Nick
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic