[opencms-dev] Usage of <cms:parse>

kk fenghuohou at hotmail.com
Thu Sep 25 19:53:03 CEST 2008


Dear All,

I had posted a problem about customizing links in OpenCms not long ago. Now 
I am going to use
the <cms:parse> Tag to do it. With the tutorial on

http://www.opencms-wiki.org/Custom_Content_Parser

I have written my own Parser Class extending CmsConfiguredHtmlParser and 
implemented the Interface (I_CmsHtmlNodeVisitor).


But I am not really sure how I use the Tag in my Template, I tried followed:

<cms:parse parserClass="MyCustomVisitor">  (and also with the parserClass 
MyCustomParser)
 <a href="<cms:link>Test.jsp</cms:link>" onclick="update(this)" > klick hier 
für mehr </a>
<span></span><h1></h1>
</cms:parse>

And everything inside the <cms:parse> Tag just disappeared.

What am I doing wrong?

The implementation of my Parser Class is as followed:

public class MyCustomParser extends A_CmsConfiguredHtmlParser {
	public I_CmsHtmlNodeVisitor createVisitorInstance() throws CmsException{
		return new MyCustomVisitor();
	}
}


public final class MyCustomVisitor extends CmsHtmlParser implements 
I_CmsHtmlNodeVisitor {

     public MyCustomVisitor() {

         super(true);
     }


     public void visitStringNode(Text text) {

         //text = doStuffToHtml(text);
         super.visitStringNode(text);
     }

     public void visitTag(Tag tag) {

         tag = replaceTag(tag);

         super.visitTag(tag);
     }
     public Tag replaceTag(Tag tag){
    	 tag.setAttribute("Id", "wasFuerEineID");
    	 return tag;
     }
     public void visitRemarkNode(Remark remark) {

         //remark = doStuffToRemark(remark);
         super.visitRemarkNode(remark);
     }
}


Plz. paste a little example, if anybody knows this problem.

Thank you for ur help.


Kunkun

--------------------------------------------------
From: <opencms-dev-request at opencms.org>
Sent: Thursday, September 25, 2008 6:00 PM
To: <opencms-dev at opencms.org>
Subject: opencms-dev Digest, Vol 207, Issue 4

