Template Injection

View: New views
4 Messages — Rating Filter:   Alert me  

Template Injection

by Austin Coose :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


What is the best way to inject a template?

I tried to use the method based on the wiki example of default  
template associated with an element:

private Template template
        public getTemplate() { return template }
        public void setTemplate(Template template) { this.template = template }

public void processElement () {
        . . .
}

And the in the site.xml

<element  . . .>
<property name="template">
<template type="html">common.navigation</template>
</property>
</element>

When I explicitly declare the template with "Template template =  
getHtmlTemplate("common.navigation")", then everything works and gets  
printed out normally, but when I use the above method, I get an error  
that says it can not find the embedded element, when I comment out "  
processEmbeddedElement(template, "CategoryEntry"); " in the  
implementation, then the template gets printed out with the static  
html and so does  ${v ELEMENT:CategoryEntry /}.

I also tried several other methods to inject a template buy viewing  
the API for Template and ElementSupport, along with several others,  
most of the time template ended up being null, or the same problem as  
above. I tried so many things and I included one at least with a  
frame of reference.  I played around with code implementation and the  
template itself, just to see if I could get anything to work, but  
alas, to no avail.

What am I missing?

Thanks for any help.

Austin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Template Injection

by Geert Bevin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Austin,

the way you're injecting the template if perfectly fine.

The error about the embedded element not being able to be found is  
related to the ID you're using. If you use a relative ID (like the  
one you're using: CategoryEntry), then it will look for that embedded  
element according to the element that's actually using the template.  
If you start with a dot, you use an absolute ID (for  
instance: .Pub.CategoryEntry). Those will always be found.

It could be that by injecting the template in the site structure,  
you're applying it one or several elements. Maybe one of those is  
located somewhere that causes the relative lookup to fail.

HTH,

Geert

On 14 Oct 2007, at 16:01, Austin Coose wrote:

>
> What is the best way to inject a template?
>
> I tried to use the method based on the wiki example of default
> template associated with an element:
>
> private Template template
> public getTemplate() { return template }
> public void setTemplate(Template template) { this.template =  
> template }
>
> public void processElement () {
> . . .
> }
>
> And the in the site.xml
>
> <element  . . .>
> <property name="template">
> <template type="html">common.navigation</template>
> </property>
> </element>
>
> When I explicitly declare the template with "Template template =
> getHtmlTemplate("common.navigation")", then everything works and gets
> printed out normally, but when I use the above method, I get an error
> that says it can not find the embedded element, when I comment out "
> processEmbeddedElement(template, "CategoryEntry"); " in the
> implementation, then the template gets printed out with the static
> html and so does  ${v ELEMENT:CategoryEntry /}.
>
> I also tried several other methods to inject a template buy viewing
> the API for Template and ElementSupport, along with several others,
> most of the time template ended up being null, or the same problem as
> above. I tried so many things and I included one at least with a
> frame of reference.  I played around with code implementation and the
> template itself, just to see if I could get anything to work, but
> alas, to no avail.
>
> What am I missing?
>
> Thanks for any help.
>
> Austin
>
> >

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Template Injection

by Austin Coose :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks Geert, once again, this was very helpful. It solved quite a  
few issues that I was having that I had just worked around, now it is  
easier and cleaner.


Austin
On Oct 15, 2007, at 5:25 AM, Geert Bevin wrote:

>
> Hi Austin,
>
> the way you're injecting the template if perfectly fine.
>
> The error about the embedded element not being able to be found is
> related to the ID you're using. If you use a relative ID (like the
> one you're using: CategoryEntry), then it will look for that embedded
> element according to the element that's actually using the template.
> If you start with a dot, you use an absolute ID (for
> instance: .Pub.CategoryEntry). Those will always be found.
>
> It could be that by injecting the template in the site structure,
> you're applying it one or several elements. Maybe one of those is
> located somewhere that causes the relative lookup to fail.
>
> HTH,
>
> Geert
>
> On 14 Oct 2007, at 16:01, Austin Coose wrote:
>
>>
>> What is the best way to inject a template?
>>
>> I tried to use the method based on the wiki example of default
>> template associated with an element:
>>
>> private Template template
>> public getTemplate() { return template }
>> public void setTemplate(Template template) { this.template =
>> template }
>>
>> public void processElement () {
>> . . .
>> }
>>
>> And the in the site.xml
>>
>> <element  . . .>
>> <property name="template">
>> <template type="html">common.navigation</template>
>> </property>
>> </element>
>>
>> When I explicitly declare the template with "Template template =
>> getHtmlTemplate("common.navigation")", then everything works and gets
>> printed out normally, but when I use the above method, I get an error
>> that says it can not find the embedded element, when I comment out "
>> processEmbeddedElement(template, "CategoryEntry"); " in the
>> implementation, then the template gets printed out with the static
>> html and so does  ${v ELEMENT:CategoryEntry /}.
>>
>> I also tried several other methods to inject a template buy viewing
>> the API for Template and ElementSupport, along with several others,
>> most of the time template ended up being null, or the same problem as
>> above. I tried so many things and I included one at least with a
>> frame of reference.  I played around with code implementation and the
>> template itself, just to see if I could get anything to work, but
>> alas, to no avail.
>>
>> What am I missing?
>>
>> Thanks for any help.
>>
>> Austin
>>
>>>
>
> --
> Geert Bevin
> Terracotta - http://www.terracotta.org
> Uwyn "Use what you need" - http://uwyn.com
> RIFE Java application framework - http://rifers.org
> Music and words - http://gbevin.com
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Template Injection

