[Hippo-cms7-user] Templates stored in the repo

Mansour Al Akeel mansour.alakeel at gmail.com
Tue Jun 8 17:41:41 CEST 2010


Hello Ard:
Thank you for your help. I tried everything I can, and I was not able to
get anywhere. 
I did remote debugging, and I was not able to hit any break point in the
RepositoryTemplateLoader class. The code doesn't get into this class at
all. 
On the other hand when I use 
    repository://content/documents/templates/contact.ftl
I get the following debug message:

2010-06-08 18:25:47,413 [http-8080-3] DEBUG freemarker.cache - repository:/content/documents/tampletes/contact.ftl[en_US,ISO-8859-1,parsed] no source found.

When I use: 
    repository://content/documents/templates/contact.ftl/hst:template
    or 
    repository://content/documents/templates/contact.ftl/contact:code

I don't get any debug message. In both cases the templates are not
displayed, and the break points are not hit. 

By the way, I am using Release 2.04.04, I am not sure if this one is the
right one.

Please let me know if you have any suggestions. 

Thank you. 


On Wed Jun 02,2010 04:26 pm, Ard Schrijvers wrote:
> Hello Mansour,
> 
> I looked at the RepositoryTemplateLoader code again (I've never
> completely finished all edges there), so what I did was the following:
> 
> If the path points to a jcr node, I by default try to fetch the
> property 'hst:template'
> 
> You have filled in hst:code, so that is not working. But, if you point
> your path to a property, I take that property. Thus you can try with:
> 
> repository://content/documents/templates/contact.ftl/hst:code
> 
> OTOH, I really would recommend you to rename 'hst:freemarkerTemplate'
> --> 'myns:freemarkerTemplate' and 'hst:code' --> 'myns:code' : you
> should declare nodetypes and properties of namespaces that are not
> yours, it might lead you into troubles when later on, the hst ns for
> example starts using the nodetype hst:freemarkerTemplate and you want
> to update.
> 
> Furthermore, the code I am referring to is in
> RepositoryTemplateLoader, you might want to debug through it.
> Specifically this method:
> 
> Regards Ard, hope this helps
> 
> private RepositorySource getRepositoryTemplate(String absPath) {
>         String template = null;
>         Session session = null;
>         try {
>             session = getSession();
>             if(session.itemExists(absPath)) {
>                 Item item = session.getItem(absPath);
>                 if(item.isNode()) {
>                     template =
> ((Node)item).getProperty(HstNodeTypes.SCRIPT_PROPERTY_TEMPLATE).getValue().getString();
>                 } else {
>                     template = ((Property)item).getValue().getString();
>                 }
>                 return new RepositorySource(template);
>             }
>         } catch (RepositoryException e) {
>             e.printStackTrace();
>         } finally {
>             if(session != null) {
>                 session.logout();
>             }
>         }
>         if(template == null ) {
>             template = "Template source '"+ absPath +"' not found in
> the repository. ";
>         }
>         return RepositorySource.repositorySourceNotFound;
>     }
> 
> 
> On Wed, Jun 2, 2010 at 2:54 PM, Mansour Al Akeel
> <mansour.alakeel at gmail.com> wrote:
> > Hello Ard:
> > I have checked again, and found that all the nodes are present.
> > Here's the types.cnd:
> >
> > <'contact'='http://www.mysite.com/hippocms/contact/0.12'>
> > <'nt'='http://www.jcp.org/jcr/nt/1.0'>
> > <'hippo'='http://www.onehippo.org/jcr/hippo/nt/2.0.1'>
> > <'hippostd'='http://www.onehippo.org/jcr/hippostd/nt/2.0'>
> > <'hippostdpubwf'='http://www.onehippo.org/jcr/hippostdpubwf/nt/1.0'>
> > <'hst'='http://www.hippoecm.org/hst/nt/1.4'>
> >
> > [contact:message] > hippo:document, hippostd:publishableSummary,
> > hippostdpubwf:document
> > ? ?- contact:firstName (string)
> > ? ?- contact:email (string)
> > ? ?- contact:organization (string)
> > ? ?- contact:text (string)
> > ? ?- contact:lastName (string)
> >
> > [hst:freemarkerTemplate]
> > ? ?- hst:code (String)
> >
> > I will change the namespace once I get this to work fine. Here's the
> > message I get when I request the page,
> >
> > 2010-06-02 15:44:11,525 [75373366 at qtp-1032432821-5] DEBUG freemarker.cache - Could not find template in cache, creating new one; id=[/repository://content/documents/templates/contact.ftl[en_US,ISO-8859-1,parsed] ]
> >
> > Subsequent requests gives:
> >
> > 2010-06-02 15:44:36,248 [1802843879 at qtp-1032432821-4] DEBUG freemarker.cache - /repository://content/documents/templates/contact.ftl[en_US,ISO-8859-1,parsed] no source found.
> >
> > I have followed your steps, and modifed the renderpath from :
> > jsp/component/contact.jsp
> >
> > to the following:
> >
> > repository://content/documents/templates/contact.ftl
> >
> > created the "templates" hippostd:directory, and a node called
> > "contact.ftl" of type, hst:freemarkerTemplate. Then I added a propery
> > "hst:code" with value "This is my freemarker template".
> >
> > Any idea ?
> >
> >
> > On Wed Jun 02,2010 01:22 pm, Ard Schrijvers wrote:
> >> Hello Mansour,
> >>
> >> No, the slash is added during the dispatcher call, and the
> >> RepositoryTemplateLoader expects it.
> >>
> >> If there are more people who need it we can try to put it in the 2.05
> >> hst. I am not sure whether this will be to late for, as we are
> >> currently working on the 2.05.
> >>
> >> Otherwise, you can step through a debugger to see where your issue is.
> >> It might be that some node is not present you are referring to?
> >>
> >> Regards Ard
> >>
> >> On Wed, Jun 2, 2010 at 1:12 PM, Mansour Al Akeel
> >> <mansour.alakeel at gmail.com> wrote:
> >> > Hello Ard:
> >> >
> >> > I am still having an issue with templates.
> >> >
> >> > 2010-06-02 13:47:11,258 [1269922636 at qtp-1190881123-4] DEBUG freemarker.cache - /repository://content/documents/templates/c.ftl[en_US,ISO-8859-1,parsed] no source found.
> >> >
> >> > Does this tell you anything. I can see it adding "/" before the world
> >> > "repository:". Could this be the problem ?
> >> >
> >> > Thank you.
> >> >
> >> > On Tue Jun 01,2010 02:56 pm, Ard Schrijvers wrote:
> >> >> On Tue, Jun 1, 2010 at 1:47 PM, Mansour Al Akeel
> >> >> <mansour.alakeel at gmail.com> wrote:
> >> >> > Hello Ard:
> >> >> >
> >> >> > [hst:freemarkerTemplate] > nt:base
> >> >> > ?- hst:code (hst:template)
> >> >>
> >> >> A - is for a property, but hst:template is a nodetype. Also see the
> >> >> jackrabbit cnd documentation.
> >> >>
> >> >>
> >> >> [hst:freemarkerTemplate]
> >> >> - hst:code (String)
> >> >>
> >> >> should be fine, although I would not reuse a namespace prefix that is
> >> >> not yours. Thus rather make it:
> >> >>
> >> >> [mynamespace:freemarkerTemplate]
> >> >> - hst:code (String)
> >> >>
> >> >> Regards Ard
> >> >>
> >> >> >
> >> >> > Here's the exception:
> >> >> >
> >> >> > rg.apache.jackrabbit.core.nodetype.compact.ParseException: Unkown property type 'hst:template' specified (jar:file:/home/mansour/workspace/hippo-cms/mysite/cms/target/work/webapp/WEB-INF/lib/contact-content-1.0-SNAPSHOT.jar!/types.cnd, line 16)
> >> >> > ? ? ? ? ? ? ? ?at org.apache.jackrabbit.core.nodetype.compact.Lexer.fail(Lexer.java:148)
> >> >> > ? ? ? ? ? ? ? ?at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doPropertyType(CompactNodeTypeDefReader.java:444)
> >> >> > ? ? ? ? ? ? ? ?at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doPropertyDefinition(CompactNodeTypeDefReader.java:406)
> >> >> > ? ? ? ? ? ? ? ?at org.apache.jackrabbit.core.nodetype.compact.CompactNodeTypeDefReader.doItemDefs(CompactNodeTypeDefReader.java:361)
> >> >> >
> >> >> > I don't know what's wrong.
> >> >> >
> >> >> > Now with regard to making this functionality avialable by default, I won't
> >> >> > recommend it. If you like we can discuss this further.
> >> >> >
> >> >> > Thank you.
> >> >> >
> >> >> >
> >> >> > On Tue May 25,2010 10:03 am, Ard Schrijvers wrote:
> >> >> >> Hello Mansour,
> >> >> >>
> >> >> >> I did have it all running locally (including caching & invalidation),
> >> >> >> but unfortunately, at that moment, I did not want to check it in as it
> >> >> >> meant a cnd change. Currently we are working on the 2.05.0xx. If more
> >> >> >> people need it, we can make sure it is available by default.
> >> >> >>
> >> >> >> OTOH, it should be pretty simple to get it up & running. All you need
> >> >> >> it instead of having a template like:
> >> >> >>
> >> >> >> /jsp/news/overview.jsp you add something like:
> >> >> >>
> >> >> >> repository://freemarker/scripts/news/overview.ftl
> >> >> >>
> >> >> >> Now, you make sure, that you have a node (some custom type of your
> >> >> >> project) below the root with:
> >> >> >>
> >> >> >> freemarker
> >> >> >> ? ? ?`scripts
> >> >> >> ? ? ? ? ? `news
> >> >> >> ? ? ? ? ? ? ? ?`overview.ftl
> >> >> >>
> >> >> >> where the node overview.ftl contains a property 'hst:template' . In
> >> >> >> this property, you can drop the freemarker code. That should be pretty
> >> >> >> much it (and of course, add the freemarker servlet to your web.xml)
> >> >> >>
> >> >> >> Ard
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> On Sun, May 23, 2010 at 5:32 PM, Mansour Al Akeel
> >> >> >> <mansour.alakeel at gmail.com> wrote:
> >> >> >> > Hello all:
> >> >> >> > I am wondering if there's an example code for
> >> >> >> > org.hippoecm.hst.freemarker.RepositoryTemplateLoader showing how to
> >> >> >> > store templated in the repo ?
> >> >> >> >
> >> >> >> >
> >> >> >> > _______________________________________________
> >> >> >> > Hippo-cms7-user mailing list and forums
> >> >> >> > http://www.onehippo.org/cms7/support/forums.html
> >> >> >> >
> >> >> >> _______________________________________________
> >> >> >> Hippo-cms7-user mailing list and forums
> >> >> >> http://www.onehippo.org/cms7/support/forums.html
> >> >> > _______________________________________________
> >> >> > Hippo-cms7-user mailing list and forums
> >> >> > http://www.onehippo.org/cms7/support/forums.html
> >> >> >
> >> >> _______________________________________________
> >> >> Hippo-cms7-user mailing list and forums
> >> >> http://www.onehippo.org/cms7/support/forums.html
> >> > _______________________________________________
> >> > Hippo-cms7-user mailing list and forums
> >> > http://www.onehippo.org/cms7/support/forums.html
> >> >
> >> _______________________________________________
> >> Hippo-cms7-user mailing list and forums
> >> http://www.onehippo.org/cms7/support/forums.html
> > _______________________________________________
> > Hippo-cms7-user mailing list and forums
> > http://www.onehippo.org/cms7/support/forums.html
> >
> _______________________________________________
> Hippo-cms7-user mailing list and forums
> http://www.onehippo.org/cms7/support/forums.html



More information about the Hippo-cms7-user mailing list