This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes c:import with Facelets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "c:import with Facelets" Watch "c:import with Facelets" New topic
Author

c:import with Facelets

J Haley
Ranch Hand

Joined: Jul 22, 2004
Posts: 66
I have external content that I need to import in to my Facelets/myFaces application. I�ve tried using c:import since I�m pulling content from outside of my container. However, Facelets does not support c:import . I also configured my application to support JSP pages. My jsp page works fine with the c:import, but I now can�t figure out how to include the jsp page into my facelet page. Any ideas?
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
Hello.

Thi is how i import using <c:import>.

<f:view>
<f:subview id="two">
<c:import url="WEB-INF/includes/userLogin.jsp"/>
</f:subview>
</f:view>

if you import this way userLogin.jsp should not have <f:view> inside.

I hope it helps.
J Haley
Ranch Hand

Joined: Jul 22, 2004
Posts: 66
Gave it a shot, but I get the following error.

<c:import> Tag Library supports namespace: http://java.sun.com/jstl/core, but no tag was defined for name: import

I believe that I'm getting this because facelets does not support c:import.

Unless I'm missing something, I will have to write my own custom tag to replicate the c:import. Seems odd that facelests does not support all of the JSTL.
Hung Tang
Ranch Hand

Joined: Feb 14, 2002
Posts: 148
Have you tried ui:include ?
J Haley
Ranch Hand

Joined: Jul 22, 2004
Posts: 66
I have and it works only if the content is well formed xhtml. I have to be less strict and import html.
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
It is interesting but c:import works in my JSF pages. Ofcourse I need to import JSTL tag library. Otherwise JSF page will not be able to understand c:import.

<c:import url="WEB-INF/includes/userLogin.jsp"/>

I can also use JSP includes to include content into my JSF pages. <jsp:include page=""/>. Have you tried that?

make sure you put your included content into <f:subview> as shown in the examle/message above.

you can also use jsp directive(<%@include %>) to include your content into JSF pages.
J Haley
Ranch Hand

Joined: Jul 22, 2004
Posts: 66
I have also successfully used c:import with jsf. My problem occurs with facelet pages. I have faclets pages that need to import content from outside of my container. When I look at the doc, facelets only supports 4 c: tags and import is not one of them.
https://facelets.dev.java.net/nonav/docs/dev/docbook.html

jsp:include and directive include won�t work in a facelets page. In addtion, they will not pull pages from outside of my container.

I think I�ve finally arrived at a solution. I'm going to have to write a custom tag that mimics what c:import does. I still think I may be missing something. It is very surprising to me that faclets does not support c:import.
Sergey Kargopolov
Ranch Hand

Joined: Jul 04, 2003
Posts: 63
J Haley,

thank you very much for your kind explanation. I really thought that Facelets are same Java Server Faces and there is no difference. And Facelets it is just the way Java Server Faces are called. Just like Midlets, Servlets and Portlets pages written using Java Server Faces are called Facelets.

I am actually very new to JSF and it is my third week working on a project that requires me to write some JSF. I will definetly aquaint myself with http://facelets.dev.java.net/ and with Facelets tonight when I get couple of free hours after putting my kids to sleep .

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: c:import with Facelets
 
Similar Threads
Including a file in JSP
Applet-Integration in a JSF/Facelets application
including HTML file
c:import usage
Retrive variable from JavaScript to JSP page