Power Of Beanshell In Liferay

General Blogs 2013年4月17日 按 Jignesh Vachhani

Hey Friends,

Do you know the use of Beanshell script which is coming up with Liferay control panel ?

I didn't know that superb utility available in liferay which can be useful at some specific functions and cases.

If you go to Liferay control panel >> Server Administration section,
there is one tab available to run the bean shell script directly . See below screen shot

Here if you see drop down, you can execute Java,javascript,Groovy,Python,Ruby language code directly.

So it's sometime very useful if you want to run some Liferay API and want to add ot update data on the fly.
Let say i want to change all user's time zone to EST then you can run below code directly in beanshell script and can apply that data instead of running SQL query in DB manually.

userList= com.liferay.portal.service.UserLocalServiceUtil.getUsers(-1,-1);
for(com.liferay.portal.model.User user : userList){

out.println(user .getFirstName() +" : "+user.getTimeZone().getDisplayName()+" : "+user.getTimeZone(). getID());

Looks interesting Right !!!!!

Dont forget to visit http://www.liferaysolution.com for this kind of tips and tricks.

显示 1 结果。