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 html:link Submitting form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:link Submitting form" Watch "html:link Submitting form" New topic
Author

html:link Submitting form

Jera Blade
Greenhorn

Joined: May 08, 2005
Posts: 15
I have a search jsp which brings back a collection of results. the user selects a certain user and then clicks the link to edit this particular user. However the information is not getting sent to the action form and subsequently the action class throws a null pointer.

The link is defined as follows in my jsp:

<html:link forward="editClient"></html:link>

The struts config has the following:

<global-forwards>

<forward name="editClient" path="/actionClient.do?action=edit"/>

</global-forwards>

and:

<action path="/actionClient"
type="com.medina.web.action.ActionClientAction"
name="actionClientForm"
scope="request"
input="/searchClient.jsp">
<forward name="edit" path="/createClient.jsp"/>
</action>

When i click on the link the actionClient mapping is called but the values from the jsp are not submitted through the form to the action class. How would I get the values into the form if I am using a link. The reason I am using a link is because this page will also have the option to delete a client and I want to append a request parameter to the URL so the action class will check the parameter then decide what to do.

If I use a submit button the values are passed through.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

If you use a link, you must use javascript to submit the form.


A good workman is known by his tools.
Jera Blade
Greenhorn

Joined: May 08, 2005
Posts: 15
IF I have to use javascript what is the point of the action element and the forward element calling a action mapping? Are these only to be used when I am not submitting a form.
Bram de Jager
Greenhorn

Joined: May 12, 2005
Posts: 1
Are these only to be used when I am not submitting a form.


Yes. If you want to pass some values, always use submit in some sort of way.
c chapman
Greenhorn

Joined: May 10, 2005
Posts: 7
I am trying to do something similar in my application. I have a jsp page that displays a list of customers. In the page, I iterate through a collection of CustomerForm objects, and for each customer there is a link to take to another page where I want to display the customer details for editing. The link contains all the necessary parameters obtained from a Map (I have viewed the source of the page and the parameters are set correctly).

On the next page, how do I fetch the parameters without resorting to scriptlets? If you can fetch the parameters via the request object using scriptlets why can you not obtain them from the request object in the Action class? (I have tried using a forward in the link that forwards to an action that fetches the parameters from the request object but the paramaters appear to be null).
Damanjit Kaur
Ranch Hand

Joined: Oct 18, 2004
Posts: 346
If you can fetch the parameters via the request object using scriptlets why can you not obtain them from the request object in the Action class? (I have tried using a forward in the link that forwards to an action that fetches the parameters from the request object but the paramaters appear to be null).


Well, I don't know the answer to your question. But using action instead of forward in the html:link tag will solve your problem of accessing the parameters in Action Class.
Kaiser Lautern
Greenhorn

Joined: May 11, 2005
Posts: 18



Yes. If you want to pass some values, always use submit in some sort of way.


Just to clarify one doubt of mine: the answer for this is the "submit" or the POST method? I mean, if I use a form/submit with a GET method instead, will parameters be sent too? I read once (don't remember where) that you can only send parameters to an ACTION using POST (which you can't do via links).

Kaiser
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:link Submitting form
 
Similar Threads
Struts module problem
Not getting bean values inside IE, In firefox working fine
In struts Can't display dynamic content using "include"?
[URGENT]Problems with Struts and Tiles
Cannot find bean in any scope