• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tiles advice

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am still very new to struts framework, but I already have done some examples and got them working. Because I am still learning, I want to get it done right and one thing that I am not confident about is using tiles. There are several ways in using the tiles, but I want to know what is the best and most general way of using them.

So what I want:
I have a simple page layout and it consists of two things: navigation menu - just links that stays the same and a content area which needs to be updated after every action.
For example it is a simple e-shop web-application on a very early stage. So the navigation has links to: products, serach product and contact and according to content area, it displays: list of products, serach form and contact information.

So how I would do it:
Create a main layout for the page and then for each new content, I extend a main layout and add information about the content area to tiles-defs.xml:


So then create the jsp files to the "/content" directory, where search-form.jsp and contact.jsp are pages with static information and products.jsp would get its data from database for example.

So for displaying products, I make action class and add action mapping to struts-config.xml:


And in web.xml there is nothing new:



So the links in navigation.jsp would be like so:


I don't deal with product searching right now ...


OK, so that would be it. Would that be a reasonable solution?

And here are my doubts:
1. It is very simpel layout, where only content area changes. Do I really have to make a new layout definition to tiles-defs.xml and make global forward to struts-config.xml, when ever there is new action on the web-app or is there some kind of shortcut?

2. To use tiles, all my links on the navigation and perhaps in content area allso have to be processed through struts-config.xml by forwarding it to proper tiles definition. In other words - all the links must be *.do - so I can apply a layout definiton to it?



That is it for now.

[ April 15, 2006: Message edited by: Juhan Voolaid ]
[ April 17, 2006: Message edited by: Juhan Voolaid ]
 
Juhan Voolaid
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Up!
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not exactly sure what you are asking. Yes, for each page you create a new tile definition entry that specifies what page to use for the content and you create a new action definition. I suspect that there is a way to forward to a tile definition without going through an action, but I have not done it nor had a desire to do it. If you do not need to perform any processing in your action, you can use one of the built in actions.

- Brent
 
Juhan Voolaid
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brent Sterling:
Yes, for each page you create a new tile definition entry that specifies what page to use for the content and you create a new action definition.

If you do not need to perform any processing in your action, you can use one of the built in actions.

- Brent



Thanx for answering, but could you give a small example of that "built in action"?


Another problem is, that my page has option for logging in and I want to use another layout the page user gets logged in. How could I do that?

In my tiles definitions I already have seperate layouts, for example:


The problem is, if I have a link "/products.do", I want that when user is online, the products-online layout is used and if offline, the prodcts-offline layout is used. Could that be done somehow, or I must use different links, to use different actions, like "/products-online.do" and "/products-offline.do", which would not be that cool


Thanx.
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I typically do not use the built in actions...mostly because my actions derived from a base action class that handles some common functionality. Here is the list of non-abstract actions that I see with Struts 1.1: SwitchAction, ForwardAction, and IncludeAction.

It seems possible that you could have your actions return different forwards based on the login status. Say "success-online" and "success-offline". Depending on the difference in the user interface, it might be easier to control the layout in your JSP rather than having different tiles definitions for each page.

- Brent
reply
    Bookmark Topic Watch Topic
  • New Topic