|
List Info
Thread: Need help with templates, please
|
|
| Need help with templates, please |
  United States |
2007-04-02 16:45:02 |
All I want to do is include in one template a cms page that
uses it's own
template. So in Template B, I want to include the final,
processed html for
Page A which uses Template A. I welcome any advice since I
have to get this
work for us to use OpenCms. I'm willing to write my own
custom tag, but so
far, it get the same errors (see the end of the email).
This is something that should be really easy, but I cannot,
for the life of
me, figure how to do it. I've created Page B (which uses
Template B) and
when I view Page B, I get the following results for each
implementation that
I've tried in Template B. When I view Page A directly, it
displays fine.
1. <cms:include page="/full/path/to/PageA.html"
/>
Results: A null pointer exception because there is no
element specified. (I
want the entire file, not one element , to be processed and
displayed)
ERROR [ationDispatcher: 704] Servlet.service() for servlet
jsp threw
exception
java.lang.NullPointerException
at
org.opencms.xml.CmsXmlUtils.createXpath(CmsXmlUtils.java:145
)
at
org.opencms.xml.A_CmsXmlDocument.getLocales(A_CmsXmlDocument
.java:337)
at
org.opencms.loader.A_CmsXmlDocumentLoader.dumpAsString(A_Cms
XmlDocumentLoader.java:125)
at
org.opencms.loader.A_CmsXmlDocumentLoader.service(A_CmsXmlDo
cumentLoader.java:245)
at
org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWit
hCache(CmsFlexRequestDispatcher.java:422)
at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexReq
uestDispatcher.java:173)
at
org.opencms.jsp.CmsJspTagInclude.includeActionWithCache(CmsJ
spTagInclude.java:358)
at
org.opencms.jsp.CmsJspTagInclude.includeTagAction(CmsJspTagI
nclude.java:239)
at
org.opencms.jsp.CmsJspTagInclude.doEndTag(CmsJspTagInclude.j
ava:458)
...
2. <jsp:include
page="/opencms/full/path/to/PageA.html"
flush="false" />
Results: A null pointer exception, but no stack trace or
output to the logs
at all.
3. <jsp:include page="/<webapp
name>/opencms/full/path/to/PageA.html"
flush="false" />
Results: It just prints out "The requested resource
(/<webapp name>/<webapp
name>/opencms/full/path/to/PageA.html) is not
available"
(Note the <double webapp name >in the url)
4. Inline Java code in Template B
Code:
CmsJspActionElement action = new CmsJspActionElement(
pageContext, request,
response );
String path = "/full/path/to/PageA.html";
HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
HttpServletResponse res = (HttpServletResponse)
pageContext.getResponse();
CmsObject cms = action.getCmsObject();
CmsResource resource = cms.readResource( path );
if ( resource != null ) {
// a file was read, go on process it
try {
OpenCms.getResourceManager().loadResource( cms, resource,
req, res );
//I_CmsResourceLoader loader =
OpenCms.getResourceManager().getLoader(
resource );
//loader.service( cms, resource, req, res );
}
catch ( Exception e ) {
out.println( "<pre>" );
e.printStackTrace( new PrintWriter( out ) );
out.println( "</pre>" );
}
}
Results:
javax.servlet.ServletException: VFS target
"/system/<my
module>/templates/TemplateB.jsp" was already
included earlier.
at
org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWit
hCache(CmsFlexRequestDispatcher.java:275)
at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexReq
uestDispatcher.java:173)
at
org.opencms.loader.CmsJspLoader.dispatchJsp(CmsJspLoader.jav
a:473)
at
org.opencms.loader.CmsJspLoader.load(CmsJspLoader.java:418)
at
org.opencms.loader.A_CmsXmlDocumentLoader.load(A_CmsXmlDocum
entLoader.java:232)
at
org.opencms.loader.CmsResourceManager.loadResource(CmsResour
ceManager.java:730)
...
Thanks,
Eric
--
View this message in context: http://www.nabble.com/Need-help-
with-templates%2C-please-tf3508468.html#a9799630
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: Need help with templates, please |
  United Kingdom |
