Fórum

Reg: Changing Item in Navigation

Arun Kumar, modificado 11 Anos atrás.

Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
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?
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
Hi..
Thank u Zubair...

Can i do the same using API? Since I m using vaadin.
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
How do you generate the DAO services in that Vaadin portlet?
Arun Kumar, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
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
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation (Resposta)

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
Thank you.. emoticon
Any possibility of doing without hooks?
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
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... ?
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
Gud question. I dont know what is your business logic ?... emoticon
Arun Kumar, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
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..?
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
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)
thumbnail
Gnaniyar Zubair, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

Liferay Master Postagens: 722 Data de Entrada: 19/12/07 Postagens Recentes
How you are getting that total messages..? is it coming from database ?

Are you using service Builder for transaction layer?
Arun Kumar, modificado 11 Anos atrás.

RE: Reg: Changing Item in Navigation

New Member Postagens: 8 Data de Entrada: 07/10/12 Postagens Recentes
The total messages are get from activiti-bpmn. Thats different.