Foren

How to fetch vm variables like $group_id, etc on portlets jsp??

Parag Negi, geändert vor 11 Jahren.

How to fetch vm variables like $group_id, etc on portlets jsp??

Junior Member Beiträge: 29 Beitrittsdatum: 01.02.12 Neueste 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
thumbnail
Prakash Khanchandani, geändert vor 11 Jahren.

RE: How to fetch vm variables like $group_id, etc on portlets jsp??

Expert Beiträge: 329 Beitrittsdatum: 10.02.11 Neueste 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:
<%@ taglib uri="http://liferay.com/tld/theme"     prefix="liferay-theme" %>
<liferay-theme:defineobjects />


Then you can use it like this in your JSP:

&lt;%
long groupId = themeDisplay.getScopeGroupId(); // current group
long userId = themeDisplay.getUserId(); // fetches the current logged in user's ID
User user = themeDisplay.getUser(); // current logged in user 
Company company = themeDisplay.getCompany(); 

//..... and so on

// also you get the permissionChecker object
boolean isCAdmin = permissionChecker.isCompanyAdmin();
boolean isGadmin = permissionChecker.isGroupAdmin(groupId);

// .... and so on
%&gt;


Hope this helps.
Siju Thomas, geändert vor 11 Jahren.

RE: How to fetch vm variables like $group_id, etc on portlets jsp??

New Member Beiträge: 4 Beitrittsdatum: 27.07.11 Neueste 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%>
thumbnail
Prakash Khanchandani, geändert vor 11 Jahren.

RE: How to fetch vm variables like $group_id, etc on portlets jsp??

Expert Beiträge: 329 Beitrittsdatum: 10.02.11 Neueste 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, geändert vor 11 Jahren.

RE: How to fetch vm variables like $group_id, etc on portlets jsp??

New Member Beiträge: 4 Beitrittsdatum: 27.07.11 Neueste 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.
thumbnail
Anil T, geändert vor 6 Jahren.

RE: How to fetch vm variables like $group_id, etc on portlets jsp??

Expert Beiträge: 313 Beitrittsdatum: 14.01.12 Neueste Beiträge
Did you get any solution for this problem?

I am also trying to fetch velocity variables in custom portlets JSP pages but unable to fetch it.