2007-04-04 00:14:36 |
Eric -
I've started to reply several times, and got myself bogged
down in
explanations which have served only to show my own confusion
on the subject!
So I'll just describe the approach which works for me.
0. I found the OpenCms terminology and tag naming
thoroughly confusing,
with 'template' and 'include' being used to mean more than
one thing.
1. Most of my content is XML content (of custom XML
content types). For
files like this in /sites/default, the template-elements
property is set to
refer to a JSP in /system/modules/<module folder
name>/template-elements,
and the job of this JSP is to act as the view for the data
(model) in the
XML content. As you know, it's hard-coded behaviour in
OpenCms that when
XML content has a template-elements property set to the path
of a JSP, that
JSP is invoked for page rendition.
2. The template-elements JSP (let's call this the 'view
JSP') contains
HTML, taglib invocations and scriptlets. This stuff,
together with data
included from the associated XML content, results in page
output.
3. As it happens, I don't ever include other pages
wholesale, nor do I ever
find I need to. If there was a circumstance in which I
wanted to give more
than one view of the same data, I would generalise the view
JSP - but
because it's only ever invoked from a single URL, the URL
corresponding to
the XML content item, the nature of the view required would
have to be
hinted at using URL parameters or a cookie.
4. The view JSP may includes other JSPs which provide
discrete pieces of
page output - let's call these 'view element JSPs'. These
generally use
only state passed from the main view JSP, though they too
could include bits
of data from the XML content. Typical functions include
rendering page
header and footer, or a set of search results defined (if
not retrieved) in
the main view JSP.
5. For xmlpage content, it's the 'templates' (not
'template-elements')
property which is set to the path of a view JSP. That JSP
acts similarly -
provides a page structure, possibly including view
sub-element JSPs, and
including content from the invoking xmlpage content.
6. Here's one of my view JSPs, trimmed down. This is what
I use to render
xmlpage content (i.e. free-form content created using
FCKEditor).
<% page pageEncoding="UTF-8"
session="false" import="......"<% taglib
prefix="cms" uri="http://www.op
encms.org/taglib/cms" %>
<cms:include
file="/system/modules/mymodulename/elements/pagecontent
open.jsp"/><%
// I set up some state here, storing it in the page
context.
%><div
class="freeformContent"><cms:include
element="body"/></div><cms:include
file="/system/modules/mymodulename/elements/pagecontent
close.jsp" />
There are two forms of <cms:include> here:
(a) I only ever use the first form to include a view
sub-element JSP
<cms:include>, never to refer to content (which seems
to be the way you were
trying to do things). See 3 above.
(b) The second form includes the text content of an XML node
in the resource
corresponding to the requested URL.
I hope this helps.
Jon
-----Original Message-----
From: bessette [mailto:Bessette pokemon-seattle.com]
Sent: 02 April 2007 22:45
To: opencms-dev opencms.org
Subject: [opencms-dev] Need help with templates, please
All I want to do is include in one template a cms page that
uses it's own
template. So in Template B, I want to include the final,
processed html for
Page A which uses Template A. I welcome any advice since I
have to get this
work for us to use OpenCms. I'm willing to write my own
custom tag, but so
far, it get the same errors (see the end of the email).
This is something that should be really easy, but I cannot,
for the life of
me, figure how to do it. I've created Page B (which uses
Template B) and
when I view Page B, I get the following results for each
implementation that
I've tried in Template B. When I view Page A directly, it
displays fine.
1. <cms:include page="/full/path/to/PageA.html"
/>
Results: A null pointer exception because there is no
element specified. (I
want the entire file, not one element , to be processed and
displayed)
ERROR [ationDispatcher: 704] Servlet.service() for servlet
jsp threw
exception java.lang.NullPointerException
at
org.opencms.xml.CmsXmlUtils.createXpath(CmsXmlUtils.java:145
)
at
org.opencms.xml.A_CmsXmlDocument.getLocales(A_CmsXmlDocument
.java:337)
at
org.opencms.loader.A_CmsXmlDocumentLoader.dumpAsString(A_Cms
XmlDocumentLoade
r.java:125)
at
org.opencms.loader.A_CmsXmlDocumentLoader.service(A_CmsXmlDo
cumentLoader.jav
a:245)
at
org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWit
hCache(CmsFlexRe
questDispatcher.java:422)
at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexReq
uestDispatcher.j
ava:173)
at
org.opencms.jsp.CmsJspTagInclude.includeActionWithCache(CmsJ
spTagInclude.jav
a:358)
at
org.opencms.jsp.CmsJspTagInclude.includeTagAction(CmsJspTagI
nclude.java:239)
at
org.opencms.jsp.CmsJspTagInclude.doEndTag(CmsJspTagInclude.j
ava:458)
...
2. <jsp:include
page="/opencms/full/path/to/PageA.html"
flush="false" />
Results: A null pointer exception, but no stack trace or
output to the logs
at all.
3. <jsp:include page="/<webapp
name>/opencms/full/path/to/PageA.html"
flush="false" />
Results: It just prints out "The requested resource
(/<webapp name>/<webapp
name>/opencms/full/path/to/PageA.html) is not
available"
(Note the <double webapp name >in the url)
4. Inline Java code in Template B
Code:
CmsJspActionElement action = new CmsJspActionElement(
pageContext,
request, response );
String path = "/full/path/to/PageA.html";
HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
HttpServletResponse res = (HttpServletResponse)
pageContext.getResponse();
CmsObject cms = action.getCmsObject();
CmsResource resource = cms.readResource( path );
if ( resource != null ) {
// a file was read, go on process it
try {
OpenCms.getResourceManager().loadResource( cms,
resource, req, res );
//I_CmsResourceLoader loader =
OpenCms.getResourceManager().getLoader(
resource );
//loader.service( cms, resource, req, res );
}
catch ( Exception e ) {
out.println( "<pre>" );
e.printStackTrace( new PrintWriter( out ) );
out.println( "</pre>" );
}
}
Results:
javax.servlet.ServletException: VFS target
"/system/<my
module>/templates/TemplateB.jsp" was already
included earlier.
at
org.opencms.flex.CmsFlexRequestDispatcher.includeInternalWit
hCache(CmsFlexRe
questDispatcher.java:275)
at
org.opencms.flex.CmsFlexRequestDispatcher.include(CmsFlexReq
uestDispatcher.j
ava:173)
at
org.opencms.loader.CmsJspLoader.dispatchJsp(CmsJspLoader.jav
a:473)
at
org.opencms.loader.CmsJspLoader.load(CmsJspLoader.java:418)
at
org.opencms.loader.A_CmsXmlDocumentLoader.load(A_CmsXmlDocum
entLoader.java:2
32)
at
org.opencms.loader.CmsResourceManager.loadResource(CmsResour
ceManager.java:7
30)
...
Thanks,
Eric
--
View this message in context:
http://www.nabble.com/Need-help-with
-templates%2C-please-tf3508468.html#a979
9630
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: Need help with templates, please |
  United States |
