Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
Parag Negi
How to fetch vm variables like $group_id, etc on portlets jsp??
3. Mai 2012 02:50
Antwort

Parag Negi

Rang: Junior Member

Nachrichten: 29

Eintrittsdatum: 1. Februar 2012

Neue Beiträge

Hi gang,

Is it possible to fetch vm variables like $group_id or $company_name directly to your portlets jsp?

i basically want to enable/visible some piece of code in my portlet's jsp, to only those people who match this criteria below:

(($permissionChecker.isOmniadmin())||$permissionChecker.isCompanyAdmin($themeDisplay.getCompanyId())|| $permissionChecker.isCommunityAdmin($themeDisplay.getScopeGroupId()))

These will be people with admin. priviledges only.

Is it possible to run the above code directly in my portlets jsp...
Please advise, any hep much appreciated...

Thanks,
Parag
Prakash Khanchandani
RE: How to fetch vm variables like $group_id, etc on portlets jsp??
3. Mai 2012 03:11
Antwort

Prakash Khanchandani

Rang: Regular Member

Nachrichten: 229

Eintrittsdatum: 10. Februar 2011

Neue Beiträge

You can get these parameters from themeDisplay object in your JSP.

Have the following code in your JSPs to enable liferay specific objects:
1<%@ taglib uri="http://liferay.com/tld/theme"     prefix="liferay-theme" %>
2<liferay-theme:defineObjects />


Then you can use it like this in your JSP:
 1
 2<%
 3long groupId = themeDisplay.getScopeGroupId(); // current group
 4long userId = themeDisplay.getUserId(); // fetches the current logged in user's ID
 5User user = themeDisplay.getUser(); // current logged in user
 6Company company = themeDisplay.getCompany();
 7
 8//..... and so on
 9
10// also you get the permissionChecker object
11boolean isCAdmin = permissionChecker.isCompanyAdmin();
12boolean isGadmin = permissionChecker.isGroupAdmin(groupId);
13
14// .... and so on
15%>


Hope this helps.
Siju Thomas
RE: How to fetch vm variables like $group_id, etc on portlets jsp??
16. Januar 2013 02:54
Antwort

Siju Thomas

Rang: New Member

Nachrichten: 4

Eintrittsdatum: 27. Juli 2011

Neue Beiträge

HI

#set ($companyName = "shark")
#set ($companyUrl = "http://www.shark.com")
#set ($companyEmail = "info@shark.com")
this is my custom variables saved in init_custom.vm . How to show this vm variables in my login.jsp in Hook.
I am using below code and its not working
Welcome to the <%=themeDisplay.companyName%>
Prakash Khanchandani
RE: How to fetch vm variables like $group_id, etc on portlets jsp??
16. Januar 2013 03:19
Antwort

Prakash Khanchandani

Rang: Regular Member

Nachrichten: 229

Eintrittsdatum: 10. Februar 2011

Neue Beiträge

I think you are creating custom variables in velocity templates which you want to access in liferay's JSP.

AFAIK velocity variables created in the templates cannot be accessed inside JSP, but still will look if this is possible.

Can you provide a usecase as to why you would want to define new velocity variables and access them in your JSPs?

For accessing the company which you can use <%= themeDisplay.getCompany().getName() %>, though this won't give the company name changed in the velocity template, instead this gives the company name in which this portal page exists.
Siju Thomas
RE: How to fetch vm variables like $group_id, etc on portlets jsp??
16. Januar 2013 03:48
Antwort

Siju Thomas

Rang: New Member

Nachrichten: 4

Eintrittsdatum: 27. Juli 2011

Neue Beiträge

Thank you Prakash.
I tried this method, but In my case I want to display the variables stored in the theme level to custom JSP and its not the main configuration values in the velocity variables.