掲示板

Reg: Changing Item in Navigation

11年前 に Arun Kumar によって更新されました。

Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
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
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
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
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
Hi..
Thank u Zubair...

Can i do the same using API? Since I m using vaadin.
thumbnail
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
How do you generate the DAO services in that Vaadin portlet?
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
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
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation (回答)

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
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 );
}
}
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
Thank you.. emoticon
Any possibility of doing without hooks?
thumbnail
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
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.
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
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
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
Gud question. I dont know what is your business logic ?... emoticon
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
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
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
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.
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
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
11年前 に Gnaniyar Zubair によって更新されました。

RE: Reg: Changing Item in Navigation

Liferay Master 投稿: 722 参加年月日: 07/12/19 最新の投稿
How you are getting that total messages..? is it coming from database ?

Are you using service Builder for transaction layer?
11年前 に Arun Kumar によって更新されました。

RE: Reg: Changing Item in Navigation

New Member 投稿: 8 参加年月日: 12/10/07 最新の投稿
The total messages are get from activiti-bpmn. Thats different.