File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Action Mapping in the struts-config.xml When There Is No Form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Action Mapping in the struts-config.xml When There Is No Form" Watch "Action Mapping in the struts-config.xml When There Is No Form" New topic
Author

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

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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

Joined: Feb 05, 2003
Posts: 4727

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


A good workman is known by his tools.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31057
    
232

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Action Mapping in the struts-config.xml When There Is No Form