You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Daniel Kasmeroglu <da...@kasisoft.net> on 2014/11/15 14:43:34 UTC
Freemarker and CDI
Hi,
I intend to make my beans available in a Freemarker Template which means
that I have to implement a wrapper (TemplateHashModel) for this. Is
there already something similar like a bean wrapper that is capable to
deal with the proxied instance ?
To clarify a small example:
--begin Freemarker--
Dear Mr. ${currentCustomer.callName}
--end Freemarker
In my app I got a bean 'CurrentCustomer':
@Named @ManagedBean
@Data @FieldDefaults(PRIVATE)
public class CurrentCustomer {
String callName = "Joe";
...
} /* ENDCLASS */
In a Freemarker TemplateModel I can resolve 'currentCustomer' to a bean
(CdiEjbBean). Is there some sort of BeanWrapper available for this proxy
or is there any other solution to this ?
Best regards
Daniel Kasmeroglu
Re: Freemarker and CDI
Posted by Mark Struberg <st...@yahoo.de>.
+1 to what Romain said:
http://deltaspike.apache.org/documentation/core.html#_beanprovider
It works in JavaEE and also in SE.
LieGrue,
strub
> On Saturday, 15 November 2014, 19:52, Romain Manni-Bucau <rm...@tomitribe.com> wrote:
> > Ok got it.
>
> I'm not aware of an existing impl but using deltaspike BeanProvider it
> should be trivial to impl.
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
>
> 2014-11-15 16:37 GMT+01:00 Daniel Kasmeroglu
> <da...@kasisoft.net>:
>> Am 15.11.2014 um 16:18 schrieb Romain Manni-Bucau:
>>> Hi
>>>
>>> which issue do you get with the "proxy"? should work the same
> way a normal bean
>>>
>> Proxy was probably the wrong word. I've got a CdiEjbBean instance for
>> the bean. I could use injected instances (Proxies) instead but I wan't
>> this to be as generic as possible.
>> I'm basically getting the CdiEjbBean instance by name and I want to
>> invoke it's business functions (invoking them through the CdiEjbBean).
>> There may be better ways as I'm definitely not an expert on the
> internals.
>>
>>
>> Best regards
>>
>> Daniel Kasmeroglu
>>
>
Re: Freemarker and CDI
Posted by Romain Manni-Bucau <rm...@tomitribe.com>.
Ok got it.
I'm not aware of an existing impl but using deltaspike BeanProvider it
should be trivial to impl.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau
2014-11-15 16:37 GMT+01:00 Daniel Kasmeroglu <da...@kasisoft.net>:
> Am 15.11.2014 um 16:18 schrieb Romain Manni-Bucau:
>> Hi
>>
>> which issue do you get with the "proxy"? should work the same way a normal bean
>>
> Proxy was probably the wrong word. I've got a CdiEjbBean instance for
> the bean. I could use injected instances (Proxies) instead but I wan't
> this to be as generic as possible.
> I'm basically getting the CdiEjbBean instance by name and I want to
> invoke it's business functions (invoking them through the CdiEjbBean).
> There may be better ways as I'm definitely not an expert on the internals.
>
>
> Best regards
>
> Daniel Kasmeroglu
>
Re: Freemarker and CDI
Posted by Daniel Kasmeroglu <da...@kasisoft.net>.
Am 15.11.2014 um 16:18 schrieb Romain Manni-Bucau:
> Hi
>
> which issue do you get with the "proxy"? should work the same way a normal bean
>
Proxy was probably the wrong word. I've got a CdiEjbBean instance for
the bean. I could use injected instances (Proxies) instead but I wan't
this to be as generic as possible.
I'm basically getting the CdiEjbBean instance by name and I want to
invoke it's business functions (invoking them through the CdiEjbBean).
There may be better ways as I'm definitely not an expert on the internals.
Best regards
Daniel Kasmeroglu
Re: Freemarker and CDI
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
which issue do you get with the "proxy"? should work the same way a normal bean
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-11-15 14:43 GMT+01:00 Daniel Kasmeroglu <da...@kasisoft.net>:
> Hi,
>
> I intend to make my beans available in a Freemarker Template which means
> that I have to implement a wrapper (TemplateHashModel) for this. Is
> there already something similar like a bean wrapper that is capable to
> deal with the proxied instance ?
> To clarify a small example:
>
> --begin Freemarker--
> Dear Mr. ${currentCustomer.callName}
> --end Freemarker
>
> In my app I got a bean 'CurrentCustomer':
>
> @Named @ManagedBean
> @Data @FieldDefaults(PRIVATE)
> public class CurrentCustomer {
>
> String callName = "Joe";
>
> ...
>
> } /* ENDCLASS */
>
> In a Freemarker TemplateModel I can resolve 'currentCustomer' to a bean
> (CdiEjbBean). Is there some sort of BeanWrapper available for this proxy
> or is there any other solution to this ?
>
> Best regards
>
> Daniel Kasmeroglu