> Send opencms-dev mailing list submissions to
> opencms-dev at opencms.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
> or, via email, send a message with subject or body 'help' to
> opencms-dev-request at opencms.org
>
> You can reach the person managing the list at
> opencms-dev-owner at opencms.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of opencms-dev digest..."
>
>
> Today's Topics:
>
>   1. Re: %{opencms.filename} macro not resolving properly in a
>      <cms:contentload> tag? (Iulian Dogariu)
>   2. Re: need a little Java help (out.println())
>      (Christoph P. Kukulies)
>   3. show all links in a site (Christoph P. Kukulies)
>   4. Re: show all links in a site (Olli Aro)
>   5. Re: Multiple newsletters subscription (Rita2008)
>   6. Re: [XSD, content rendering] Beginner question - I receive
>      "??? xyz ???" when accessing xml elements (mailinglists)
>   7. [locale vs. language when accessing content] OpenCMS does
>      only use the language and does not handle Locales properly?
>      (mailinglists)
>   8. Re: Configuring Multisite without mod_jk (Fidel Viegas)
>   9. best approach (J Arrazolo)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 24 Sep 2008 13:23:27 +0300
> From: "Iulian Dogariu" <iulianu at gmail.com>
> Subject: Re: [opencms-dev] %{opencms.filename} macro not resolving
> properly in a <cms:contentload> tag?
> To: "The OpenCms mailing list" <opencms-dev at opencms.org>
> Message-ID:
> <2d95e0d00809240323x34284253x9a5ba0c9dd40d029 at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> On Wed, Sep 24, 2008 at 10:13 AM, Hendrik Jander
> <hendrik.jander at pixelpark.com> wrote:
>> Hello,
>>
>> Try to use ( ) instead of { } around the opencms.filename.
>
> Thanks, Hendrik, that does the trick!
>
> I should have been more careful.
>
> i.
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 24 Sep 2008 12:41:44 +0200
> From: "Christoph P. Kukulies" <kuku at physik.rwth-aachen.de>
> Subject: Re: [opencms-dev] need a little Java help (out.println())
> To: Tim Howland <th at wdogsystems.com>
> Cc: The OpenCms mailing list <opencms-dev at opencms.org>
> Message-ID: <20080924104144.GA19668 at physik.rwth-aachen.de>
> Content-Type: text/plain; charset=iso-8859-1
>
> Hi Tim,
>
> yes, it is your code example I grabbed from the net.
> (I referred to that fact already in an earlier email :-)
> Thanks for the explanation. I'll try what you suggested (passing the
> out through the method).
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
> On Fri, Sep 19, 2008 at 08:51:30AM -0400, Tim Howland wrote:
>> Hey Christoph-
>>
>> I think that looks like my old sitemap code; anyway, the issue is that
>> the method declaration is in the <%! block, so it doesn't run in the
>> same method as the rest of the java code. Normally, JSP's get compiled
>> into a single method, with things like a params Map and a responswriter
>> (called out) available. Since I needed to define a recursive function, I
>> had to define this code outside of that method.
>>
>> You may be able to get away with it by changing the method signature for
>> the recurseTree method to:
>>
>> private String recurseTree(CmsObject cmso,CmsJspActionElement jsp, String 
>> path, ResponseWriter out) {
>>
>> }
>>
>> and passing the responsewriter to it from the body of the calling JSP.
>>
>> Hope this helps,
>>
>> TIm
>>
>>
>>
>> Christoph P. Kukulies wrote:
>>> I'm using this piece of code that I grabbed from the net with minor
>>> modifications to generate a google sitemap file.
>>> I would like to modify this code to print out a recursive directory
>>> directory listing of the site with all folders and files. (kind of
>>> ls -lR).
>>> So all I would need is to put an out.println() into the most inner
>>> code section where the <loc>url</loc> is written (appended to the
>>> string). Appending to the string a costly anyway when doing recursion
>>> that's why this piece of code runs quite a while :).
>>>
>>> Anyway, whan I put an out.println() into the private function
>>> recurseTree(), out is an unknown variable.
>>>
>>> So I'm a) wondering what magic makes it known in the outer scope when I
>>> use it
>>>    there
>>> b) asking for help, what I have to do to make it known. I tried
>>>    System.out.println() but I see no output in the browser window.
>>>    (it goes into the logs/stdout_20080918.log file)
>>>
>>> Here is the code again:
>>>
>>> <%@ page session="false" %>
>>> <%@ page
>>> import="java.util.*,org.opencms.jsp.*,org.opencms.file.*,java.text.DateFormat,
>>> java.text.SimpleDateFormat,org.opencms.main.*" %>
>>> <%@ page import="org.opencms.lock.CmsLockType" %>
>>> <%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
>>> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
>>> <?xml version="1.0" encoding="UTF-8" ?>
>>> <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
>>> <%!
>>> protected String BASE_URL="";
>>> public static SimpleDateFormat ISO8601FORMAT = new
>>> SimpleDateFormat("yyyy-MM-dd");
>>> private String recurseTree(CmsObject cmso,CmsJspActionElement jsp,
>>> String path)  {
>>> StringBuffer sb = new StringBuffer();
>>>         try {
>>> ArrayList files = (ArrayList)
>>> cmso.getFilesInFolder(path);
>>> Iterator i = files.iterator();
>>> while (i.hasNext()) {
>>> CmsFile f = (CmsFile) i.next();
>>> String thispath = jsp.link(cmso.getSitePath(f));
>>> CmsProperty secret =
>>> cmso.readPropertyObject(f,"sitemap_hidden",true);
>>> CmsProperty changeFreqProperty =
>>> cmso.readPropertyObject(f,"sitemap_change_frequency",true);
>>> CmsProperty priorityProperty =
>>> cmso.readPropertyObject(f,"sitemap_priority",true);
>>> String changeFrequency =
>>> changeFreqProperty.getValue("weekly");
>>> String priority =
>>> priorityProperty.getValue("1");
>>> if ((secret.getValue("false") == "false") &&
>>> (thispath.endsWith("html")||thispath.endsWith("jsp")||thispath.endsWith("pdf")||thispath.endsWith("htm")))
>>> {
>>> sb.append("<url>\n");
>>> sb.append("<loc>"+BASE_URL+thispath+"</loc>\n");
>>> //DateFormat df =
>>> //DateFormat.getDateInstance();
>>> String niceDate =
>>> ISO8601FORMAT.format(new Date(f.getDateLastModified()));
>>> sb.append("<lastmod>"+niceDate+"</lastmod>\n");
>>> sb.append("<changefreq>"+changeFrequency+"</changefreq>\n");
>>> sb.append("<priority>"+priority+"</priority>\n");
>>> sb.append("</url>\n");
>>> }
>>> }
>>> ArrayList folders = (ArrayList)
>>> cmso.getSubFolders(path);
>>> Iterator j = folders.iterator();
>>> while (j.hasNext()) {
>>> CmsFolder f = (CmsFolder) j.next();
>>> sb.append( recurseTree(cmso,jsp,
>>> cmso.getSitePath(f) ) );
>>> }
>>> }
>>> catch (CmsException cmsException) {
>>> sb.append("A CMS exception occurred:
>>> "+cmsException.toString());
>>>
>>> }
>>> return sb.toString();
>>>
>>> }
>>> %>
>>> <%
>>>
>>>  CmsJspActionElement cms = new
>>> org.opencms.jsp.CmsJspActionElement(pageContext, request, response);
>>>  CmsObject cmso = cms.getCmsObject();
>>>  String filename="sitemap.xml";
>>>  String s_filecontent;
>>> 
>>> cmso.getRequestContext().setCurrentProject(cmso.readProject("Offline"));
>>> if (cmso.existsResource(filename)) {
>>>        cmso.lockResource(filename,CmsLock.TEMPORARY);
>>>         cmso.deleteResource(filename,
>>> CmsResource.DELETE_PRESERVE_SIBLINGS);
>>>         if (cmso.existsResource(filename)) {
>>>                 cmso.unlockResource(filename);
>>>                 cmso.publishResource(filename);
>>>         }
>>> }
>>>
>>>
>>> String url = cms.info("opencms.url");
>>> int lastSlash = url.indexOf("/",8);
>>> BASE_URL = url.substring(0,lastSlash);
>>> s_filecontent=recurseTree(cmso,cms, "/");
>>> s_filecontent=s_filecontent+"</urlset>\n";
>>> cmso.createResource(
>>>         filename,
>>> 
>>> OpenCms.getResourceManager().getResourceType("plain").getTypeId(),
>>>         s_filecontent.getBytes(),
>>>         new ArrayList()
>>> );
>>> cmso.unlockResource(filename);
>>> cmso.publishResource(filename);
>>> %>
>>>
>>> Thanks for helping,
>>>
>>>
>>> --
>>> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>>>
>>>
>>
>>
>> -- 
>> Tim Howland
>> th at wdogsystems.com
>> http://wdogsystems.com
>>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 24 Sep 2008 12:43:31 +0200
> From: "Christoph P. Kukulies" <kuku at physik.rwth-aachen.de>
> Subject: [opencms-dev] show all links in a site
> To: opencms-dev at opencms.org
> Message-ID: <20080924104331.GA19717 at physik.rwth-aachen.de>
> Content-Type: text/plain; charset=iso-8859-1
>
> Hi list,
>
> is there a way to see all links a site has in its pages?
>
> I thought of doing something of wget -r from the outside but when
> there is a way to obtain this information through opencms from within
> the workplace I'd be happier.
>
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 24 Sep 2008 11:50:24 +0100
> From: "Olli Aro" <olli_aro at yahoo.co.uk>
> Subject: Re: [opencms-dev] show all links in a site
> To: "'The OpenCms mailing list'" <opencms-dev at opencms.org>
> Message-ID:
> <!&!AAAAAAAAAAAYAAAAAAAAAJvPto8dXaJNqufVsxzMG9DCgAAAEAAAAEBFeuJvYVdFuwrl0r9+Sl8BAAAAAA==@yahoo.co.uk>
>
> Content-Type: text/plain; charset="us-ascii"
>
> You could always write your custom content parser.
>
> http://www.opencms-wiki.org/Custom_Content_Parser
>
> Regards,
>
> Olli
>
> -----Original Message-----
> From: opencms-dev-bounces at opencms.org
> [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Christoph P. 
> Kukulies
> Sent: 24 September 2008 11:44
> To: opencms-dev at opencms.org
> Subject: [opencms-dev] show all links in a site
>
> Hi list,
>
> is there a way to see all links a site has in its pages?
>
> I thought of doing something of wget -r from the outside but when
> there is a way to obtain this information through opencms from within
> the workplace I'd be happier.
>
> --
> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>
>
> _______________________________________________
> 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
>
>
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 24 Sep 2008 06:02:21 -0700 (PDT)
> From: Rita2008 <rita.risso at castagna.it>
> Subject: Re: [opencms-dev] Multiple newsletters subscription
> To: opencms-dev at opencms.org
> Message-ID: <19648286.post at talk.nabble.com>
> Content-Type: text/plain; charset=UTF-8
>
>
> hi,
>
> thanks for the hint;
> i have read the included .pdf manual about registration module;
> i tried to create the registration form in order to manage more than one
> subscription to the newsletters, but i encountered the following problem:
>
> - in the "User Creation Options" section/fields, i can choose only one
> organizational newsletter unit
> , and not more than one.
>
> so that inside the reg. form, how can i tie user fields to more than one
> newsletter
> at the same time ?
> (the example included inside .pdf manual shows two radio buttons with two
> selectable newsletters
> but unfortunately those fields configuration settings are hidden in the
> manual)
>
> thanks in advance for your help.
> bye,
> Rita.
>
>
>
> marc fi?vet-2 wrote:
>>
>> Hello Rita,
>>
>> I think the best way to do it it's to use the Alkacon registration module
>> and in the webform fields proposes,via  the check box field the
>> newsletters.
>>
>> Kind  regards
>>
>> MARC
>>
>>
>> -----Original message-----
>> From: "Rita Risso" rita.risso at castagna.it
>> Date: Tue, 23 Sep 2008 09:51:26 +0200
>> To: "'The OpenCms mailing list'" opencms-dev at opencms.org
>> Subject: [opencms-dev] Multiple newsletters subscription
>>
>>> Hi list,
>>>
>>> I've installed the Alkacon newsletter module for Opencms. I was 
>>> wondering
>>> if
>>> it is possible to create a web page to allow a user to subscribe to one
>>> or
>>> more newsletter at the same time. For better understanding:
>>>
>>> 1. the web page should have a list of check button to select the
>>> newsletter I want to subscribe
>>> 2. the user can select one or more newsletter
>>> 3. when the user press the "Confirm" button OpenCms should insert the
>>> user data in all the newsletter selected in a way that is completely
>>> invisible for the user
>>>
>>>
>>>
>>> That's all.. ;-)
>>>
>>> Any suggestion?
>>>
>>>
>>>
>>> Thanks
>>>
>>> Rita
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> 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
>>
>>
>
> -- 
> View this message in context: 
> http://www.nabble.com/Alkacon-OAMP-%22Module-Comments%22-problems-tp19455362p19648286.html
> Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
>
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 24 Sep 2008 17:38:15 +0200
> From: mailinglists <mailinglists at pcom.at>
> Subject: Re: [opencms-dev] [XSD, content rendering] Beginner question
> - I receive "??? xyz ???" when accessing xml elements
> To: The OpenCms mailing list <opencms-dev at opencms.org>
> Message-ID: <48DA5EE7.4060105 at pcom.at>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Thanks for the feedback!
>
> Your hint and an some more api source reading did the trick ... and
> opened a new question ([locale vs. language when accessing content]
> OpenCMS does only use the language and does not handle Locales properly?)
>
> br,
> Philip
>
> Florian Gutmann wrote:
>> cms:contentcheck should be what you are looking for.
>>
>> Normally i read structured contents something like this:
>>
>> <cms:contentload collector="singleFile" param="${file}" editable="true">
>> <cms:contentcheck ifexists="Content/Title">
>> <h3><cms:contentshow element="Content/ Title "/></h3>
>> </cms:contentcheck>
>> </cms:contentload>
>>
>> --
>>
>> Florian
>>
>> -----Urspr?ngliche Nachricht-----
>> Von: opencms-dev-bounces at opencms.org
>> [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von mailinglists
>> Gesendet: Dienstag, 23. September 2008 19:09
>> An: opencms-dev at opencms.org
>> Betreff: [opencms-dev] [XSD, content rendering] Beginner question - I
>> receive "??? xyz ???" when accessing xml elements
>>
>>
> [...]
>  How to check is a content item does really contain a specific element.
> [...]
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 24 Sep 2008 18:13:04 +0200
> From: mailinglists <mailinglists at pcom.at>
> Subject: [opencms-dev] [locale vs. language when accessing content]
> OpenCMS does only use the language and does not handle Locales
> properly?
> To: opencms-dev at opencms.org
> Message-ID: <48DA6710.3050706 at pcom.at>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> When trying to find out if a specific xml element is present in a
> content item I had the problem that I could not use
> "request.getLocale()" as locale for the CmsJspTagContentCheck.
>
> The browsers request locale in my case is "en_US". When using the
> request locale to access or check content (which in fact is "en"
> content) the api does return null (or false). When creating a new locale
> after cropping the country from the Locale everything works fine (see
> code below). As the cms backend does only provide interfaces to set the
> content language and not the content locale I assume this to be an
> improper implementation of Locale/language handling.
>
> br,
> Philip
>
> Example 1 - works fine:
> ******************
> code:
>     List li =
> content.getContentContainer().getXmlDocument().getNames(java.util.Locale.ENGLISH);
>
>     log.debug("Locale: "+java.util.Locale.ENGLISH);
>     log.debug("Elements: "+li);
> output:
>     Locale: en
>     Elements: [Elements[1]/Item[1], ShowBreadCrumbs[1],
> ShowLeftNavigation[1], Elements[1]/elementParam2[1], ...<snip>
>
>
> Example 2 - returns empty list:
> ******************
> code:
>     List li =
> content.getContentContainer().getXmlDocument().getNames(request.getLocale());
>
>     log.debug("Locale: "+request.getLocale());
>     log.debug("Elements: "+li);
> output:
>     Locale: en_US
>     Elements: []
>
>
> Example 2 - works fine:
> ******************
> code:
>     List li =
> content.getContentContainer().getXmlDocument().getNames(new
> Locale(request.getLocale().getLanguage()));
>     log.debug("Locale: "+new Locale(request.getLocale().getLanguage()));
>     log.debug("Elements: "+li);
> output:
>     Locale: en
>     Elements: [Elements[1]/Item[1], ShowBreadCrumbs[1],
> ShowLeftNavigation[1], Elements[1]/elementParam2[1], ...<snip>
>
>
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> http://lists.opencms.org/pipermail/opencms-dev/attachments/20080924/c9076290/attachment.html
>
> ------------------------------
>
> Message: 8
> Date: Wed, 24 Sep 2008 23:58:25 +0100
> From: "Fidel Viegas" <fidel.viegas at gmail.com>
> Subject: Re: [opencms-dev] Configuring Multisite without mod_jk
> To: opencms-dev at opencms.org
> Message-ID:
> <3d3c4b7e0809241558h60763638iba6d8d6025620cc8 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> On Tue, Sep 23, 2008 at 4:00 PM, Fidel Viegas <fidel.viegas at gmail.com> 
> wrote:
>> Hi folks,
>>
>> I have been reading the documenation about setting up opencms or
>> multisites, and I was wondering if there an alternative way of
>> configuring opencms using only tomcat. Also, is there a way of getting
>> rid of the /opencms/opencms/ prefix by using only tomcat?
>
> Ok, I guess that for mulsite settings I really have to use mod_jk.
> Now, with regards to getting rid of the /opencms/opencms/ from within
> tomcat only, I tried to mess with the web.xml and I tried everything
> to get rid of it. I managed to get rid of the first /opencms by making
> the app ROOT. Now, when I tried to change the context-param and the
> servlet-mapping to /*, it did not work. A blank page would show up. I
> can, though, change from opencms to any other name. That works fine.
>
> Does anyone know a workaround to this? What should I set both the
> context-param and the servlet-mapping to in order to get rid of the
> last opencms prefix?
>
> This is what I have tried:
>
>    <context-param>
>
>        <param-name>OpenCmsServlet</param-name>
>
>        <param-value>/*</param-value>
>
>    </context-param>
>
>    <servlet-mapping>
>
>        <servlet-name>OpenCmsServlet</servlet-name>
>
>        <url-pattern>/*</url-pattern>
>
>    </servlet-mapping>
>
> And I don't get any error message from trying to access the
> /system/login, just a blank page.
>
> Can someone help me with this?
>
> Thanks in advance,
>
> Fidel.
>
>
> ------------------------------
>
> Message: 9
> Date: Wed, 24 Sep 2008 22:58:34 -0500
> From: "J Arrazolo" <jarrazolo at gmail.com>
> Subject: [opencms-dev] best approach
> To: <opencms-dev at opencms.org>
> Message-ID: <BC4E181658204A638BEDD3C83F0084E9 at JosePC>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi list,
>
>
>
> I am new to OpenCms but have done some CMS development in 
> BroadVision/Java.
> So, is there a way to extend the OpenCms database to install my own
> application tables?  What is the approach to take if I need to develop
> functionality like this?  Add a new module?  Will this module have its own
> dedicated tables/columns?  Is the OpenCms a relational database?  Are 
> there
> any examples out there on how to do this?
>
>
>
> Thanks for any help
>
>
>
> -Jose
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> http://lists.opencms.org/pipermail/opencms-dev/attachments/20080925/2dc6e9ce/attachment-0001.htm
>
> ------------------------------
>
> _______________________________________________
> 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
>
> End of opencms-dev Digest, Vol 207, Issue 4
> *******************************************
> 



More information about the opencms-dev mailing list