组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Daniel Aschauer
Variables and methods in web content
2012年10月29日 上午1:09
答复

Daniel Aschauer

等级: Junior Member

帖子: 39

加入日期: 2012年10月22日

最近的帖子

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
2012年10月29日 上午1:24
答复

Pavel Savinov

等级: Junior Member

帖子: 97

加入日期: 2012年9月24日

最近的帖子

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
2012年10月29日 上午2:00
答复

Daniel Aschauer

等级: Junior Member

帖子: 39

加入日期: 2012年10月22日

最近的帖子

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
2012年10月29日 上午2:20
答复

Gaurav Jain

等级: Regular Member

帖子: 141

加入日期: 2011年1月31日

最近的帖子

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
2012年11月23日 上午5:15
答复

Daniel Aschauer

等级: Junior Member

帖子: 39

加入日期: 2012年10月22日

最近的帖子

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
2012年11月23日 上午8:46
答复

Pavel Savinov

等级: Junior Member

帖子: 97

加入日期: 2012年9月24日

最近的帖子

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
2012年11月26日 上午3:09
答复

Daniel Aschauer

等级: Junior Member

帖子: 39

加入日期: 2012年10月22日

最近的帖子

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/