Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Arun Kumar
Reg: Changing Item in Navigation
February 19, 2013 3:39 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

Hi there,
Is there any way that i can change the name of the menu, dynamically. Please refer the Attachment.
I want to change the name of the menu in the navigator (marked in blue) dynamically with some count,

Can anybody help me?
Attachment

Attachments: Attach.JPG (25.0k)
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 19, 2013 3:58 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

Yes definitely you can do that. you have to write the logic in portal_normal.vm .

Get the total count number from portlet services by serviceLocator in velocity file.

#set($inboxService= $serviceLocator.findService("com.liferay.inbox.service.InboxLocalService"))
#set($totalCount = $inboxService.getTotalCount())


then add the count with the page name

#if ($nav_item.getName() == "Inbox" )
$nav_item.getName()+"("+$totalCount+")"
#end
Arun Kumar
RE: Reg: Changing Item in Navigation
February 19, 2013 4:04 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

Hi..
Thank u Zubair...

Can i do the same using API? Since I m using vaadin.
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 19, 2013 4:13 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

How do you generate the DAO services in that Vaadin portlet?
Arun Kumar
RE: Reg: Changing Item in Navigation
February 19, 2013 5:26 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

The count to be displayed is based on some other logic. This portlet is developed based on activiti. I need an API from liferay so that it changes the title. The value to be populated is from a different API
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 19, 2013 6:00 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

All the default velocity variables which can be accessible in liferay is deriving from ServicePreAction. So in that way, you can extend the ServicePreAction [com.liferay.portal.events.ServicePreAction] through property Hook and set the required variables in that ServicePreAction and access that variable in portal_normal.vm

1. add portal.properties entry in liferay-hook.xml
2. set this property in portal.properties of hook
servlet.service.events.pre=com.liferay.custom.events.CustomServicePreAction


3. Extend ServicePreAction :

public class CustomServicePreAction extends Action {
public void run(HttpServletRequest request, HttpServletResponse response) {

Map customVar = new HashMap();

customVar .put("totalCount", <someValue>));

request.setAttribute(WebKeys.VM_VARIABLES, customVar );
}
}
Arun Kumar
RE: Reg: Changing Item in Navigation
February 19, 2013 6:00 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

Thank you.. emoticon
Any possibility of doing without hooks?
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 19, 2013 6:06 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

1. Create normal Java classes which dont talk with Liferay API
2. Convert them as JAR file
3. copy into global path if tomcat, tomcat/lib/ext
4. import that package and access it.
Arun Kumar
RE: Reg: Changing Item in Navigation
February 19, 2013 6:15 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

Thank u again..
I m a newbie to java..
Can u say what to be written in the java class so that i can access it... ?
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 19, 2013 6:24 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

Gud question. I dont know what is your business logic ?... emoticon
Arun Kumar
RE: Reg: Changing Item in Navigation
February 19, 2013 10:40 PM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

The Logic to return the count is a static class, which i already have. How can i display the count as i requested? Is there any possibility of displaying that without using hooks..?
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 19, 2013 11:10 PM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

Arun,

I already explained different situation if not HOOKS.

Ok Count is your static class. But what are the business logic inside that..?

Are you gonna display total messages received for users? then how would you receive the total count for that INBOX.
Arun Kumar
RE: Reg: Changing Item in Navigation
February 20, 2013 2:11 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

Hi Zubair,
Yes, I ld be displaying the total messages received for that user... the count would be the same thing what ever i m displaying for that Tab (can be seen as Inbox(0) in that image)
Kowbathullah Gnaniyar
RE: Reg: Changing Item in Navigation
February 20, 2013 2:27 AM
Answer

Kowbathullah Gnaniyar

Rank: Liferay Master

Posts: 606

Join Date: December 19, 2007

Recent Posts

How you are getting that total messages..? is it coming from database ?

Are you using service Builder for transaction layer?
Arun Kumar
RE: Reg: Changing Item in Navigation
February 20, 2013 3:19 AM
Answer

Arun Kumar

Rank: New Member

Posts: 8

Join Date: October 7, 2012

Recent Posts

The total messages are get from activiti-bpmn. Thats different.