File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Composite View Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Composite View" Watch "Composite View" New topic
Author

Composite View

Matthias Zeilerbauer
Greenhorn

Joined: Sep 01, 2010
Posts: 13
I have a problem with understanding the composite view. I use struts 2.0 for my FrontController and I want now that my pages have a template index.jsp (header, navigation, main) and that load automatically the right content. On the website http://www.oracle.com/technetwork/java/compositeview-138350.html I found a brief description of Composite Views but I don't understand it completly, I think.

My Website Environment:
- Tomcat 6.0.29
- Eclipse Java EE Helios
- Struts 2.2.1

This is how I made my Website:

I have a LoadAction which i must give the parameter "main" that it sets the attribute "main" and forwards it to my index.jsp which than includes the the value of the "main" attribute.

index.jsp file:


My LoadAction.java:


This my navigation.jsp which till now only inherits one link to load my createTerm.jsp:


But I think this is not a good solution? Very bad performance...even when I make some approaches. Is there a better solution to load dynamically (with a navigation) content in my template index.jsp? And the main question have I implemented the Composite View correctly?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It's not at all clear to me what you're doing (besides that you say you're using both S2.0 and S2.1.1, but your code is Struts 1).

Let's straighten that little issue out first before we get into the fact that Struts already *is* a controller, and you're introducing an unnecessary layer on top of it, and badly, since you're coding direct references to pages, and page types, in your Java.
Matthias Zeilerbauer
Greenhorn

Joined: Sep 01, 2010
Posts: 13
David Newton wrote:It's not at all clear to me what you're doing (besides that you say you're using both S2.0 and S2.1.1, but your code is Struts 1).

Let's straighten that little issue out first before we get into the fact that Struts already *is* a controller, and you're introducing an unnecessary layer on top of it, and badly, since you're coding direct references to pages, and page types, in your Java.


I must admit that I have not much experience with struts. But I downloaded struts 2.2.1 and so I wrote that as my environment. What would be the diffrence? Because I don't want to learn old technologies, expect the new one is build up on it.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

They are entirely different frameworks.
Matthias Zeilerbauer
Greenhorn

Joined: Sep 01, 2010
Posts: 13
David Newton wrote:They are entirely different frameworks.


Ok then I will search for another solution (struts 2.2.1). But one more question can I make with struts 2.2.0 (I mean has struts 2.2.0 support for) custom tags composite view? Because I didn't find anything about it. (or oversaw it)
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Custom tag support is completely unrelated to backing framework. S2 supports Tiles, SiteMesh, standard JSTL page composition, and so on.

But it's still not clear to me what you're trying to do.
Matthias Zeilerbauer
Greenhorn

Joined: Sep 01, 2010
Posts: 13
I want to implement "custom" tag composite view in my Website. I know that a backing framework has nothing todo with custom tags. My question is if the backing framework (struts 2.2.1) has a solution (tags or something) which i can use to implement my composite view. Custom tags is maybe the wrong expression because they are implemented in the framework...sorry that was unclearly explained. I had that expression from "http://java.sun.com/blueprints/corej2eepatterns/Patterns/CompositeView.html" and I don't know a better expression because composite view can be also the very unflexible way of JSTL (with <jsp:include). So my really question is if there is a more flexible one with struts 2.2.1?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I already said that Struts supports both Tiles and SiteMesh. And I think you're prematurely discounting smart usage of c:import and the like, which is a very lightweight way to composite views. I'm not sure what else to tell you.
Matthias Zeilerbauer
Greenhorn

Joined: Sep 01, 2010
Posts: 13
No ok, thanks thats perfect. Now I will try a little.
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Composite View
 
Similar Threads
JSF Spring integration
web portal in struts and nothing is working at all
I think execute method is not executed...(confused)
how do i use checkbox as an active/inactive button for a form?
Need Help on struts....