• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Problem with 2 ActionForms for one JSP

 
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi - I'm fairly new to Struts. I thought I understood the configuration setup, but I guess not.

I have a form that, when submitted, sets the form's action value (based on a user-selected value from the form.) This part seems to work (I can output the form.action value thru Javascript & see the correct value).

Before I started the project, the form forwarded to only one ActionForm. I am giving the form more functionality, and would like to put the new functionality into a different ActionForm class, since the logic is not similar.

I have entered a new forward tag in the global-forwards section, as well as a new action tag in action-mappings section of the struts-config file. I literally copy & pasted the old ones, & copy & pasted the new name in all places that held the old name. This new name is the same (copy & pasted) as the form's action value I mentioned above.

The only way I can get my new ActionForm class to be called is if I revert back to the original configuration and simply replace the old class name with my new one. Other than that, I get nothing - no error, no stack trace, and no page.

I've reverted back to just hard-coding my new action in the jsp:


Here's the except from the struts-config file:


Not much to go on, but maybe someone can see the error I've made?

Many Thanks!
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you understand the concept of Struts (the MVC-approach)?
I'm not a Struts wiz either but as far as I know (from the little experience I have) your Form should represent the fields of your jsp page. So if you want to add functionality to your jsp by adding new fields then just extend your form with the field attributes.
If you really want a jsp with same sort of fields doing different things, then just implement a new action-form-jsp.
Your form should only contain the jsp attributes it represents and the logic should be present (or called from) within your action.
 
Gail Schlentz
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not adding new fields. Adding functionality based on user choices from existing fields.

Turns out I've done it correctly - just missed a step in a little-used permissions table in the database.

...another case in favor of DOCUMENTING CODE that others may alter!!!

:roll:
reply
    Bookmark Topic Watch Topic
  • New Topic