How to pass data with actionform if no html form?

K

kai via JavaKB.com

Hi,

Basically is it possible, for instance, if there are html links in a page that lead to different actions. But there is no form in the page. How can I pass data in this case? Or is there a way to make all the links a POST to the action?

Thanks
Kai
 
N

naiki

Hi,

Basically is it possible, for instance, if there are html links in a page that
lead to different actions. But there is no form in the page. How can I
pass data in this case? Or is there a way to make all the links a POST
to the action?

Thanks
Kai
Hi

Only way to do post to action (btw, u mean struts action i guess?) is use
of form html element. With plain html link you can only make GET requests.

so you can use either GET:
1a) <html:link page="/your_action.do" paramId="form_property_name"
paramName="beanName" paramProperty="beanProperty">Blabla</html:link> for
only one simple property.

1b) or use of map of properties with <html:link page="/..."
name="..." property="...">...</html:link>

1c) or simplest case: <html:link
page="/your_action.do?form_property_name=some_data">Blabla</html:link>

----
or if you need use of POST you will need form for this...
if you cannot(dont want) use <html:form> tag (target action have not
defined any form bean) you can use <form
action="/your_context/your_module_if_needed/your_action.do" method="POST">
<input type="hidden" name="form_property_name" value="some_data"> ...
<html:submit>Click me</html:submit>
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top