aspose file tools*
The moose likes Struts and the fly likes html:link problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:link problem" Watch "html:link problem" New topic
Author

html:link problem

Chris Perth
Greenhorn

Joined: Oct 15, 2003
Posts: 21
Hi you guys...
I got a new problem with my serach from!
(still haven't solved the one about the html:select... really, so frustrating!)
It worked so far when I enter the info I want it to be searched for (into the
database) then it lists the table correctly, BUT now I wanted to add a
LINK to some of the results, so that when you click on the link you'll be
forwarded to another page with another table with more (detailed) info
about that one texture.
For those who didn't read my other post, here's what I have:
a MySql database,
a search form which you can type (or select) the search criteria
(for example, you wanna see a list of all textures with have a
particular color, so you select the texture and let's say, black,
then click the button search that submits the action that grabs
the info from the action and form .javas
and you see a small table that was created with all the textures
with that color...
The table that you see as search result is printed in the
searchresult.jsp but the code with the html table and sql results
comes all from the .javas...
The question is, how can I add a html:link to my Action class?!
Is that even possible?!!
I tried already and it compiles ok but whatever Struts tag I put
inside a .java doesn't work!
The link works only if I use normal HTML link, but if I do that then
I can't use an action to grab the detailed view for that texture!!!
I hope you can understand what I mean, if not let me know and I'll
try to formulate the problem another way, I'm pretty new on this
but I'm really hoping I can learn what's possible and what's not
with Struts!
Thank you for any ideas/input on this! I really appreciate it!
Chris
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
Hey chris,
I am sorry i dun know the answer to this one but i am starting to work on struts with mysql and would like to know what kind of experience u had using struts with mysql. I would appreciate if you could gimme your messanger id. Also, i replied to your other post. I think that will help you.
TIA
Sahil


Adios
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Chris,
I'm not quite sure what you're trying to do. If you post some of the code from your action class and some of the code from the jsp, maybe it will be a little clearer. Please surround your code with UBB [ CODE][ /CODE] tags (take out the spaces after the [ )
"desi dude", please check your email.
[ October 22, 2003: Message edited by: Jason Menard ]
Chris Perth
Greenhorn

Joined: Oct 15, 2003
Posts: 21
Hi Jason, thanks for answering!!!
I'll try to explain...
My problem doesn't lay on my jsp but rather on my java class!
I have 3 .javas which need each other to make the search form work:
There's the
SearchAction.java
SearchForm.java
and the
DisplaySearchResult.java
On my searchContent.jsp there's the html:form with the name of the action.
The form has the select and text fields in which you enter the search criteria.
When you press the search button the SearchAction.java is called (and it itself
calls the SearchForm.java to get the value from the fields).
Then (if everything goes well with the sql) it's all sent to the DisplaySearchResult.java.
The DisplaySearchResult.java prints in searchResultContent.jsp the table
with the search result according to the search criteria.
The problem lays in the DisplaySearchResult.java!
Here's a piece of the code where the database values are put into a table to
be printed: (rs is the ResultSet from the database)

As you see above, I can only add the link in my DisplaySearchResult.java IF it's
a simple HTLM link!
What I wanted (and already tried but didn't work) was something like this:

If I add any kind of html:link or whatever that's not simple html, it isn't interpreted as it
should!
It turns up as a normal link or something. Maybe it's a common knowlege and I'm too
new on this, but if it is so (that this kind of forms and links can't work inside a .java)
then what can I do??!!
These 'texture' values that are gotten from the database HAVE to have some sort of link that
will take upon clicking to another page which, will call yet another new DetailedAction.java
which will print another table with detailed info (also from the database) from this texture!
Know what I mean now? I hope I didn't make it all even more confusing to be understood...
For any ideas I'd be thankful!!!
Chris
[ October 23, 2003: Message edited by: Chris Perth ]
Chris Perth
Greenhorn

Joined: Oct 15, 2003
Posts: 21
Hi Sahil,
thanks for answering to my other post... I'm still working on both my problems.
I can't use my messanger at the moment so I'll have to answer you right here
(about my experience with struts and mysql)...
Like you I've just started working with that, so I can't say I have much experience
at all, unfortunately. Learning mostly by trying and by (MANY) mistakes... :roll:
It's all very interesting but also complicated & stressful...
Anyway, I wish you a lot of luck with struts & mysql!
Take care!
Chris
Priyanka Chopda
Ranch Hand

Joined: Jul 22, 2003
Posts: 112
hi,
If I were you I would first fetch results from database. Then instead of writing the out.println things in java class itself, would use <html:iterate id="element">
...........
<a href='<bean:write name="element" property="texture"/>
<bean:write name="element" property="texture"/>
</a>
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
If it was me, I would probably do something like this:
SearchResult.java

ColorTextureQuery.java

SearchAction.java's execute() method

DisplayResults.jsp

DisplayResults.jsp would then create a table that looked something like the following for each result returned from the DB:

I made the assumption that you have some parameter 't' which you pass to your Action which reads this parameter to determine the texture. If you needed to have more than one parameter for your link, you would have to do things a little differently and have a map which contained your parameter/value pairs (see API), but the code as given is fine for a single parameter.
Using the way I did it, you confine your database query to a business object in order to keep your layers separated. You also use the power that jsp and the struts custom tags give you (you could also use jstl if you'd like) to make life easier for you and your code more maintainable. Did I interpret your problem correctly, or am I way off base here?
[ October 23, 2003: Message edited by: Jason Menard ]
Chris Perth
Greenhorn

Joined: Oct 15, 2003
Posts: 21
Thank you so much Jason,
I'll try that out and post to say if it worked!
I hope it does!
Take care
Chris
Chris Perth
Greenhorn

Joined: Oct 15, 2003
Posts: 21
It's workiiiiing!!!

Thanks!
Chris
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:link problem