• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action Mapping in the struts-config.xml When There Is No Form

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I often have to call a servlet which extends Action; but, I do not have a form submitted.

The action mapping in the struts-config.xml gives me problem when I leave out the 'name' attribute; for example:
{CODE]
<action
roles="administrator,contributor"
path="/article/Edit"
parameter="org.MyOrg.MyProj.article.FindByArticle"
name="articleForm" // if this is left out
scope="request">
<forward
name="success"
path=".article.Form"/>
</action>
[/CODE]
I really do not have a form for this action. What should I do?
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Submissions require a form.
You can check out Scaffold's NullForm for an idea of what to do for your situation.

Actually, here's the code:
Copyright (c) 2001 The Apache Software Foundation. All rights
reserved.
/**
* Empty (or "null") form for use with "formless" forms.
* The Struts JSP tags require a form bean to create elements like
* buttons, even if one is not actually needed.
* The NullForm placates the tag by providing an empty form.
*/
public final class NullForm extends ActionForm {

// blank form for use with command buttons

} // end NullForm
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34218
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JiaPei,
I've done pages without a form (you can't have an HTML page or buttons on the page either i believe.) You need to leave out the scope attribute too.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic