aspose file tools*
The moose likes Struts and the fly likes hyperlink calls database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "hyperlink calls database" Watch "hyperlink calls database" New topic
Author

hyperlink calls database

biswajit goswami
Ranch Hand

Joined: Dec 05, 2005
Posts: 35
yeah.....there r multiple hyperlinked userids,which if clicked should search a database and display the corresponding data.To search the database ,i need the userid in some bean or in some attribute??how to send the corrresponding userid to a bean through clicking a hyperlink.
eg: click hyperlinked<AS009> and i get the details of AS009 displayed in a new jsp
michelle Wang
Ranch Hand

Joined: Jan 12, 2004
Posts: 65
Hi, do you know what is MVC structure? Struts is based on it and developed. Your JSP cannot directly call DB to do the search function right? So you will need a "action" class to handle the user request on the server side. So you can put the value u want pass to DB into a attribute with a request in JSP, like this:

<a href="../action/ShowClientProfileAction.do?clientID=<%=clientID%>">

Then in your action class, you may need to get the attribute first, like this:

int clientID = Integer.parseInt((String) request.getParameter("clientID"));

from here, your action class can use the clientID and call DB class to do the search function already.

Hope this helps.


michelle Wang <br />SCJP 1.4
biswajit goswami
Ranch Hand

Joined: Dec 05, 2005
Posts: 35
Thanx for the solution........But if it is desired that there should be no getparameter in the action class and that all the input paramters should be fetched from a Form class then is there any solution?
michelle Wang
Ranch Hand

Joined: Jan 12, 2004
Posts: 65
I only make use of the action Form that when the first page is really a "Form", which means the page has text fields, check box, dropdown menu these user input elements and you need to validate them. Nobody say when using struts must follow every thing inside right? I just combining all the knowledge i know and choose the most suitable one to make it works, that's all.
pankajjj jain
Greenhorn

Joined: Oct 12, 2005
Posts: 14
HI

you can put the userid in a text box by java script and textbox can be easily fetched by Action Form
biswajit goswami
Ranch Hand

Joined: Dec 05, 2005
Posts: 35
Thanx for ur replies.Jain,my situation does not permit ur solution.Wang i too feel that i should directly take the attribute in the action class using getParameter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hyperlink calls database