Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Karthik Baskaran
How to manage page links in navigation bar programatically
May 3, 2012 10:40 PM
Answer

Karthik Baskaran

Rank: Junior Member

Posts: 32

Join Date: May 3, 2012

Recent Posts

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
May 4, 2012 1:09 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

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
May 4, 2012 1:40 AM
Answer

Karthik Baskaran

Rank: Junior Member

Posts: 32

Join Date: May 3, 2012

Recent Posts

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
May 4, 2012 4:28 AM
Answer

Karthik Baskaran

Rank: Junior Member

Posts: 32

Join Date: May 3, 2012

Recent Posts

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
May 4, 2012 5:04 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

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
May 4, 2012 5:01 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11770

Join Date: September 1, 2006

Recent Posts

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
May 4, 2012 5:16 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11770

Join Date: September 1, 2006

Recent Posts

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
May 4, 2012 7:15 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

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
May 4, 2012 7:30 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11770

Join Date: September 1, 2006

Recent Posts

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
May 5, 2012 8:37 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts


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
May 7, 2012 7:00 PM
Answer

Karthik Baskaran

Rank: Junior Member

Posts: 32

Join Date: May 3, 2012

Recent Posts

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