This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Now, I wanted to do to same thing with a link -- <html:link action="/myAction" on*lick="setact('6')">Link</html:link>
Unfortunately, this does absolutely nothing. No errors anywhere but does not set the "action" field like the image tag does. Any thoughts why?? I'm sure I'm missing something simple but just don't see it.
I have few questions running around me. Pls clarify it to get some answers for you.
1. How did you verified that sets a form bean field to the appropriate number of images clicked? In this case, the value you are expecting is 2. Have you verified from client or server side?. Have not seen any codes to submit the form.
2. Why did you included action attribute in html:link tag?
Joined: Feb 10, 2006
Thanks for helping me think this through. And your second question is excellent!
1) On the server side I simply write out the value of my FormBean property/field and check the log file:
2) Your question about the action attribute, I think identifies the problem here. Correct me if I'm wrong ...
I thought if I used the link tag INSIDE the form I could also have the form fields avaiable (hidden "action" field). But apparently this is not the case. When the link is clicked, the request is sent to myAction.
Joined: Jul 26, 2005
Gregg, just a little push. extremely sorry for the delayed response.
I think, any form elements or the hidden variables must be enclosed with in <html:form/> tag.
One more question, why do u want to place the link outside the form tag? any specific reasons?
No matter where a link is placed, whether inside or outside of a <html:form></html:form> tag pair, it does notcause the form to be submitted. It merely calls the URL in the link wihout passing any of the parameters in the form to it.
There are two possible solutions to this:
1-Make the link refer to something non-operational, and use the onclick event to submit the form. Something like this:
2-If you just want to submit the form with the "action" parameter and no others, you could simply incorporate the parameter into the URL like this:
<a href="myAction.do?action=6">click here</a>