Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass value on clicking link

Status
Not open for further replies.

a4b4

Programmer
Jan 6, 2004
1
IN
Hi!
I need to pass a value whenever a user clicks on a link.
I have an application which provides for permanent and trial users. I need to pass a value say type="trial" when the user clicks on link named trial and type="permanent", when clicked on permanent.
I am using the following format now and wish to add this facility
<html:link forward=&quot;trial&quot; > Trial </html:link>

Also, once I do pass the value from here, how to receive it in the Form and Action classes?
Thanks in Advance,
Shanky
 
well, if you wanted to use a button class, you could handle the operation of clicking a button in your action class and then execute to the correct code.

you could also use javascript onclick=&quot;function name&quot; in your struts tag to call form posting in a function defined on the jsp. You can pass the value in the tag. (trial/perm)

Also,
for your form, you can use getter and setter methods. You want to use the property parameter in your struts tags to connect to the methods.
Ex: <html:text name=&quot;blah&quot; property = &quot;userType&quot;/>

in your form:

getUserType(){
return(usertype);
}

setUserType(){
this.usertype= usertype;
}

the property value actually calls the getter method.
notice the case difference or userType, its ok, struts will take care of it.


hope this helps, I am still kind of new to this!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top