• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Including JSP in a JSF framework

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I am having a problem including a jsp page into another jsp where both are using the JSF framework. My current setup is like this.

A.jsp
<taglibs>
<html>
<body>
<table>
<f:view>
<h utputText />
.........more code......
</f:view>
<jsp:include page="B.jsp" flush="false" />
</table>
</body>
</html>

B.jsp
<taglibs>
<% scriptlet %>
<f:view>
<h:form>
<table>
...Some table stuff...
</table>
</h:form>
</f:view>

Hopefully someone can look at this and give me some advice on how to structure the <jsp:include>, I've tried all sorts of things. I've tried subview in different ways to no avail. Thanks for the help.

Patrick
 
Author
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must use <f:subview> instead of <f:view> for the included page if you use dynamic includes. There are many other issues regarding dynamic includes, so I recommend using static includes whenever you can instead. If so, no <f:subview> element is needed because the content of the statically included file ends up as part of the including page before it's compiled.

For questions about JSF, I recommend Sun's JSF forum:
http://forum.java.sun.com/forum.jsp?forum=427

I try to answer some questions here, but you have a much better chance of getting an answer in the JSF forum.
 
Patrick Ferguson
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Hans,

I'm also posting this in the Java forum. But I tried what you said about putting the included page in <f:subview> tags, and it does something really odd. The included page is a menu page, it has some DIV tag stuff in it where it defines the links and to put my links in there I use the <h:commandlink> tag. If I used the <f:view> and bring up just that page by itself (not included in another page), it works fine. And if I include it in a page with no <f:view> tags, it works fine. But when I include it in a page with <f:view> tags and <f:subview> tags in the included page, it's like it pulls the JSF components out of the DIV tags in the included page. I don't know if this is a bug or just something I'm doing incorrectly, but I don't understand why JSF needed to make page includes so difficult.

Anyway, any opinion on this would be greatly appreciated.
 
Hans Bergsten
Author
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Patrick Ferguson:
Thanks Hans,

I'm also posting this in the Java forum. But I tried what you said about putting the included page in <f:subview> tags, and it does something really odd. The included page is a menu page, it has some DIV tag stuff in it where it defines the links and to put my links in there I use the <h:commandlink> tag. If I used the <f:view> and bring up just that page by itself (not included in another page), it works fine. And if I include it in a page with no <f:view> tags, it works fine. But when I include it in a page with <f:view> tags and <f:subview> tags in the included page, it's like it pulls the JSF components out of the DIV tags in the included page. I don't know if this is a bug or just something I'm doing incorrectly, but I don't understand why JSF needed to make page includes so difficult.

Anyway, any opinion on this would be greatly appreciated.




That's what I meant with "there are many other issues regarding dynamic includes". You need to wrap all non-JSF elements within <f:verbatim> elements in the included page as well.

But again, do you really have to use a dynamic include? A static include (i.e., <%@ include file="..." %> doesn't have all these issues; you just include the file without adding any wrapping elements. Dynamic includes should be used (in JSF) only when you don't know the name of the file at design/compile time to avoid all this extra complexity.
 
I AM MIGHTY! Especially when I hold this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic