• 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

html:link Submitting form

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you use a link, you must use javascript to submit the form.
 
Jera Blade
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




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
reply
    Bookmark Topic Watch Topic
  • New Topic