2007-04-05 10:30:09 |
First off, thanks for your reply. I appreciate the time you
took to help me
out. I've tried to reply to each of your points below, but
I can tell that
we have different requirements and so my opinions below will
differ from
yours. Your response has helped me understand how other
people use OpenCms,
so again thanks for your reply.
Jonathan Woods wrote:
>
> 0. I found the OpenCms terminology and tag naming
thoroughly confusing,
> with 'template' and 'include' being used to mean more
than one thing.
>
Most definitely! Part of the problem stems from lack of
detailed
documentation about each VFS file type and how the tags
interact with them.
If you look in org.opencms.loader, you'll get a much better
understanding of
how each VFS file type is processed. (At least I did)
Jonathan Woods wrote:
>
> 1. Most of my content is XML content (of custom XML
content types). For
> files like this in /sites/default, the
template-elements property is set
> to
> refer to a JSP in /system/modules/<module folder
name>/template-elements,
> and the job of this JSP is to act as the view for the
data (model) in the
> XML content. As you know, it's hard-coded behaviour in
OpenCms that when
> XML content has a template-elements property set to the
path of a JSP,
> that
> JSP is invoked for page rendition.
>
I haven't gotten into XML content yet, although eventually I
will have to.
I've just been using JSP templates and "Page with free
text". While your
description might be accurate for XML content, if you are
using JSP
templates with "Page with free text" pages, then
the template-elements is
where you specify the elements that writers/editors can use
for content.
It took me a while to figure out the syntax, but this is
what I found (in
the properties for the template, not the page):
template-elements=<elementname>[|<Short element
Name][,<elementname>[|<Short
element Name]]
For example, if you have a template with two include tags
like this:
<cms:include element="section1"
editable="true" />
<cms:include element="leftNav"
editable="true" />
Then your template-elements property FOR THE TEMPLATE would
be:
section1|First Section,leftNav|Left Navigation
Now when a user edits a page that uses that template, they
will see the
Short Element Name in the element drop down list. This
helps you, as a
developer, keep your element names short, but give the
writer/editor a more
descriptive name to prevent confusion.
Jonathan Woods wrote:
>
> 3. As it happens, I don't ever include other pages
wholesale, nor do I
> ever
> find I need to. If there was a circumstance in which I
wanted to give
> more
> than one view of the same data, I would generalise the
view JSP - but
> because it's only ever invoked from a single URL, the
URL corresponding to
> the XML content item, the nature of the view required
would have to be
> hinted at using URL parameters or a cookie.
>
I don't really understand what your saying here. I come
from a Tiles
background, http://str
uts.apache.org/1.x/struts-tiles/, so breaking up the
templates into smaller, modular pieces is second nature to
me.
Jonathan Woods wrote:
>
> 4. The view JSP may includes other JSPs which provide
discrete pieces of
> page output - let's call these 'view element JSPs'.
These generally use
> only state passed from the main view JSP, though they
too could include
> bits
> of data from the XML content. Typical functions
include rendering page
> header and footer, or a set of search results defined
(if not retrieved)
> in
> the main view JSP.
>
Correct, this works in OpenCms out of the box. However, you
can only
include the JSP page as is, you can't apply any xml content
to the included
JSP without modifying the code, as I have done. That means
that you have to
duplicate the content and elements in the xmlpage instead of
having one
source content file. Duplication is always bad in
software.
Jonathan Woods wrote:
>
> 6. Here's one of my view JSPs, trimmed down. This is
what I use to
> render
> xmlpage content (i.e. free-form content created using
FCKEditor).
>
> <% page pageEncoding="UTF-8"
session="false" import="......"<% taglib
> prefix="cms" uri="http://www.op
encms.org/taglib/cms" %>
> <cms:include
>
file="/system/modules/mymodulename/elements/pagecontent
open.jsp"/><%
>
> // I set up some state here, storing it in the page
context.
> %><div
class="freeformContent"><cms:include
>
element="body"/></div><cms:include
>
file="/system/modules/mymodulename/elements/pagecontent
close.jsp" />
>
> There are two forms of <cms:include> here:
>
> (a) I only ever use the first form to include a view
sub-element JSP
> <cms:include>, never to refer to content (which
seems to be the way you
> were
> trying to do things). See 3 above.
> (b) The second form includes the text content of an XML
node in the
> resource
> corresponding to the requested URL.
>
a. Yes, as I said in my response to #4, I want to have one
source content
for a sub template. Because CSS is now so powerfull, if I
can accomplish my
goal, I will be able to repurpose the same content on almost
every page of
my site, even allowing for multiple stylings, without having
the problem of
duplication.
Thanks,
Eric
--
View this message in context: http://www.nabble.com/Need-help-
with-templates%2C-please-tf3508468.html#a9858091
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: Need help with templates, please |
  United States |
