论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Karthik Baskaran
How to manage page links in navigation bar programatically
2012年5月3日 下午10:40
答复

Karthik Baskaran

等级: Junior Member

帖子: 32

加入日期: 2012年5月3日

最近的帖子

Hi,

When we add pages to the portal, these new pages get added next to "Welcome" page. Is it possible to hide/display based on certain condition ? The condition to be checked will depend on the webservice response returned by our customised ldap server. I would like to know, if it is possible to do this programatically, some kind of java class invocation, before we show the page links at the top.

Thanks
Karthik
Amit Doshi
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午1:09
答复

Amit Doshi

等级: Liferay Master

帖子: 547

加入日期: 2010年12月29日

最近的帖子

Hi Karthik,

You can do one thing is that you consume that Web Service in liferay.

And access that web service in theme portal_normal.vm and Depending upon the output of that particular webservice you can hide or show your pages as you required by putting condition in it.

Hope it helps.

Thanks & Regards,
Amit Doshi
Karthik Baskaran
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午1:40
答复

Karthik Baskaran

等级: Junior Member

帖子: 32

加入日期: 2012年5月3日

最近的帖子

Hi Amit,

I am new to Liferay portal. Can you point me to the exact location, where I can find details on your implementation approach.

Thanks
Karthik
Karthik Baskaran
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午4:28
答复

Karthik Baskaran

等级: Junior Member

帖子: 32

加入日期: 2012年5月3日

最近的帖子

Hi,

Can anyone point me to the exact resource for me to proceed on this ?

Thanks
Karthik
Amit Doshi
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午5:04
答复

Amit Doshi

等级: Liferay Master

帖子: 547

加入日期: 2010年12月29日

最近的帖子

Create the simple java project and do simple webservice consumption in eclipse and create jar file for it.
And put that jar file in tomcat/lib/ext/ folder.

And now use that Service method in theme portal_normal.vm using the following code.
1
2#set ($customLocalService = $serviceLocator.findService('com.sample.portlet.myprofile.service.MyProfileDataLocalService'))
3#set ($number=$customLocalService.getMyProfileDatasCount())


Here I given example of my class that I am going to call and use it's function.

The above is starting point for you to begin, now call your's function from portal_normal.vm as shown above and get values from the service and depend on it put conditions for hiding and showing the page in navigation.vm.

Hope it helps.

Thanks & Regards,
Amit Doshi
David H Nebinger
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午5:01
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 9012

加入日期: 2006年9月1日

最近的帖子

Karthik Baskaran:
Hi,

When we add pages to the portal, these new pages get added next to "Welcome" page. Is it possible to hide/display based on certain condition ? The condition to be checked will depend on the webservice response returned by our customised ldap server. I would like to know, if it is possible to do this programatically, some kind of java class invocation, before we show the page links at the top.

Thanks
Karthik



You're going to implement a custom theme. Override the navigation.vm file to invoke your own class. Your class will use jaxb (or whatever) to access the remote web service. Your class will want to cache the data so moving around in the portal doesn't slow to a crawl.
David H Nebinger
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午5:16
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 9012

加入日期: 2006年9月1日

最近的帖子

Amit Doshi:
Create the simple java project and do simple webservice consumption in eclipse and create jar file for it.
And put that jar file in tomcat/lib/ext/ folder.


Bad advice. Dropping code in lib/ext means you're binding yourself to server restarts whenever you need to update the code, and that's not a good idea.

Instead bundle the jar w/ the deployment artifact(s).

And now use that Service method in theme portal_normal.vm using the following code.
1
2#set ($customLocalService = $serviceLocator.findService('com.sample.portlet.myprofile.service.MyProfileDataLocalService'))
3#set ($number=$customLocalService.getMyProfileDatasCount())


Here I given example of my class that I am going to call and use it's function.


How does your "simple java project" map over to the architecture that is Service Builder? SB creates all of the stuff that you can leverage in the velocity macros in this way, no "simple java project" is going to plug into the same architecture.
Amit Doshi
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午7:15
答复

Amit Doshi

等级: Liferay Master

帖子: 547

加入日期: 2010年12月29日

最近的帖子

Hi David,

I agree with your suggestion that putting the jar file in tomcat/lib/ext will binds us to the server restart.

Can you please suggest then how can we access our own custom web service which was build with the help of service builder in theme without putting the jar file in tomcat/lib/ext folder ?

And on second point I agree with you on that too.. Directly putting the jar file of building simple java project will not give build Environment for the SB. There is couple of entries in the different xml like springs,context etc files need to be there in order to build SB environment then only one can consume the Service.

Sorry, for my post for building java project.

But according to karthik post that they have already have web service for LDAP, which they want to access it.
So, I don't think then there will be any requirement for service builder now.

Now the question remains the same How can we access that webservice which was build in any platform and use it in theme ?

Thanks & Regards,
Amit Doshi
David H Nebinger
RE: How to manage page links in navigation bar programatically
2012年5月4日 上午7:30
答复

David H Nebinger

Community Moderator

等级: Liferay Legend

帖子: 9012

加入日期: 2006年9月1日

最近的帖子

Amit Doshi:
Can you please suggest then how can we access our own custom web service which was build with the help of service builder in theme without putting the jar file in tomcat/lib/ext folder ?


You declare the required deployment context in the plugin consuming the SB service in the liferay-plugin-package.properties file. When service is rebuilt in the plugin providing the SB service, the service jar will be automatically copied to the plugins that have it listed as required deployment contexts (all of this should be done in the IDE).

Now the question remains the same How can we access that webservice which was build in any platform and use it in theme ?


The same way you'd access any web service in java - you can use jaxb, axis, etc. Generate the necessary client code to invoke the web service. Wrap all of the stuff into a nice little utility class and call that utility class from the navigation.vm velocity template.
Amit Doshi
RE: How to manage page links in navigation bar programatically
2012年5月5日 上午8:37
答复

Amit Doshi

等级: Liferay Master

帖子: 547

加入日期: 2010年12月29日

最近的帖子


You declare the required deployment context in the plugin consuming the SB service in the liferay-plugin-package.properties file. When service is rebuilt in the plugin providing the SB service, the service jar will be automatically copied to the plugins that have it listed as required deployment contexts (all of this should be done in the IDE).


Thanks David . Actually in my mind i was thinking of Web content (Velocity and Templates) not of theme that made me mistake to identify. I hope we require to put jar file in tomcat/lib/ext, when we want to use custom service in templates as show in code above. Make me correct if i am wrong?


The same way you'd access any web service in java - you can use jaxb, axis, etc. Generate the necessary client code to invoke the web service. Wrap all of the stuff into a nice little utility class and call that utility class from the navigation.vm velocity template.


Like to know more on above. Because as we discussed if we make simple jar files then it will not give us SB portablity. Then If we are making utility class then it will be of SB type or normal portlet or jar of jaxb etc.
Karthik Baskaran
RE: How to manage page links in navigation bar programatically
2012年5月7日 下午7:00
答复

Karthik Baskaran

等级: Junior Member

帖子: 32

加入日期: 2012年5月3日

最近的帖子

Hi,

Can any one of you please guide me to the location where I can learn more about this and try to apply this approach ?

Thanks
Karthik