Foros de discusión

Reg: Changing Item in Navigation

Arun Kumar, modificado hace 11 años.

Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
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?

Archivos adjuntos:

thumbnail
Gnaniyar Zubair, modificado hace 11 años.

RE: Reg: Changing Item in Navigation

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
Hi..
Thank u Zubair...

Can i do the same using API? Since I m using vaadin.
thumbnail
Gnaniyar Zubair, modificado hace 11 años.

RE: Reg: Changing Item in Navigation

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
How do you generate the DAO services in that Vaadin portlet?
Arun Kumar, modificado hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation (Respuesta)

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
Thank you.. emoticon
Any possibility of doing without hooks?
thumbnail
Gnaniyar Zubair, modificado hace 11 años.

RE: Reg: Changing Item in Navigation

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
Gud question. I dont know what is your business logic ?... emoticon
Arun Kumar, modificado hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
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 hace 11 años.

RE: Reg: Changing Item in Navigation

Liferay Master Mensajes: 722 Fecha de incorporación: 19/12/07 Mensajes recientes
How you are getting that total messages..? is it coming from database ?

Are you using service Builder for transaction layer?
Arun Kumar, modificado hace 11 años.

RE: Reg: Changing Item in Navigation

New Member Mensajes: 8 Fecha de incorporación: 7/10/12 Mensajes recientes
The total messages are get from activiti-bpmn. Thats different.