Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Daniel Aschauer
Variables and methods in web content
29. Oktober 2012 01:09
Antwort

Daniel Aschauer

Rang: Junior Member

Nachrichten: 39

Eintrittsdatum: 22. Oktober 2012

Neue Beiträge

Hi!
I recently started evaluation liferay for the use in larger portal project, gone through the documentation, clicked around in the cms and did some portlet development tutorials.
Still I have some principle question on usage of the cms:
In some occasions I would need to include some dynamic content in a created web content, e.g. I need to call a method for currency convertion, get values from the database to include in the content.
Is there a possibility to do this?
Or to I have to write the content and functionality in a template?
Thanks,
Daniel
Pavel Savinov
RE: Variables and methods in web content
29. Oktober 2012 01:24
Antwort

Pavel Savinov

Rang: Junior Member

Nachrichten: 97

Eintrittsdatum: 24. September 2012

Neue Beiträge

Hi Daniel.

You can solve your task in 2 ways:

1) Use AJAX to call some remote service that will give you required info (exchange rates in your case)
2) Use Velocity to call some your local service that will provide the required info, like this:

1 #set ($currencyLocalService = $serviceLocator.findService("com.daniel.service.CurrencyLocalService"))
2 #set ($rate = $currencyLocalService.getExchangeRate(someDate, currencyAId, CurrencyBId))

And then use $rate variable.
Daniel Aschauer
RE: Variables and methods in web content
29. Oktober 2012 02:00
Antwort

Daniel Aschauer

Rang: Junior Member

Nachrichten: 39

Eintrittsdatum: 22. Oktober 2012

Neue Beiträge

Thanks.
Ok, that means this has to go to the template. To make it available to the editor I may use a PLACEHOLDER in the content and then replace it with the calculated value in the template?
I suppose I have access to request / session from the template to use user settings (language, role, and so on)..
Gaurav Jain
RE: Variables and methods in web content
29. Oktober 2012 02:20
Antwort

Gaurav Jain

Rang: Regular Member

Nachrichten: 146

Eintrittsdatum: 31. Januar 2011

Neue Beiträge

Daniel Aschauer:
Thanks.
Ok, that means this has to go to the template. To make it available to the editor I may use a PLACEHOLDER in the content and then replace it with the calculated value in the template?
I suppose I have access to request / session from the template to use user settings (language, role, and so on)..


Yes, web-content with structure/template is a kind of quite powerful tool in liferay that can be used for static/dynamic content.
However for security reasons request is not accesible as object in template but $request is in form of xmlRequest. [Refert o here]

You can check the liferay documentation on velocity objects here
Daniel Aschauer
RE: Variables and methods in web content
23. November 2012 05:15
Antwort

Daniel Aschauer

Rang: Junior Member

Nachrichten: 39

Eintrittsdatum: 22. Oktober 2012

Neue Beiträge

Hi again!
What is the best way to provide a service that is accessible from within the template. Has that to be implemented as ext-plugin? Or can they be implemented in a portlet-plugin?
Didn't find any good documentation on this issue.
Daniel
Pavel Savinov
RE: Variables and methods in web content
23. November 2012 08:46
Antwort

Pavel Savinov

Rang: Junior Member

Nachrichten: 97

Eintrittsdatum: 24. September 2012

Neue Beiträge

Hi Daniel.

It could be an ext-plugin (if you want to EXTend some existing Liferay portlet/service), a hook(if you want to override some functionality of Liferay service) or a plain portlet with service built with Service Builder.
The way depends only on your project's requirements.
Daniel Aschauer
RE: Variables and methods in web content
26. November 2012 03:09
Antwort

Daniel Aschauer

Rang: Junior Member

Nachrichten: 39

Eintrittsdatum: 22. Oktober 2012

Neue Beiträge

As far as I understood the service builder is mainly used for generating and providing services related to DAOs.
So I guess if it just want to provide any other service I would build a service with using service builder or ext, as described http://www.devatwork.nl/2010/04/implementing-a-reusable-liferay-service-without-ext-or-service-builder/