Loading templates at run-time in Tapestry 5.4

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Loading templates at run-time in Tapestry 5.4

David Diaz
Hi all,

I have been using Tapestry for a little bit now and I have run into one
problem that I can't figure out how to solve.

In my application I need to be able to load external code & HTML to display
to the user from a trusted source at run-time. Currently I have gotten code
to load fine and I am using outputraw to render the result from the code.
This is pretty bad though since I have to code the HTML within the Java
file instead of having it templated.

I saw that Tapestry has a "Dynamic" component that allows loading templates
from an external source but I tried using it - it tries loading a file from
the file system at page creation time... this is not suitable for my use
case since I need to load it from a String and I need to do it at render
time.

I also tried messing around with DynamicTemplateParser & MarkupWriter but I
couldn't get it to bind to my properties/functions since the code is loaded
at runtime and is not defined at compile time (I would hit a NPE when the
PropBindingFactory would try and locate the component).

If anyone could suggest any way of accomplishing this (or if it's futile
and I'm wasting my time), it would be really appreciated.

Thanks,
David.
Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Jens Breitenstein
Hi David!

What do you mean by "external code"? Are you talking about external Tapestry pages/components and tml's you need to integrate? Because you mentiond HTML not TML? Does "code" refer to Javascript? Is the external code self contained? What about an ugly but simple "iframe"?

Jens


Von meinem iPhone gesendet

> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
>
> Hi all,
>
> I have been using Tapestry for a little bit now and I have run into one
> problem that I can't figure out how to solve.
>
> In my application I need to be able to load external code & HTML to display
> to the user from a trusted source at run-time. Currently I have gotten code
> to load fine and I am using outputraw to render the result from the code.
> This is pretty bad though since I have to code the HTML within the Java
> file instead of having it templated.
>
> I saw that Tapestry has a "Dynamic" component that allows loading templates
> from an external source but I tried using it - it tries loading a file from
> the file system at page creation time... this is not suitable for my use
> case since I need to load it from a String and I need to do it at render
> time.
>
> I also tried messing around with DynamicTemplateParser & MarkupWriter but I
> couldn't get it to bind to my properties/functions since the code is loaded
> at runtime and is not defined at compile time (I would hit a NPE when the
> PropBindingFactory would try and locate the component).
>
> If anyone could suggest any way of accomplishing this (or if it's futile
> and I'm wasting my time), it would be really appreciated.
>
> Thanks,
> David.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

David Diaz
Hi Jens,

Yes I have external pages that I need to integrate. And by code I mean the
actual .java page that would (hopefully) power the .tml.

The problem I have is that I need to (obviously) render content in a
specific way, but the application I am writing needs to load the templates
dynamically.

Thanks,
David.

On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <[hidden email]>
wrote:

> Hi David!
>
> What do you mean by "external code"? Are you talking about external
> Tapestry pages/components and tml's you need to integrate? Because you
> mentiond HTML not TML? Does "code" refer to Javascript? Is the external
> code self contained? What about an ugly but simple "iframe"?
>
> Jens
>
>
> Von meinem iPhone gesendet
>
> > Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
> >
> > Hi all,
> >
> > I have been using Tapestry for a little bit now and I have run into one
> > problem that I can't figure out how to solve.
> >
> > In my application I need to be able to load external code & HTML to
> display
> > to the user from a trusted source at run-time. Currently I have gotten
> code
> > to load fine and I am using outputraw to render the result from the code.
> > This is pretty bad though since I have to code the HTML within the Java
> > file instead of having it templated.
> >
> > I saw that Tapestry has a "Dynamic" component that allows loading
> templates
> > from an external source but I tried using it - it tries loading a file
> from
> > the file system at page creation time... this is not suitable for my use
> > case since I need to load it from a String and I need to do it at render
> > time.
> >
> > I also tried messing around with DynamicTemplateParser & MarkupWriter
> but I
> > couldn't get it to bind to my properties/functions since the code is
> loaded
> > at runtime and is not defined at compile time (I would hit a NPE when the
> > PropBindingFactory would try and locate the component).
> >
> > If anyone could suggest any way of accomplishing this (or if it's futile
> > and I'm wasting my time), it would be really appreciated.
> >
> > Thanks,
> > David.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

trsvax
I did something like this a while ago. I stored the .tml file on Amazon S3
and I wrote an S3 asset to load the template. The code is here

https://github.com/trsvax/tapestry-aws



On Monday, February 29, 2016, David Diaz <[hidden email]> wrote:

> Hi Jens,
>
> Yes I have external pages that I need to integrate. And by code I mean the
> actual .java page that would (hopefully) power the .tml.
>
> The problem I have is that I need to (obviously) render content in a
> specific way, but the application I am writing needs to load the templates
> dynamically.
>
> Thanks,
> David.
>
> On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <javascript:;> <
> [hidden email] <javascript:;>>
> wrote:
>
> > Hi David!
> >
> > What do you mean by "external code"? Are you talking about external
> > Tapestry pages/components and tml's you need to integrate? Because you
> > mentiond HTML not TML? Does "code" refer to Javascript? Is the external
> > code self contained? What about an ugly but simple "iframe"?
> >
> > Jens
> >
> >
> > Von meinem iPhone gesendet
> >
> > > Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]
> <javascript:;>>:
> > >
> > > Hi all,
> > >
> > > I have been using Tapestry for a little bit now and I have run into one
> > > problem that I can't figure out how to solve.
> > >
> > > In my application I need to be able to load external code & HTML to
> > display
> > > to the user from a trusted source at run-time. Currently I have gotten
> > code
> > > to load fine and I am using outputraw to render the result from the
> code.
> > > This is pretty bad though since I have to code the HTML within the Java
> > > file instead of having it templated.
> > >
> > > I saw that Tapestry has a "Dynamic" component that allows loading
> > templates
> > > from an external source but I tried using it - it tries loading a file
> > from
> > > the file system at page creation time... this is not suitable for my
> use
> > > case since I need to load it from a String and I need to do it at
> render
> > > time.
> > >
> > > I also tried messing around with DynamicTemplateParser & MarkupWriter
> > but I
> > > couldn't get it to bind to my properties/functions since the code is
> > loaded
> > > at runtime and is not defined at compile time (I would hit a NPE when
> the
> > > PropBindingFactory would try and locate the component).
> > >
> > > If anyone could suggest any way of accomplishing this (or if it's
> futile
> > > and I'm wasting my time), it would be really appreciated.
> > >
> > > Thanks,
> > > David.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> <javascript:;>
> > For additional commands, e-mail: [hidden email]
> <javascript:;>
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Thiago H de Paula Figueiredo
In reply to this post by David Diaz
On Mon, 29 Feb 2016 01:18:43 -0300, David Diaz <[hidden email]> wrote:

> Hi all,

Hi!

> I have been using Tapestry for a little bit now and I have run into one
> problem that I can't figure out how to solve.
>
> In my application I need to be able to load external code & HTML to  
> display to the user from a trusted source at run-time. Currently I have  
> gotten code to load fine and I am using outputraw to render the result  
> from the code.
> This is pretty bad though since I have to code the HTML within the Java
> file instead of having it templated.

IMHO, Tapestry templates were not built for this kind of situation  
(dynamic loading of templates), even if it has some support for it. In  
your case, I'd try using a general-purpose template framework like  
Freemarker.

How are you doing the fetching-code-from-outside-server part? Grabbing the  
.class file from outside and overwriting the corresponding class locally?

> I saw that Tapestry has a "Dynamic" component that allows loading  
> templates> from an external source but I tried using it - it tries  
> loading a file from> the file system at page creation time... this is  
> not suitable for my use
> case since I need to load it from a String and I need to do it at render
> time.

I'm afraid your statement is incorrect. Dynamic's template parameter is of  
type Asset, which is an interface, and you can implement it based on a  
String just fine.

> I also tried messing around with DynamicTemplateParser & MarkupWriter  
> but I couldn't get it to bind to my properties/functions since the code  
> is loaded at runtime and is not defined at compile time (I would hit a  
> NPE when the
> PropBindingFactory would try and locate the component).

Full stack trace please. :)

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Jens Breitenstein
In reply to this post by David Diaz
I see. So a tapestry TML without a JAVA class is not considerably dynamic as it has no business logic at all. Either your 3rd party delivers TML+CLASS (only components from my point of view) than you can integrate it as module. But this is far away from "dynamic". If you provide the logic, the TML can not change anything nor add something new, so its about rearanging HTML or changing the style, but this is not what you want either, right? Because this might be a pure CSS related topic.

Can you give us a real piece of code you get from your 3rd party for integration? Maybe it's really an iframe, an external template engine (to render raw output) or something completely different like angular...
I am still confused about the requirements...

Sorry

Jens

Von meinem iPhone gesendet

> Am 29.02.2016 um 09:05 schrieb David Diaz <[hidden email]>:
>
> Hi Jens,
>
> Yes I have external pages that I need to integrate. And by code I mean the
> actual .java page that would (hopefully) power the .tml.
>
> The problem I have is that I need to (obviously) render content in a
> specific way, but the application I am writing needs to load the templates
> dynamically.
>
> Thanks,
> David.
>
> On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <[hidden email]>
> wrote:
>
>> Hi David!
>>
>> What do you mean by "external code"? Are you talking about external
>> Tapestry pages/components and tml's you need to integrate? Because you
>> mentiond HTML not TML? Does "code" refer to Javascript? Is the external
>> code self contained? What about an ugly but simple "iframe"?
>>
>> Jens
>>
>>
>> Von meinem iPhone gesendet
>>
>>> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
>>>
>>> Hi all,
>>>
>>> I have been using Tapestry for a little bit now and I have run into one
>>> problem that I can't figure out how to solve.
>>>
>>> In my application I need to be able to load external code & HTML to
>> display
>>> to the user from a trusted source at run-time. Currently I have gotten
>> code
>>> to load fine and I am using outputraw to render the result from the code.
>>> This is pretty bad though since I have to code the HTML within the Java
>>> file instead of having it templated.
>>>
>>> I saw that Tapestry has a "Dynamic" component that allows loading
>> templates
>>> from an external source but I tried using it - it tries loading a file
>> from
>>> the file system at page creation time... this is not suitable for my use
>>> case since I need to load it from a String and I need to do it at render
>>> time.
>>>
>>> I also tried messing around with DynamicTemplateParser & MarkupWriter
>> but I
>>> couldn't get it to bind to my properties/functions since the code is
>> loaded
>>> at runtime and is not defined at compile time (I would hit a NPE when the
>>> PropBindingFactory would try and locate the component).
>>>
>>> If anyone could suggest any way of accomplishing this (or if it's futile
>>> and I'm wasting my time), it would be really appreciated.
>>>
>>> Thanks,
>>> David.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

David Diaz
Hi all,

Thanks for the replies! I checked out your link Barry - it doesn't seem to
be exactly what I want. (I'll explain later in the reply... I'm still new
to mailing lists).

Thiago & Jens:
How I'm doing fetching-code-outside is someone writes a .java file that
implements an interface. Say it has function a, b and c they have to
implement. They then compile this into a class, put it into a program and
link it to the set of data they want to render. Then, when using the web
interface the application will detect when its loading the set of data and
load it into its own class (not overwriting), create a new instance and
then use functions a, b and c to render the data into the webpage. This is
already working - but currently how it is done is that the user has to
hardcode their HTML into the .class file and do things like \"<div>" +
escapeHTML(data) + "</div>";\ instead of it having a template system where
they could go <div>${data}</div> and then the application would use the
tapestry template/component system.

An example usage for this would be, for example, a library that wants to
digitize its pages and then have it available online to be viewed through
the application. The library could store the files in an XML format like
so: http://da.viddiaz.com/example.xml and then use the following
hypothetical code and .tml to render it: http://da.viddiaz.com/code.txt
http://da.viddiaz.com/code.tml

Then this library could have different sets of data that wouldn't match
this exact set of data - it might have sets of emails (so then you could
write an email renderer), MARC data and so on. These examples are basic -
in the real world the data is a lot more complex! I hope this makes a bit
more sense why I would need to take this approach.

In regards to the Dynamic component, I must have messed up using it. Still
though, the problem would be getting it linked up to the .class file that
is loaded so that the user could then use tapestry in there (otherwise the
ComponentResources would be the .tml file that loaded it, not the
dynamically loaded one).

The stack trace I was getting is here, although I don't think it's really
useful: http://da.viddiaz.com/stacktrace.txt

Thanks,
David.

On Tue, Mar 1, 2016 at 9:09 AM, [hidden email] <[hidden email]>
wrote:

> I see. So a tapestry TML without a JAVA class is not considerably dynamic
> as it has no business logic at all. Either your 3rd party delivers
> TML+CLASS (only components from my point of view) than you can integrate it
> as module. But this is far away from "dynamic". If you provide the logic,
> the TML can not change anything nor add something new, so its about
> rearanging HTML or changing the style, but this is not what you want
> either, right? Because this might be a pure CSS related topic.
>
> Can you give us a real piece of code you get from your 3rd party for
> integration? Maybe it's really an iframe, an external template engine (to
> render raw output) or something completely different like angular...
> I am still confused about the requirements...
>
> Sorry
>
> Jens
>
> Von meinem iPhone gesendet
>
> > Am 29.02.2016 um 09:05 schrieb David Diaz <[hidden email]>:
> >
> > Hi Jens,
> >
> > Yes I have external pages that I need to integrate. And by code I mean
> the
> > actual .java page that would (hopefully) power the .tml.
> >
> > The problem I have is that I need to (obviously) render content in a
> > specific way, but the application I am writing needs to load the
> templates
> > dynamically.
> >
> > Thanks,
> > David.
> >
> > On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <
> [hidden email]>
> > wrote:
> >
> >> Hi David!
> >>
> >> What do you mean by "external code"? Are you talking about external
> >> Tapestry pages/components and tml's you need to integrate? Because you
> >> mentiond HTML not TML? Does "code" refer to Javascript? Is the external
> >> code self contained? What about an ugly but simple "iframe"?
> >>
> >> Jens
> >>
> >>
> >> Von meinem iPhone gesendet
> >>
> >>> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
> >>>
> >>> Hi all,
> >>>
> >>> I have been using Tapestry for a little bit now and I have run into one
> >>> problem that I can't figure out how to solve.
> >>>
> >>> In my application I need to be able to load external code & HTML to
> >> display
> >>> to the user from a trusted source at run-time. Currently I have gotten
> >> code
> >>> to load fine and I am using outputraw to render the result from the
> code.
> >>> This is pretty bad though since I have to code the HTML within the Java
> >>> file instead of having it templated.
> >>>
> >>> I saw that Tapestry has a "Dynamic" component that allows loading
> >> templates
> >>> from an external source but I tried using it - it tries loading a file
> >> from
> >>> the file system at page creation time... this is not suitable for my
> use
> >>> case since I need to load it from a String and I need to do it at
> render
> >>> time.
> >>>
> >>> I also tried messing around with DynamicTemplateParser & MarkupWriter
> >> but I
> >>> couldn't get it to bind to my properties/functions since the code is
> >> loaded
> >>> at runtime and is not defined at compile time (I would hit a NPE when
> the
> >>> PropBindingFactory would try and locate the component).
> >>>
> >>> If anyone could suggest any way of accomplishing this (or if it's
> futile
> >>> and I'm wasting my time), it would be really appreciated.
> >>>
> >>> Thanks,
> >>> David.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

David Diaz
In reply to this post by Thiago H de Paula Figueiredo
Hi Thiago,

I checked out Freemarker - that seems exactly like what I wanted! It would
be better if I could just use tapestry directly but this works just fine as
well.

Thanks,
David.
Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Jens Breitenstein
In reply to this post by David Diaz
Hi David!

Thanks for the explanation. Unfortunately I doubt your approach is the way to go. You are forcing all your users to get familiar with Tapestry, so they are all really aware of software development, java, Testing, the dev pipeline and everything? Who makes sure the tml and fictious jave class works smoothly together?

I believe either they have to provide valid static html (no dynamic part, but renderable by tapestry via outputraw). Or you provide base classes and tmls and they send back derived version (tml / java inheritance, see T5 website), but again there must be some awareness for software dev and the toolchain, which is not worth the effort as you still need to know all dynamic parts in advance.

What about accepting e.g  xml / json and render the data in a generic way on your side? Based an certain elements or attributes you should be able even to render complex layouts and your users only need to know which elements/attributes you support? Yes I know this sounds like the early 80ies jsp tag libs or good old xml-dynamic-swing-ui systems-frameworks.

Jens

Von meinem iPhone gesendet

> Am 01.03.2016 um 00:03 schrieb David Diaz <[hidden email]>:
>
> Hi all,
>
> Thanks for the replies! I checked out your link Barry - it doesn't seem to
> be exactly what I want. (I'll explain later in the reply... I'm still new
> to mailing lists).
>
> Thiago & Jens:
> How I'm doing fetching-code-outside is someone writes a .java file that
> implements an interface. Say it has function a, b and c they have to
> implement. They then compile this into a class, put it into a program and
> link it to the set of data they want to render. Then, when using the web
> interface the application will detect when its loading the set of data and
> load it into its own class (not overwriting), create a new instance and
> then use functions a, b and c to render the data into the webpage. This is
> already working - but currently how it is done is that the user has to
> hardcode their HTML into the .class file and do things like \"<div>" +
> escapeHTML(data) + "</div>";\ instead of it having a template system where
> they could go <div>${data}</div> and then the application would use the
> tapestry template/component system.
>
> An example usage for this would be, for example, a library that wants to
> digitize its pages and then have it available online to be viewed through
> the application. The library could store the files in an XML format like
> so: http://da.viddiaz.com/example.xml and then use the following
> hypothetical code and .tml to render it: http://da.viddiaz.com/code.txt
> http://da.viddiaz.com/code.tml
>
> Then this library could have different sets of data that wouldn't match
> this exact set of data - it might have sets of emails (so then you could
> write an email renderer), MARC data and so on. These examples are basic -
> in the real world the data is a lot more complex! I hope this makes a bit
> more sense why I would need to take this approach.
>
> In regards to the Dynamic component, I must have messed up using it. Still
> though, the problem would be getting it linked up to the .class file that
> is loaded so that the user could then use tapestry in there (otherwise the
> ComponentResources would be the .tml file that loaded it, not the
> dynamically loaded one).
>
> The stack trace I was getting is here, although I don't think it's really
> useful: http://da.viddiaz.com/stacktrace.txt
>
> Thanks,
> David.
>
> On Tue, Mar 1, 2016 at 9:09 AM, [hidden email] <[hidden email]>
> wrote:
>
>> I see. So a tapestry TML without a JAVA class is not considerably dynamic
>> as it has no business logic at all. Either your 3rd party delivers
>> TML+CLASS (only components from my point of view) than you can integrate it
>> as module. But this is far away from "dynamic". If you provide the logic,
>> the TML can not change anything nor add something new, so its about
>> rearanging HTML or changing the style, but this is not what you want
>> either, right? Because this might be a pure CSS related topic.
>>
>> Can you give us a real piece of code you get from your 3rd party for
>> integration? Maybe it's really an iframe, an external template engine (to
>> render raw output) or something completely different like angular...
>> I am still confused about the requirements...
>>
>> Sorry
>>
>> Jens
>>
>> Von meinem iPhone gesendet
>>
>>> Am 29.02.2016 um 09:05 schrieb David Diaz <[hidden email]>:
>>>
>>> Hi Jens,
>>>
>>> Yes I have external pages that I need to integrate. And by code I mean
>> the
>>> actual .java page that would (hopefully) power the .tml.
>>>
>>> The problem I have is that I need to (obviously) render content in a
>>> specific way, but the application I am writing needs to load the
>> templates
>>> dynamically.
>>>
>>> Thanks,
>>> David.
>>>
>>> On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <
>> [hidden email]>
>>> wrote:
>>>
>>>> Hi David!
>>>>
>>>> What do you mean by "external code"? Are you talking about external
>>>> Tapestry pages/components and tml's you need to integrate? Because you
>>>> mentiond HTML not TML? Does "code" refer to Javascript? Is the external
>>>> code self contained? What about an ugly but simple "iframe"?
>>>>
>>>> Jens
>>>>
>>>>
>>>> Von meinem iPhone gesendet
>>>>
>>>>> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> I have been using Tapestry for a little bit now and I have run into one
>>>>> problem that I can't figure out how to solve.
>>>>>
>>>>> In my application I need to be able to load external code & HTML to
>>>> display
>>>>> to the user from a trusted source at run-time. Currently I have gotten
>>>> code
>>>>> to load fine and I am using outputraw to render the result from the
>> code.
>>>>> This is pretty bad though since I have to code the HTML within the Java
>>>>> file instead of having it templated.
>>>>>
>>>>> I saw that Tapestry has a "Dynamic" component that allows loading
>>>> templates
>>>>> from an external source but I tried using it - it tries loading a file
>>>> from
>>>>> the file system at page creation time... this is not suitable for my
>> use
>>>>> case since I need to load it from a String and I need to do it at
>> render
>>>>> time.
>>>>>
>>>>> I also tried messing around with DynamicTemplateParser & MarkupWriter
>>>> but I
>>>>> couldn't get it to bind to my properties/functions since the code is
>>>> loaded
>>>>> at runtime and is not defined at compile time (I would hit a NPE when
>> the
>>>>> PropBindingFactory would try and locate the component).
>>>>>
>>>>> If anyone could suggest any way of accomplishing this (or if it's
>> futile
>>>>> and I'm wasting my time), it would be really appreciated.
>>>>>
>>>>> Thanks,
>>>>> David.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

David Diaz
Hi Jens,

Yes, not all users will have software development backgrounds (of course).
However, our users will not be the ones developing these renderer
classes/templates, and thus it's fine if doing this requires some SDLC and
Tapestry knowledge. I know it sounds a bit outlandish, but requirements are
requirements.

It would be nice we could get our users to give us standardized data sets
that matched the same data each time, but it's just not realistic in this
case.

Thiago's suggestion of Freemarker seems like it can do the job for me just
fine, and although having two templating systems isn't ideal, it's a lot
better than the current system that is in place.

Thanks,
David.

On Tue, Mar 1, 2016 at 12:05 PM, [hidden email] <[hidden email]>
wrote:

> Hi David!
>
> Thanks for the explanation. Unfortunately I doubt your approach is the way
> to go. You are forcing all your users to get familiar with Tapestry, so
> they are all really aware of software development, java, Testing, the dev
> pipeline and everything? Who makes sure the tml and fictious jave class
> works smoothly together?
>
> I believe either they have to provide valid static html (no dynamic part,
> but renderable by tapestry via outputraw). Or you provide base classes and
> tmls and they send back derived version (tml / java inheritance, see T5
> website), but again there must be some awareness for software dev and the
> toolchain, which is not worth the effort as you still need to know all
> dynamic parts in advance.
>
> What about accepting e.g  xml / json and render the data in a generic way
> on your side? Based an certain elements or attributes you should be able
> even to render complex layouts and your users only need to know which
> elements/attributes you support? Yes I know this sounds like the early
> 80ies jsp tag libs or good old xml-dynamic-swing-ui systems-frameworks.
>
> Jens
>
> Von meinem iPhone gesendet
>
> > Am 01.03.2016 um 00:03 schrieb David Diaz <[hidden email]>:
> >
> > Hi all,
> >
> > Thanks for the replies! I checked out your link Barry - it doesn't seem
> to
> > be exactly what I want. (I'll explain later in the reply... I'm still new
> > to mailing lists).
> >
> > Thiago & Jens:
> > How I'm doing fetching-code-outside is someone writes a .java file that
> > implements an interface. Say it has function a, b and c they have to
> > implement. They then compile this into a class, put it into a program and
> > link it to the set of data they want to render. Then, when using the web
> > interface the application will detect when its loading the set of data
> and
> > load it into its own class (not overwriting), create a new instance and
> > then use functions a, b and c to render the data into the webpage. This
> is
> > already working - but currently how it is done is that the user has to
> > hardcode their HTML into the .class file and do things like \"<div>" +
> > escapeHTML(data) + "</div>";\ instead of it having a template system
> where
> > they could go <div>${data}</div> and then the application would use the
> > tapestry template/component system.
> >
> > An example usage for this would be, for example, a library that wants to
> > digitize its pages and then have it available online to be viewed through
> > the application. The library could store the files in an XML format like
> > so: http://da.viddiaz.com/example.xml and then use the following
> > hypothetical code and .tml to render it: http://da.viddiaz.com/code.txt
> > http://da.viddiaz.com/code.tml
> >
> > Then this library could have different sets of data that wouldn't match
> > this exact set of data - it might have sets of emails (so then you could
> > write an email renderer), MARC data and so on. These examples are basic -
> > in the real world the data is a lot more complex! I hope this makes a bit
> > more sense why I would need to take this approach.
> >
> > In regards to the Dynamic component, I must have messed up using it.
> Still
> > though, the problem would be getting it linked up to the .class file that
> > is loaded so that the user could then use tapestry in there (otherwise
> the
> > ComponentResources would be the .tml file that loaded it, not the
> > dynamically loaded one).
> >
> > The stack trace I was getting is here, although I don't think it's really
> > useful: http://da.viddiaz.com/stacktrace.txt
> >
> > Thanks,
> > David.
> >
> > On Tue, Mar 1, 2016 at 9:09 AM, [hidden email] <
> [hidden email]>
> > wrote:
> >
> >> I see. So a tapestry TML without a JAVA class is not considerably
> dynamic
> >> as it has no business logic at all. Either your 3rd party delivers
> >> TML+CLASS (only components from my point of view) than you can
> integrate it
> >> as module. But this is far away from "dynamic". If you provide the
> logic,
> >> the TML can not change anything nor add something new, so its about
> >> rearanging HTML or changing the style, but this is not what you want
> >> either, right? Because this might be a pure CSS related topic.
> >>
> >> Can you give us a real piece of code you get from your 3rd party for
> >> integration? Maybe it's really an iframe, an external template engine
> (to
> >> render raw output) or something completely different like angular...
> >> I am still confused about the requirements...
> >>
> >> Sorry
> >>
> >> Jens
> >>
> >> Von meinem iPhone gesendet
> >>
> >>> Am 29.02.2016 um 09:05 schrieb David Diaz <[hidden email]>:
> >>>
> >>> Hi Jens,
> >>>
> >>> Yes I have external pages that I need to integrate. And by code I mean
> >> the
> >>> actual .java page that would (hopefully) power the .tml.
> >>>
> >>> The problem I have is that I need to (obviously) render content in a
> >>> specific way, but the application I am writing needs to load the
> >> templates
> >>> dynamically.
> >>>
> >>> Thanks,
> >>> David.
> >>>
> >>> On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <
> >> [hidden email]>
> >>> wrote:
> >>>
> >>>> Hi David!
> >>>>
> >>>> What do you mean by "external code"? Are you talking about external
> >>>> Tapestry pages/components and tml's you need to integrate? Because you
> >>>> mentiond HTML not TML? Does "code" refer to Javascript? Is the
> external
> >>>> code self contained? What about an ugly but simple "iframe"?
> >>>>
> >>>> Jens
> >>>>
> >>>>
> >>>> Von meinem iPhone gesendet
> >>>>
> >>>>> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
> >>>>>
> >>>>> Hi all,
> >>>>>
> >>>>> I have been using Tapestry for a little bit now and I have run into
> one
> >>>>> problem that I can't figure out how to solve.
> >>>>>
> >>>>> In my application I need to be able to load external code & HTML to
> >>>> display
> >>>>> to the user from a trusted source at run-time. Currently I have
> gotten
> >>>> code
> >>>>> to load fine and I am using outputraw to render the result from the
> >> code.
> >>>>> This is pretty bad though since I have to code the HTML within the
> Java
> >>>>> file instead of having it templated.
> >>>>>
> >>>>> I saw that Tapestry has a "Dynamic" component that allows loading
> >>>> templates
> >>>>> from an external source but I tried using it - it tries loading a
> file
> >>>> from
> >>>>> the file system at page creation time... this is not suitable for my
> >> use
> >>>>> case since I need to load it from a String and I need to do it at
> >> render
> >>>>> time.
> >>>>>
> >>>>> I also tried messing around with DynamicTemplateParser & MarkupWriter
> >>>> but I
> >>>>> couldn't get it to bind to my properties/functions since the code is
> >>>> loaded
> >>>>> at runtime and is not defined at compile time (I would hit a NPE when
> >> the
> >>>>> PropBindingFactory would try and locate the component).
> >>>>>
> >>>>> If anyone could suggest any way of accomplishing this (or if it's
> >> futile
> >>>>> and I'm wasting my time), it would be really appreciated.
> >>>>>
> >>>>> Thanks,
> >>>>> David.
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [hidden email]
> >>>> For additional commands, e-mail: [hidden email]
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Andreas Fink
Hi David.

If you like the style of templating Tapestry offers i can only recommend using the Thymeleaf template engine over Freemarker.
http://www.thymeleaf.org/

>> early 80ies jsp tag libs

Haha, not bad :-)

Cheers,
Andi.


On 01 Mar 2016, at 2:25 , David Diaz <[hidden email]> wrote:

> Hi Jens,
>
> Yes, not all users will have software development backgrounds (of course).
> However, our users will not be the ones developing these renderer
> classes/templates, and thus it's fine if doing this requires some SDLC and
> Tapestry knowledge. I know it sounds a bit outlandish, but requirements are
> requirements.
>
> It would be nice we could get our users to give us standardized data sets
> that matched the same data each time, but it's just not realistic in this
> case.
>
> Thiago's suggestion of Freemarker seems like it can do the job for me just
> fine, and although having two templating systems isn't ideal, it's a lot
> better than the current system that is in place.
>
> Thanks,
> David.
>
> On Tue, Mar 1, 2016 at 12:05 PM, [hidden email] <[hidden email]>
> wrote:
>
>> Hi David!
>>
>> Thanks for the explanation. Unfortunately I doubt your approach is the way
>> to go. You are forcing all your users to get familiar with Tapestry, so
>> they are all really aware of software development, java, Testing, the dev
>> pipeline and everything? Who makes sure the tml and fictious jave class
>> works smoothly together?
>>
>> I believe either they have to provide valid static html (no dynamic part,
>> but renderable by tapestry via outputraw). Or you provide base classes and
>> tmls and they send back derived version (tml / java inheritance, see T5
>> website), but again there must be some awareness for software dev and the
>> toolchain, which is not worth the effort as you still need to know all
>> dynamic parts in advance.
>>
>> What about accepting e.g  xml / json and render the data in a generic way
>> on your side? Based an certain elements or attributes you should be able
>> even to render complex layouts and your users only need to know which
>> elements/attributes you support? Yes I know this sounds like the early
>> 80ies jsp tag libs or good old xml-dynamic-swing-ui systems-frameworks.
>>
>> Jens
>>
>> Von meinem iPhone gesendet
>>
>>> Am 01.03.2016 um 00:03 schrieb David Diaz <[hidden email]>:
>>>
>>> Hi all,
>>>
>>> Thanks for the replies! I checked out your link Barry - it doesn't seem
>> to
>>> be exactly what I want. (I'll explain later in the reply... I'm still new
>>> to mailing lists).
>>>
>>> Thiago & Jens:
>>> How I'm doing fetching-code-outside is someone writes a .java file that
>>> implements an interface. Say it has function a, b and c they have to
>>> implement. They then compile this into a class, put it into a program and
>>> link it to the set of data they want to render. Then, when using the web
>>> interface the application will detect when its loading the set of data
>> and
>>> load it into its own class (not overwriting), create a new instance and
>>> then use functions a, b and c to render the data into the webpage. This
>> is
>>> already working - but currently how it is done is that the user has to
>>> hardcode their HTML into the .class file and do things like \"<div>" +
>>> escapeHTML(data) + "</div>";\ instead of it having a template system
>> where
>>> they could go <div>${data}</div> and then the application would use the
>>> tapestry template/component system.
>>>
>>> An example usage for this would be, for example, a library that wants to
>>> digitize its pages and then have it available online to be viewed through
>>> the application. The library could store the files in an XML format like
>>> so: http://da.viddiaz.com/example.xml and then use the following
>>> hypothetical code and .tml to render it: http://da.viddiaz.com/code.txt
>>> http://da.viddiaz.com/code.tml
>>>
>>> Then this library could have different sets of data that wouldn't match
>>> this exact set of data - it might have sets of emails (so then you could
>>> write an email renderer), MARC data and so on. These examples are basic -
>>> in the real world the data is a lot more complex! I hope this makes a bit
>>> more sense why I would need to take this approach.
>>>
>>> In regards to the Dynamic component, I must have messed up using it.
>> Still
>>> though, the problem would be getting it linked up to the .class file that
>>> is loaded so that the user could then use tapestry in there (otherwise
>> the
>>> ComponentResources would be the .tml file that loaded it, not the
>>> dynamically loaded one).
>>>
>>> The stack trace I was getting is here, although I don't think it's really
>>> useful: http://da.viddiaz.com/stacktrace.txt
>>>
>>> Thanks,
>>> David.
>>>
>>> On Tue, Mar 1, 2016 at 9:09 AM, [hidden email] <
>> [hidden email]>
>>> wrote:
>>>
>>>> I see. So a tapestry TML without a JAVA class is not considerably
>> dynamic
>>>> as it has no business logic at all. Either your 3rd party delivers
>>>> TML+CLASS (only components from my point of view) than you can
>> integrate it
>>>> as module. But this is far away from "dynamic". If you provide the
>> logic,
>>>> the TML can not change anything nor add something new, so its about
>>>> rearanging HTML or changing the style, but this is not what you want
>>>> either, right? Because this might be a pure CSS related topic.
>>>>
>>>> Can you give us a real piece of code you get from your 3rd party for
>>>> integration? Maybe it's really an iframe, an external template engine
>> (to
>>>> render raw output) or something completely different like angular...
>>>> I am still confused about the requirements...
>>>>
>>>> Sorry
>>>>
>>>> Jens
>>>>
>>>> Von meinem iPhone gesendet
>>>>
>>>>> Am 29.02.2016 um 09:05 schrieb David Diaz <[hidden email]>:
>>>>>
>>>>> Hi Jens,
>>>>>
>>>>> Yes I have external pages that I need to integrate. And by code I mean
>>>> the
>>>>> actual .java page that would (hopefully) power the .tml.
>>>>>
>>>>> The problem I have is that I need to (obviously) render content in a
>>>>> specific way, but the application I am writing needs to load the
>>>> templates
>>>>> dynamically.
>>>>>
>>>>> Thanks,
>>>>> David.
>>>>>
>>>>> On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <
>>>> [hidden email]>
>>>>> wrote:
>>>>>
>>>>>> Hi David!
>>>>>>
>>>>>> What do you mean by "external code"? Are you talking about external
>>>>>> Tapestry pages/components and tml's you need to integrate? Because you
>>>>>> mentiond HTML not TML? Does "code" refer to Javascript? Is the
>> external
>>>>>> code self contained? What about an ugly but simple "iframe"?
>>>>>>
>>>>>> Jens
>>>>>>
>>>>>>
>>>>>> Von meinem iPhone gesendet
>>>>>>
>>>>>>> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
>>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I have been using Tapestry for a little bit now and I have run into
>> one
>>>>>>> problem that I can't figure out how to solve.
>>>>>>>
>>>>>>> In my application I need to be able to load external code & HTML to
>>>>>> display
>>>>>>> to the user from a trusted source at run-time. Currently I have
>> gotten
>>>>>> code
>>>>>>> to load fine and I am using outputraw to render the result from the
>>>> code.
>>>>>>> This is pretty bad though since I have to code the HTML within the
>> Java
>>>>>>> file instead of having it templated.
>>>>>>>
>>>>>>> I saw that Tapestry has a "Dynamic" component that allows loading
>>>>>> templates
>>>>>>> from an external source but I tried using it - it tries loading a
>> file
>>>>>> from
>>>>>>> the file system at page creation time... this is not suitable for my
>>>> use
>>>>>>> case since I need to load it from a String and I need to do it at
>>>> render
>>>>>>> time.
>>>>>>>
>>>>>>> I also tried messing around with DynamicTemplateParser & MarkupWriter
>>>>>> but I
>>>>>>> couldn't get it to bind to my properties/functions since the code is
>>>>>> loaded
>>>>>>> at runtime and is not defined at compile time (I would hit a NPE when
>>>> the
>>>>>>> PropBindingFactory would try and locate the component).
>>>>>>>
>>>>>>> If anyone could suggest any way of accomplishing this (or if it's
>>>> futile
>>>>>>> and I'm wasting my time), it would be really appreciated.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> David.
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Jens Breitenstein
In reply to this post by David Diaz
Well, Freemarker, Velocity. Tapestry Offline all require some dev knowledge. And I did not say you give your users a standard dataset, I said give them a standard way to describe it like json or xml. Thus transformation is like:

array --> T5 loop (table, ol, ul)
elements --> div's or whatever
attributes --> maybe bootstrap col serrings aso

There are even json to html form conversion tools which do a great job like jeremydorn.com/json-editor

Jens

But if freemarker solves it: fine!

Jens

Von meinem iPhone gesendet

> Am 01.03.2016 um 02:25 schrieb David Diaz <[hidden email]>:
>
> Hi Jens,
>
> Yes, not all users will have software development backgrounds (of course).
> However, our users will not be the ones developing these renderer
> classes/templates, and thus it's fine if doing this requires some SDLC and
> Tapestry knowledge. I know it sounds a bit outlandish, but requirements are
> requirements.
>
> It would be nice we could get our users to give us standardized data sets
> that matched the same data each time, but it's just not realistic in this
> case.
>
> Thiago's suggestion of Freemarker seems like it can do the job for me just
> fine, and although having two templating systems isn't ideal, it's a lot
> better than the current system that is in place.
>
> Thanks,
> David.
>
> On Tue, Mar 1, 2016 at 12:05 PM, [hidden email] <[hidden email]>
> wrote:
>
>> Hi David!
>>
>> Thanks for the explanation. Unfortunately I doubt your approach is the way
>> to go. You are forcing all your users to get familiar with Tapestry, so
>> they are all really aware of software development, java, Testing, the dev
>> pipeline and everything? Who makes sure the tml and fictious jave class
>> works smoothly together?
>>
>> I believe either they have to provide valid static html (no dynamic part,
>> but renderable by tapestry via outputraw). Or you provide base classes and
>> tmls and they send back derived version (tml / java inheritance, see T5
>> website), but again there must be some awareness for software dev and the
>> toolchain, which is not worth the effort as you still need to know all
>> dynamic parts in advance.
>>
>> What about accepting e.g  xml / json and render the data in a generic way
>> on your side? Based an certain elements or attributes you should be able
>> even to render complex layouts and your users only need to know which
>> elements/attributes you support? Yes I know this sounds like the early
>> 80ies jsp tag libs or good old xml-dynamic-swing-ui systems-frameworks.
>>
>> Jens
>>
>> Von meinem iPhone gesendet
>>
>>> Am 01.03.2016 um 00:03 schrieb David Diaz <[hidden email]>:
>>>
>>> Hi all,
>>>
>>> Thanks for the replies! I checked out your link Barry - it doesn't seem
>> to
>>> be exactly what I want. (I'll explain later in the reply... I'm still new
>>> to mailing lists).
>>>
>>> Thiago & Jens:
>>> How I'm doing fetching-code-outside is someone writes a .java file that
>>> implements an interface. Say it has function a, b and c they have to
>>> implement. They then compile this into a class, put it into a program and
>>> link it to the set of data they want to render. Then, when using the web
>>> interface the application will detect when its loading the set of data
>> and
>>> load it into its own class (not overwriting), create a new instance and
>>> then use functions a, b and c to render the data into the webpage. This
>> is
>>> already working - but currently how it is done is that the user has to
>>> hardcode their HTML into the .class file and do things like \"<div>" +
>>> escapeHTML(data) + "</div>";\ instead of it having a template system
>> where
>>> they could go <div>${data}</div> and then the application would use the
>>> tapestry template/component system.
>>>
>>> An example usage for this would be, for example, a library that wants to
>>> digitize its pages and then have it available online to be viewed through
>>> the application. The library could store the files in an XML format like
>>> so: http://da.viddiaz.com/example.xml and then use the following
>>> hypothetical code and .tml to render it: http://da.viddiaz.com/code.txt
>>> http://da.viddiaz.com/code.tml
>>>
>>> Then this library could have different sets of data that wouldn't match
>>> this exact set of data - it might have sets of emails (so then you could
>>> write an email renderer), MARC data and so on. These examples are basic -
>>> in the real world the data is a lot more complex! I hope this makes a bit
>>> more sense why I would need to take this approach.
>>>
>>> In regards to the Dynamic component, I must have messed up using it.
>> Still
>>> though, the problem would be getting it linked up to the .class file that
>>> is loaded so that the user could then use tapestry in there (otherwise
>> the
>>> ComponentResources would be the .tml file that loaded it, not the
>>> dynamically loaded one).
>>>
>>> The stack trace I was getting is here, although I don't think it's really
>>> useful: http://da.viddiaz.com/stacktrace.txt
>>>
>>> Thanks,
>>> David.
>>>
>>> On Tue, Mar 1, 2016 at 9:09 AM, [hidden email] <
>> [hidden email]>
>>> wrote:
>>>
>>>> I see. So a tapestry TML without a JAVA class is not considerably
>> dynamic
>>>> as it has no business logic at all. Either your 3rd party delivers
>>>> TML+CLASS (only components from my point of view) than you can
>> integrate it
>>>> as module. But this is far away from "dynamic". If you provide the
>> logic,
>>>> the TML can not change anything nor add something new, so its about
>>>> rearanging HTML or changing the style, but this is not what you want
>>>> either, right? Because this might be a pure CSS related topic.
>>>>
>>>> Can you give us a real piece of code you get from your 3rd party for
>>>> integration? Maybe it's really an iframe, an external template engine
>> (to
>>>> render raw output) or something completely different like angular...
>>>> I am still confused about the requirements...
>>>>
>>>> Sorry
>>>>
>>>> Jens
>>>>
>>>> Von meinem iPhone gesendet
>>>>
>>>>> Am 29.02.2016 um 09:05 schrieb David Diaz <[hidden email]>:
>>>>>
>>>>> Hi Jens,
>>>>>
>>>>> Yes I have external pages that I need to integrate. And by code I mean
>>>> the
>>>>> actual .java page that would (hopefully) power the .tml.
>>>>>
>>>>> The problem I have is that I need to (obviously) render content in a
>>>>> specific way, but the application I am writing needs to load the
>>>> templates
>>>>> dynamically.
>>>>>
>>>>> Thanks,
>>>>> David.
>>>>>
>>>>> On Mon, Feb 29, 2016 at 6:37 PM, [hidden email] <
>>>> [hidden email]>
>>>>> wrote:
>>>>>
>>>>>> Hi David!
>>>>>>
>>>>>> What do you mean by "external code"? Are you talking about external
>>>>>> Tapestry pages/components and tml's you need to integrate? Because you
>>>>>> mentiond HTML not TML? Does "code" refer to Javascript? Is the
>> external
>>>>>> code self contained? What about an ugly but simple "iframe"?
>>>>>>
>>>>>> Jens
>>>>>>
>>>>>>
>>>>>> Von meinem iPhone gesendet
>>>>>>
>>>>>>> Am 29.02.2016 um 05:18 schrieb David Diaz <[hidden email]>:
>>>>>>>
>>>>>>> Hi all,
>>>>>>>
>>>>>>> I have been using Tapestry for a little bit now and I have run into
>> one
>>>>>>> problem that I can't figure out how to solve.
>>>>>>>
>>>>>>> In my application I need to be able to load external code & HTML to
>>>>>> display
>>>>>>> to the user from a trusted source at run-time. Currently I have
>> gotten
>>>>>> code
>>>>>>> to load fine and I am using outputraw to render the result from the
>>>> code.
>>>>>>> This is pretty bad though since I have to code the HTML within the
>> Java
>>>>>>> file instead of having it templated.
>>>>>>>
>>>>>>> I saw that Tapestry has a "Dynamic" component that allows loading
>>>>>> templates
>>>>>>> from an external source but I tried using it - it tries loading a
>> file
>>>>>> from
>>>>>>> the file system at page creation time... this is not suitable for my
>>>> use
>>>>>>> case since I need to load it from a String and I need to do it at
>>>> render
>>>>>>> time.
>>>>>>>
>>>>>>> I also tried messing around with DynamicTemplateParser & MarkupWriter
>>>>>> but I
>>>>>>> couldn't get it to bind to my properties/functions since the code is
>>>>>> loaded
>>>>>>> at runtime and is not defined at compile time (I would hit a NPE when
>>>> the
>>>>>>> PropBindingFactory would try and locate the component).
>>>>>>>
>>>>>>> If anyone could suggest any way of accomplishing this (or if it's
>>>> futile
>>>>>>> and I'm wasting my time), it would be really appreciated.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> David.
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: [hidden email]
>>>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Thiago H de Paula Figueiredo
In reply to this post by David Diaz
On Mon, 29 Feb 2016 20:03:05 -0300, David Diaz <[hidden email]> wrote:

> Hi all,

Hi!

> Thiago & Jens:
> How I'm doing fetching-code-outside is someone writes a .java file that
> implements an interface. Say it has function a, b and c they have to
> implement. They then compile this into a class, put it into a program and
> link it to the set of data they want to render. Then, when using the web
> interface the application will detect when its loading the set of data  
> and load it into its own class (not overwriting), create a new instance  
> and
> then use functions a, b and c to render the data into the webpage. This  
> is
> already working - but currently how it is done is that the user has to
> hardcode their HTML into the .class file and do things like \"<div>" +
> escapeHTML(data) + "</div>";\ instead of it having a template system  
> where they could go <div>${data}</div> and then the application would  
> use the
> tapestry template/component system.

It's not a template, but you could pass this interface a MarkupWriter and  
then you just create HTML elements through its methods. Something like  
this, supposing your interface is called Renderer:

public interface Renderer {
        void render(MarkupWriter writer);
        ....
}

void setupRender(MarkupWriter writer) {
        Renderer renderer = ...;
        renderer.render(writer);
}

MarkupRenderer is exactly the interface used internally by Tapestry when  
rendering a template.

> In regards to the Dynamic component, I must have messed up using it.  
> Still though, the problem would be getting it linked up to the .class  
> file that
> is loaded so that the user could then use tapestry in there (otherwise  
> the ComponentResources would be the .tml file that loaded it, not the
> dynamically loaded one).

The template is tightly linked to its corresponding component or page  
class and that's where Tapestry looks for properties.

> The stack trace I was getting is here, although I don't think it's really
> useful: http://da.viddiaz.com/stacktrace.txt

Actually, it is. It's saying the page or component class related to your  
template doesn't have a 'header' property.

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Thiago H de Paula Figueiredo
In reply to this post by Jens Breitenstein
On Mon, 29 Feb 2016 22:05:09 -0300, [hidden email]  
<[hidden email]> wrote:

> Hi David!

Hi, guys!

> What about accepting e.g  xml / json and render the data in a generic  
> way on your side? Based an certain elements or attributes you should be  
> able even to render complex layouts and your users only need to know  
> which elements/attributes you support? Yes I know this sounds like the  
> early 80ies jsp tag libs or good old xml-dynamic-swing-ui  
> systems-frameworks.

My day job is a large Tapestry application which a very important part of  
it is rendering XML provided by clients into HTML. We even have a version  
of OutputRaw that parses the generated HTML and outputs Tapestry DOM  
elements so we can use DOM rewriting if needed. :)

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Loading templates at run-time in Tapestry 5.4

Thiago H de Paula Figueiredo
In reply to this post by David Diaz
On Mon, 29 Feb 2016 22:25:20 -0300, David Diaz <[hidden email]> wrote:

> Yes, not all users will have software development backgrounds (of  
> course). However, our users will not be the ones developing these  
> renderer
> classes/templates, and thus it's fine if doing this requires some SDLC  
> and Tapestry knowledge. I know it sounds a bit outlandish, but  
> requirements are requirements.

If you don't mind me giving an opinion, they're very weird requirements.  
If the logic and the data are provided by other serviers, why don't theses  
servers just do the templating part themselves and just deliver the final  
result? :)

> Thiago's suggestion of Freemarker seems like it can do the job for me  
> just fine, and although having two templating systems isn't ideal, it's  
> a lot
> better than the current system that is in place.

Still better than trying to make Tapestry's templating engine work in a  
way it was never intended. :)

--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]