by Geert Bevin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Glad it helped, Austin.

One more remark about the relative element IDs. You can also use the  
^ character to go up the hierarchy. This is similar to .. in file  
system paths, except that you don't need the / (or the dot with  
element IDs) after the 'one level up' char.

For example, say you have an element in the site .Pub.Stuff.Foo. and  
you want to refer to the Home element in the .Pub.Fum. site. Then you  
can use ^^Fum.Home

HTH,

Geert

On 16 Oct 2007, at 15:55, Austin Coose wrote:

>
> Thanks Geert, once again, this was very helpful. It solved quite a
> few issues that I was having that I had just worked around, now it is
> easier and cleaner.
>
>
> Austin
> On Oct 15, 2007, at 5:25 AM, Geert Bevin wrote:
>
>>
>> Hi Austin,
>>
>> the way you're injecting the template if perfectly fine.
>>
>> The error about the embedded element not being able to be found is
>> related to the ID you're using. If you use a relative ID (like the
>> one you're using: CategoryEntry), then it will look for that embedded
>> element according to the element that's actually using the template.
>> If you start with a dot, you use an absolute ID (for
>> instance: .Pub.CategoryEntry). Those will always be found.
>>
>> It could be that by injecting the template in the site structure,
>> you're applying it one or several elements. Maybe one of those is
>> located somewhere that causes the relative lookup to fail.
>>
>> HTH,
>>
>> Geert
>>
>> On 14 Oct 2007, at 16:01, Austin Coose wrote:
>>
>>>
>>> What is the best way to inject a template?
>>>
>>> I tried to use the method based on the wiki example of default
>>> template associated with an element:
>>>
>>> private Template template
>>> public getTemplate() { return template }
>>> public void setTemplate(Template template) { this.template =
>>> template }
>>>
>>> public void processElement () {
>>> . . .
>>> }
>>>
>>> And the in the site.xml
>>>
>>> <element  . . .>
>>> <property name="template">
>>> <template type="html">common.navigation</template>
>>> </property>
>>> </element>
>>>
>>> When I explicitly declare the template with "Template template =
>>> getHtmlTemplate("common.navigation")", then everything works and  
>>> gets
>>> printed out normally, but when I use the above method, I get an  
>>> error
>>> that says it can not find the embedded element, when I comment out "
>>> processEmbeddedElement(template, "CategoryEntry"); " in the
>>> implementation, then the template gets printed out with the static
>>> html and so does  ${v ELEMENT:CategoryEntry /}.
>>>
>>> I also tried several other methods to inject a template buy viewing
>>> the API for Template and ElementSupport, along with several others,
>>> most of the time template ended up being null, or the same  
>>> problem as
>>> above. I tried so many things and I included one at least with a
>>> frame of reference.  I played around with code implementation and  
>>> the
>>> template itself, just to see if I could get anything to work, but
>>> alas, to no avail.
>>>
>>> What am I missing?
>>>
>>> Thanks for any help.
>>>
>>> Austin
>>>
>>>>
>>
>> --
>> Geert Bevin
>> Terracotta - http://www.terracotta.org
>> Uwyn "Use what you need" - http://uwyn.com
>> RIFE Java application framework - http://rifers.org
>> Music and words - http://gbevin.com
>>
>>
>>>
>
>
> >

--
Geert Bevin
Terracotta - http://www.terracotta.org
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "rife-users" group.
To post to this group, send email to rife-users@...
To unsubscribe from this group, send email to rife-users-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/rife-users?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price!
 
 
 
Google
rifers.org web