AW: [opencms-dev] Xtags Taglib cant/wont use uri inside OpenCms

Petr Hollay ph at ethikom.de
Thu Feb 26 09:14:00 CET 2004


Hi Alex,

> 1) Are there any alternative (taglibs or other methods) I could (or
should) use?
Of course there are always alternatives... ;-)

Well, this issue is related to the way how FlexCache is implemented.

As you may already know, setting "stream" property for JSP page to "bypass"
will not help. Then it doesn't work at all.

Problem is that even when using 

<xtags:parse>
  <cms:include file="/test/test_xml.xml />
</xtags:parse>

the content of the XML file is read and prepared for inclusion into
response, but it is not available for <xtags:parse> tag.
I've tested it by adding some logging into
org.apache.taglibs.xtags.xpath.ParseTag Java class, which handles this tag.

Anyway there seems to be solution for your problem. 
If you need to include files from VFS and you don't want to write full path
to the resource including server name and servlet path 
(what I could understand ;-),
try to use the following code in your JSP:

<xtags:parse url="<%= myurl %>" />

And define variable myurl somewhere before. 

You probably know that <xtags:parse> tag has two possible attributes for
setting path to the resource, 
"url" for the absolute URL, using java.net.URL syntax,
and "uri" for path using page context - see
javax.servlet.ServletContext.getResource(String).


Just as an example, add the following code into your JSP page:

1) define imports
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"  %>
<%@ page
import="com.opencms.flex.cache.*,com.opencms.flex.*,com.opencms.core.*,com.o
pencms.file.*,java.util.*" %>

2) define cms object
<%
com.opencms.flex.jsp.CmsJspActionElement cms = new
com.opencms.flex.jsp.CmsJspActionElement(pageContext, request, response);
%>

3) define helper method getServerPath() for getting full path including
server name and servlet path. It could be moved into some helper JavaBean.
<%!
	public String getServerPath(CmsObject cmsObject, String path) {
		I_CmsRequest cmsRequest =
cmsObject.getRequestContext().getRequest();
		return "http://" + cmsRequest.getServerName() + ":" +
cmsRequest.getServerPort() + cmsRequest.getServletUrl() +
(path.startsWith("/") ? path : "/" + path);
	}
%>

4) define url to your XML file you want to parse
<%
String myurl = getServerPath(cms.getCmsObject(),
"/sites/testethikom1/data1.xml");
%>

5) test myurl variable and parse XML file
myurl: <%= myurl %> <br>

<xtags:parse url="<%= myurl %>" />



My enviroment:
  JDK 1.4.1_07
  Tomcat 4.1.29
  OpenCms 5.0
  jakarta-taglibs-20040225

Let me know if you will have any problems.

Best regards
Petr


-----Ursprüngliche Nachricht-----
Von: opencms-dev-admin at opencms.org [mailto:opencms-dev-admin at opencms.org] Im
Auftrag von Alexander Kandzior
Gesendet: Mittwoch, 25. Februar 2004 17:23
An: opencms-dev at opencms.org
Betreff: RE: [opencms-dev] Xtags Taglib cant/wont use uri inside OpenCms


> 1) Are there any alternative (taglibs or other methods) I 
> could (or should) 
> use?

I don't know.

> 2) Is your suggestion aimed at resolving the uri issue?

No. It will bypass the FlexCache wich may be the reason for your error.

> 3) Is there any documentation where I can look up how to 
> perform the changes 
> you suggested?

You know how to attach a property value to a page? If so, there is the
"Define..." button where you can create property definitions.


Alexander Kandzior

-------------------

Alkacon Software
Alexander Kandzior
Eugen-Langen-Str. 8
50968 Koeln, DE

Tel: +49 (0)221 3797540
Fax: +49 (0)221 3797541
Email: a.kandzior at alkacon.com

http://www.alkacon.com

_______________________________________________
This mail is send to you from the opencms-dev mailing list
To change your list options, or to unsubscribe from the list, please visit
http://mail.opencms.org/mailman/listinfo/opencms-dev




More information about the opencms-dev mailing list