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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Frames in struts" Watch "Frames in struts" New topic
Author

Frames in struts

Debasmita Dash
Greenhorn

Joined: Apr 07, 2009
Posts: 19
I have a jsp page that displays the list of folders. When one of the folder name is selected the contents of that folder is diplayed in another jsp page.


I want that when one of the folder name is clicked, the jsp page that displays the contents of the folder to be shown as a frame in the same jsp page at the right.

Thanks....
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

How is this related to struts that I don't know, but you can create frames in your page and use the target property of <a> tag to target the hyperlink to the frame...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Debasmita Dash
Greenhorn

Joined: Apr 07, 2009
Posts: 19
Thanks for your concern..
Following are the entries in struts-config file.


By using <html:frame> in DisplayContents.jsp I am not able to get the content of ListOfCabinets.jsp.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

...

Including the JSP code that isn't working might help.
Debasmita Dash
Greenhorn

Joined: Apr 07, 2009
Posts: 19
Following is the jsp code.

David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

While I'm not familiar with the "frame" tag, its documentation leads me to believe you're using it incorrectly, since your usage does not include *any* attributes.

Why would you do all that work in the JSP file? That's what actions and service objects are for.
Debasmita Dash
Greenhorn

Joined: Apr 07, 2009
Posts: 19
Will you please give any idea how to do it....
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Do what, use the <html:frame> tag, use the HTML anchor tag's "target" attribute correctly, or writing all your code in the JSP?

If you're talking about using the anchor tag: in your example you're using the "href" value for the "target" attribute. If you're having issues with frames and HTML tags you'll probably want to post in the HTML forum--once you get the basic HTML worked out *then* you can get back to the Struts stuff.

If you're talking about writing all your code in the JSP, there's almost never any reason to do this. The reason servlets and JSPs exist is to separate code and presentation. The reason Struts exists is to further the abstraction: Java code should be written in Java files, JSP should be used to present data processed in the Java files.

Besides, the HTML you posted does not seem to be well-formed: issues like this can be seen readily when indentation is used consistently. Here you're starting a new table row inside a table cell, are opening potentially multiple div tags and never closing them, don't close the try/catch block, and so on. In short, it's a mess.It's easy to see when this is formatted consistently that something has gone wrong.

Besides the malformed HTML:

* None of this Java code should be in the JSP. It should be in a service object used by the action.
* The "tree.xml" file should be either on the classpath or use a path relative to the server context.
* It should be cached, otherwise you're parsing XML *every* time the page is loaded.
* If the attribute map is a *map* then why are you *iterating* over it to get the ID?! It's a map: get it using map access.
* The table cell containing everything has a height attribute of "1". That's really short, and almost certainly not what you want.
* If the node value is really the cabinet name, as implied by the improperly-used "target" attribute, then you'll need to quote it to pass it to the JavaScript function. If it's guaranteed to be a numeric value then you're okay. I would, however, be wary of using it, unadorned, as the id for a DOM element.

This would lead to JSP code much closer to the following (although not really understanding the structure you posted some of it is just a close approximation:I'd also consider moving the code for each individual line into a JSP-based custom tag file; this would clean up the main JSP page considerably, leading to the even cleaner:You're welcome! Consider having your employer make a donation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Frames in struts
 
Similar Threads
Problem in passing dataaftr a link is clicked
Display the contents of folder when the link is clicked
Tree view in struts
linking jsp pages in a liferay portlet
Passing variables from one JSP to another