Hi,
I tried to use the Taglib Function "includeTemplate" in an other way,
than it is normaly used.
I have an ArrayList with Content Object in it. So in the Jsp I go
through it like this:
<c:forEach var="node" items="${nodes}">
<cms:adminOnly>
<cms:editBar contentNodeName="${node.handle}"/>
</cms:adminOnly>
<cms:includeTemplate
path="/templates/jsp//oneColumnGB/paragraphs/gbeintrag.jsp"
contentNode="${node}" />
<br/>
</c:forEach>
so I give the includeTemplate Function the Parameter contentNode. The
Problem now is, that in the include.java the contentNode will not be set
as the localContentNode.
So I cannot access it later in the template which I defined over the
path parameter.
I took a look into the include.java and found the problem (it solved the
problem for me), but perhaps I didn't understand it correctly.
Here my conclusion: (First one, like it is now - Second one, like it has
to be from my opinion)
Inlude.java
...
public int doEndTag() {
try {
HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
// get content
Content content = this.contentNode;
if (content == null) {
// was there a node name passed
if (this.contentNodeName != null) {
content =
Resource.getCurrentActivePage(req).getContent(this.contentNodeName);
if (content != null) {
Resource.setLocalContentNode(req, content);
}
}
// use current (first local then global)
else {
content = Resource.getLocalContentNode(req);
if (content == null) {
content = Resource.getGlobalContentNode(req);
if (content != null) {
Resource.setLocalContentNode(req, content);
}
}
}
if (content == null) {
throw new Exception("no content node found");
//$NON-NLS-1$
}
}
String jspPage = this.path;
...
------
...
public int doEndTag() {
try {
HttpServletRequest req = (HttpServletRequest)
pageContext.getRequest();
// get content
Content content = this.contentNode;
if (content == null) {
// was there a node name passed
if (this.contentNodeName != null) {
content =
Resource.getCurrentActivePage(req).getContent(this.contentNodeName);
}
// use current (first local then global)
else {
content = Resource.getLocalContentNode(req);
if (content == null) {
content = Resource.getGlobalContentNode(req);
}
}
}
if (content == null) {
throw new Exception("no content node found");
//$NON-NLS-1$
}else {
Resource.setLocalContentNode(req, content);
}
String jspPage = this.path;
...
So also if the contentNode is passed by Parameter it will be set as
LocalContentNode an can be accessed.
I hope I did the right thing :)
- D
----------------------------------------------------------------
for list details see
http://www.magnolia.info/en/magnolia/developer.html
----------------------------------------------------------------