2007-04-05 10:32:16 |
Oh, I forgot to add that I have figured out how to implement
this by creating
a custom tag, custom loader, and custom HttpServletRequest.
I consider this
a huge hack and will look for a more elegant solution later,
but for now I
just need to get this working.
Once I fine tune a couple of things, I'll post my solution
here. (So you
can all rip it to shreads )
Thanks,
Eric
--
View this message in context: http://www.nabble.com/Need-help-
with-templates%2C-please-tf3508468.html#a9858092
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: RE: Need help with templates,
please |
  United Kingdom |
2007-04-05 11:17:33 |
Eric -
No worries re the reply.
I give up! I can't work out where we're failing to
understand one another -
I don't think it's just about a difference of philosophy.
All I know is
that I manage to break things down just as you describe,
even for xmlpage
content, and without using custom versions of low level
classes - this
definitely shouldn't be necessary - though congratulations
on some heavy
hacking, though! I think the difference in approach is
probably most
apparent in your answer to 4, where you say that "you
can't apply any XML
content to the included JSP". JSPs can do what they
like, can't they? Mine
do.
Feel free to drop me an e-mail if you want to discuss this
by
phone/Skype/whatever, but otherwise I'll shut up on this
thread.
Jon
-----Original Message-----
From: bessette [mailto:Bessette pokemon-seattle.com]
Sent: 05 April 2007 16:30
To: opencms-dev opencms.org
Subject: [opencms-dev] RE: Need help with templates, please
First off, thanks for your reply. I appreciate the time you
took to help me
out. I've tried to reply to each of your points below, but
I can tell that
we have different requirements and so my opinions below will
differ from
yours. Your response has helped me understand how other
people use OpenCms,
so again thanks for your reply.
Jonathan Woods wrote:
>
> 0. I found the OpenCms terminology and tag naming
thoroughly
> confusing, with 'template' and 'include' being used to
mean more than one
thing.
>
Most definitely! Part of the problem stems from lack of
detailed
documentation about each VFS file type and how the tags
interact with them.
If you look in org.opencms.loader, you'll get a much better
understanding of
how each VFS file type is processed. (At least I did)
Jonathan Woods wrote:
>
> 1. Most of my content is XML content (of custom XML
content types). For
> files like this in /sites/default, the
template-elements property is
> set to refer to a JSP in /system/modules/<module
folder
> name>/template-elements, and the job of this JSP is
to act as the view
> for the data (model) in the XML content. As you know,
it's hard-coded
> behaviour in OpenCms that when XML content has a
template-elements
> property set to the path of a JSP, that JSP is invoked
for page
> rendition.
>
I haven't gotten into XML content yet, although eventually I
will have to.
I've just been using JSP templates and "Page with free
text". While your
description might be accurate for XML content, if you are
using JSP
templates with "Page with free text" pages, then
the template-elements is
where you specify the elements that writers/editors can use
for content.
It took me a while to figure out the syntax, but this is
what I found (in
the properties for the template, not the page):
template-elements=<elementname>[|<Short element
Name][,<elementname>[|<Short
element Name]]
For example, if you have a template with two include tags
like this:
<cms:include element="section1"
editable="true" /> <cms:include
element="leftNav" editable="true" />
Then your template-elements property FOR THE TEMPLATE would
be:
section1|First Section,leftNav|Left Navigation
Now when a user edits a page that uses that template, they
will see the
Short Element Name in the element drop down list. This
helps you, as a
developer, keep your element names short, but give the
writer/editor a more
descriptive name to prevent confusion.
Jonathan Woods wrote:
>
> 3. As it happens, I don't ever include other pages
wholesale, nor do
> I ever find I need to. If there was a circumstance in
which I wanted
> to give more than one view of the same data, I would
generalise the
> view JSP - but because it's only ever invoked from a
single URL, the
> URL corresponding to the XML content item, the nature
of the view
> required would have to be hinted at using URL
parameters or a cookie.
>
I don't really understand what your saying here. I come
from a Tiles
background, http://str
uts.apache.org/1.x/struts-tiles/, so breaking up the
templates into smaller, modular pieces is second nature to
me.
Jonathan Woods wrote:
>
> 4. The view JSP may includes other JSPs which provide
discrete pieces
> of page output - let's call these 'view element JSPs'.
These
> generally use only state passed from the main view JSP,
though they
> too could include bits of data from the XML content.
Typical
> functions include rendering page header and footer, or
a set of search
> results defined (if not retrieved) in the main view
JSP.
>
Correct, this works in OpenCms out of the box. However, you
can only
include the JSP page as is, you can't apply any xml content
to the included
JSP without modifying the code, as I have done. That means
that you have to
duplicate the content and elements in the xmlpage instead of
having one
source content file. Duplication is always bad in
software.
Jonathan Woods wrote:
>
> 6. Here's one of my view JSPs, trimmed down. This is
what I use to
> render xmlpage content (i.e. free-form content created
using
> FCKEditor).
>
> <% page pageEncoding="UTF-8"
session="false" import="......"<%
> taglib prefix="cms" uri="http://www.op
encms.org/taglib/cms" %>
> <cms:include
>
file="/system/modules/mymodulename/elements/pagecontent
open.jsp"/><%
>
> // I set up some state here, storing it in the page
context.
> %><div
class="freeformContent"><cms:include
>
element="body"/></div><cms:include
>
file="/system/modules/mymodulename/elements/pagecontent
close.jsp" />
>
> There are two forms of <cms:include> here:
>
> (a) I only ever use the first form to include a view
sub-element JSP
> <cms:include>, never to refer to content (which
seems to be the way
> you were trying to do things). See 3 above.
> (b) The second form includes the text content of an XML
node in the
> resource corresponding to the requested URL.
>
a. Yes, as I said in my response to #4, I want to have one
source content
for a sub template. Because CSS is now so powerfull, if I
can accomplish my
goal, I will be able to repurpose the same content on almost
every page of
my site, even allowing for multiple stylings, without having
the problem of
duplication.
Thanks,
Eric
--
View this message in context:
http://www.nabble.com/Need-help-with
-templates%2C-please-tf3508468.html#a985
8091
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: RE: Need help with templates,
please |
  United States |
2007-04-05 11:23:42 |
Jonathan Woods wrote:
>
> I give up! I can't work out where we're failing to
understand one another
> -
> I don't think it's just about a difference of
philosophy. All I know is
> that I manage to break things down just as you
describe, even for xmlpage
> content, and without using custom versions of low level
classes - this
> definitely shouldn't be necessary - though
congratulations on some heavy
> hacking, though! I think the difference in approach is
probably most
> apparent in your answer to 4, where you say that
"you can't apply any XML
> content to the included JSP". JSPs can do what
they like, can't they?
> Mine
> do.
>
I'm pretty new to OpenCms, but I couldn't find any other way
to do what I
wanted. If I try to include an xmlpage using the
<cms:include> tag, I get
the results in this thread,
http://www.nabble.com/Null-P
ointer-Exception-using-cms%3Ainclude-tag-tf3468837.html.
If anyone has a way around the exception without hacking as
I have done,
please let me know as I prefer not to us my implementation
if I can help it.
Thanks,
Eric
--
View this message in context: http://www.nabble.com/Need-help-
with-templates%2C-please-tf3508468.html#a9859114
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: RE: RE: Need help with templates,
please |
  United Kingdom |
2007-04-05 11:58:17 |
Instead of including the xmlpage, try including the JSP
which renders the
xmlpage's contents, making sure that JSP knows which
resource (e.g. the
footer) which it's supposed to render. I think that's the
difference
between our approaches.
Jon
-----Original Message-----
From: bessette [mailto:Bessette pokemon-seattle.com]
Sent: 05 April 2007 17:24
To: opencms-dev opencms.org
Subject: [opencms-dev] RE: RE: Need help with templates,
please
Jonathan Woods wrote:
>
> I give up! I can't work out where we're failing to
understand one
> another
> -
> I don't think it's just about a difference of
philosophy. All I know
> is that I manage to break things down just as you
describe, even for
> xmlpage content, and without using custom versions of
low level
> classes - this definitely shouldn't be necessary -
though
> congratulations on some heavy hacking, though! I think
the difference
> in approach is probably most apparent in your answer to
4, where you
> say that "you can't apply any XML content to the
included JSP". JSPs can
do what they like, can't they?
> Mine
> do.
>
I'm pretty new to OpenCms, but I couldn't find any other way
to do what I
wanted. If I try to include an xmlpage using the
<cms:include> tag, I get
the results in this thread,
http://www.nabble.com/Null-Pointer-E
xception-using-cms%3Ainclude-tag-tf34688
37.html.
If anyone has a way around the exception without hacking as
I have done,
please let me know as I prefer not to us my implementation
if I can help it.
Thanks,
Eric
--
View this message in context:
http://www.nabble.com/Need-help-with
-templates%2C-please-tf3508468.html#a985
9114
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| RE: RE: RE: Need help with templates,
please |
  United States |
2007-04-05 13:23:54 |
Jonathan Woods wrote:
>
> Instead of including the xmlpage, try including the JSP
which renders the
> xmlpage's contents, making sure that JSP knows which
resource (e.g. the
> footer) which it's supposed to render. I think that's
the difference
> between our approaches.
>
So, how do you make sure that the JSP knows which resource
it's suppose to
render? I have this template (called t_header.jsp):
<% page language="java"
contentType="text/html"
pageEncoding="UTF-8"%>
<% taglib prefix="cms" uri="http://w
ww.opencms.org/taglib/cms"%>
<cms:editable />
<div>
<div><cms:include element="div.logo"
editable="true" /></div>
<div><cms:include element="other.divs"
editable="true" /></div>
<div>
<!-- other stuff -->
</div>
</div>
If I want to include the t_header.jsp template in another
template (like
t_main.jsp), how do I specify that t_header.jsp should use
/sites/mysite/div1/common/header.html (an xmlpage file)?
The options I know about, which I would use in t_main.jsp
and haven't worked
for me, are <cms:include>, <jsp:include>, and
<% import %>.
Thanks,
Eric
--
View this message in context: http://www.nabble.com/Need-help-
with-templates%2C-please-tf3508468.html#a9860354
Sent from the OpenCMS - Dev mailing list archive at
Nabble.com.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
| Re: RE: RE: Need help with templates,
please |
  Germany |
2007-04-18 06:40:44 |
Jonathan, once again you have given the most relevant hint
about a
problem. Thank you very much for your answers on this list.
I had the same/similar problem. I needed to include rendered
xmlcontent
files from a central portal template.
Here is how I made sure that the JSP knows which resource
it's supposed
to render.
My central template receives the path of the xmlcontent file
to include
as a request parameter and uses <cms:include
page="article.jsp"/> to
include the file. article.jsp is also set as the
template-elements
property of the xmlcontent files. The path of the file is
passed to
article.jsp via the HTTP session.
My code in article.jsp determines the path from the session
and then
sets it as a page context variable which is referred to by
the
contentload tag. If no path is found in the session it is
assumed that
the xmlcontent file is called directly within the Explorer
or by
invocation of its URL. In this case the page context
variable is set to
the value of the OpenCms request context URI (which has the
same value
as ${opencms.uri}).
Code snippet from article.jsp:
<%
String path = // something like
session.getAttribute("...");
if (null == path) {
CmsJspActionElement jsp =
new CmsJspActionElement(pageContext, request,
response);
pageContext.setAttribute("uri",
jsp.getRequestContext().getUri());
} else {
pageContext.setAttribute("uri", path);
}
%>
<cms:contentload collector="singleFile"
param="${pageContext.uri}"
editable="true">
</cms:contentload>
Best regards,
Christoph
_______________________________________________
This mail is sent to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the
list, please visit
http://lists.opencms.org/mailman/listinfo/opencms-dev
|
|
[1-9]
|
|