论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Abhi Ed
database call in navigation.vm
2012年7月17日 上午1:19
答复

Abhi Ed

等级: Regular Member

帖子: 118

加入日期: 2012年6月4日

最近的帖子

hello,
In my theme i have a requirement that one of the navigation links will contain the list that will be dynamically populated after querying the database.
Can we make a database call in navigation.vm ?
Muzakir Khan
RE: database call in navigation.vm
2012年7月17日 上午3:02
答复

Muzakir Khan

等级: Regular Member

帖子: 112

加入日期: 2012年3月14日

最近的帖子

Abhi Ed:
hello,

Can we make a database call in navigation.vm ?

Think so yes, we can make a database call in navigation.vm using javascript..

Regards
Khan
Abhi Ed
RE: database call in navigation.vm
2012年7月17日 上午3:05
答复

Abhi Ed

等级: Regular Member

帖子: 118

加入日期: 2012年6月4日

最近的帖子

Muzakir Khan:
Abhi Ed:
hello,

Can we make a database call in navigation.vm ?

Think so yes, we can make a database call in navigation.vm using javascript..

Regards
Khan


Thanks Muzakir, Can u explain how this call can be performed by any example which can clarify this?
Muzakir Khan
RE: database call in navigation.vm
2012年7月17日 上午3:14
答复

Muzakir Khan

等级: Regular Member

帖子: 112

加入日期: 2012年3月14日

最近的帖子

Abhi Ed:

Thanks Muzakir, Can u explain how this call can be performed by any example which can clarify this?


I am sorry, you have to include the javascript code(onclick) for calling the database in your portal_normal.vm of your theme..
You just google javascript code for the same, u will get it..
Abhi Ed
RE: database call in navigation.vm
2012年7月17日 上午3:52
答复

Abhi Ed

等级: Regular Member

帖子: 118

加入日期: 2012年6月4日

最近的帖子

Muzakir Khan:
Abhi Ed:

Thanks Muzakir, Can u explain how this call can be performed by any example which can clarify this?


I am sorry, you have to include the javascript code(onclick) for calling the database in your portal_normal.vm of your theme..
You just google javascript code for the same, u will get it..



I don't know, how practical ur solution is,Muzakir.However,thanks for ur time.

The question stands open yet.If anyone has done like this before,please share ur ideas.
Priyanka Dhingra
RE: database call in navigation.vm
2012年7月17日 上午8:23
答复

Priyanka Dhingra

等级: Liferay Master

帖子: 501

加入日期: 2011年12月19日

最近的帖子

Hi,
Please check the following link
https://www.liferay.com/community/forums/-/message_boards/message/10559868
I think editing the velocityvariable class will give you access to your database and then you can access the variable with a $ in your init-custom.vm
I didnt tried anyways but that can be a possible solution(an idea).
Aravinth Raj Raju
RE: database call in navigation.vm
2012年8月14日 上午3:30
答复

Aravinth Raj Raju

等级: New Member

帖子: 24

加入日期: 2011年10月3日

最近的帖子

Hi,

I too have similar requirement, to load menus after querying from a custom table.
Plz post your ideas.

Thanks,
Aravinth Raj R.
David H Nebinger
RE: database call in navigation.vm
2012年8月14日 上午6:09
答复

David H Nebinger

等级: Liferay Legend

帖子: 7152

加入日期: 2006年9月1日

最近的帖子

Abhi Ed:
Can we make a database call in navigation.vm ?


Yes, although you shouldn't do things this way.

Navigation.vm is a velocity script, and tweaking the velocity context to include necessary stuff to run the query would not be good.

Instead you should wrap the logic into a Spring bean. Register the bean in the portal's Spring context, then use $utilLocator.findUtil("my spring bean") to get access to the spring bean in navigation.vm, call the bean, and handle the results.