• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to implement tabs and workspaces within tabs.

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to create tabs within my Struts application where once a tab is selected, there will be navigation links down one side, and when links are selected, the remainder of the tab area will serve as the "workspace" for displaying the corresponding JSP page. I have tried using the struts-display tag library and have been able to generate tabs and panels for my links, but I'm not sure how to direct the jsp output to a specific panel in a tab.

Is there a better method to do this? I would like some possible suggestions on ways of accomplishing this that has ample documentation. I know this is a very common design these days, so I know there has to be a better way (or at least one with more documentation than struts-display library). Just looking for suggstions on technologies/frameworks that I could start investigating.

Thanks in advance,
Scott
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've always just used good old HTML, CSS, JavaScript and an iframe to hold the "workspace".
 
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great suggestion. When I try using the iframe tag (pointing to test.jsp) I get the 404 resource not found error in Tomcat. Here's how I have it coded:

<IFRAME ID=adminlist src="/WEB-INF/jsp/mlist.jsp">
</IFRAME>

All my jsp files are kept in Tomcat under the /WEB-INF/jsp/ directory. Do I need to do anything differently? Usually I can just put the path from web app root directory to jsp directory and the app can find the files. Why is this different?

Scott
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Servlet containers do not allow web access to files under the WEB-INF directory.

In and MVC environment (such as with Struts), you typically forward to any JSPs. The browser is not requesting them directly.
To preserve your MVC archetecture, create a controller servlet that forwards to these JSPs using a requestDispatcher. Otherwise, move the JSPs out from under WEB-INF.
[ May 19, 2006: Message edited by: Ben Souther ]
 
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my application, I have an action servlet that dispatches to one jsp, but now with iframes, that jsp page contains two iframe tags that both point to separate jsp pages. So, I'm dispatching to one jsp file that needs to refrence two other jsp files contained in iframe tags.

I hope I'm following your advice correctly. If not, please point me to some reference material on this type of thing. I'm just looking for a simple example (with code snippets).

Thanks for everyone's patience.
Scott
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember, in a page with frames, each frame generates a completely seperate request.

You could either

  • enhance your controller so that is knows how to dispatch to different JSPs according to the URL (preferred).
  • Create servlet entries and servlet-mappings for each of your frame JSPs.
  • Move the JSPs out from under the WEB-INF directory so that they can be accessed directly from a browser.

  •  
    Scott Updike
    Ranch Hand
    Posts: 92
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Are you saying that I would code the iframe SRC property in a way that the controller knows that this request is coming from this particular frame (and only this frame)?

    I think I need an example. Can you suggest a link/book/paper that has a simple example of how to do this?

    Again, many thanks.
    Scott
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Here's one approach.

    Lets say you have one controller for the app.
    Set up one mapping that grabs any requests that end with ".do"



    Now, lets suppose you have 3 JSPs (a frameset, a menu, and a main page)
    Your framset (index.do) will have two frame tags:


    Now in your controller, write code that analyzes the URI and forwards to the proper JSP according to the URI




    When you hit the initial page, the servlet will forward to the index.jsp (your frameset page) page. Once the page loads in the browser, the browser will fire off two new requests, one for the menu and one for the main page.
    The controller will analyze each of these requests and forward to the correct JSP.
     
    Scott Updike
    Ranch Hand
    Posts: 92
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Wow. Great response. I'll work with it and see where it goes.

    Thanks a lot for taking the time to provide an example. I'm also just starting the chapter on the command design pattern - what great timing.

    Scott
     
    Scott Updike
    Ranch Hand
    Posts: 92
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok, I have one last question. When I try and add the frameset tags into my jsp (my tab actually) I don't see any output at all. I would at least expect to see empty frames or frames with the "Page not found" error, but I don't see the outlines of the frames at all. Here's my main display page:

    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %>
    <head>
    <layout:skin/>
    </head>

    <html>
    <body>
    <layout:tabs styleClass="FORM" width="100%">
    <layout:tab key="Administration" width="50">
    <frameset cols="20,*">
    <frame src="display.do" />
    <frame name="workspace" />
    </frameset>
    </layout:tab>
    </layout:tabs>
    </body>
    <html>


    Where the controller forwards the display.do to a jsp page which lists my links. What's interesting is that when I was playing around with the iframe tag, I was getting it to display, but when I switched to the frame tags, I see nothing - just an empty tab. I really like the functionality of the frame tag as opposed to iframes.

    Do you know if there are any known issues with having frameset and frame tags within a display:tab tag?

    Thanks,
    Scott
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I'm not a big user of Struts so I'm not sure what the tab tag does.
    You might want to ask that this thread be moved into the Struts forum.
     
    straws are for suckers. tiny ads are for attractive people.
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic