liferay-velocity

How to write a java class to be accessed in liferay theme?

旧时模样 提交于 2019-12-11 13:29:26
问题 I have a Scenario where I have a java class written in JSP and its members are used in that JSP itself. The JSP is part of a liferay portlet. Now, I need to write that class for the velocity template in liferay theme so that I can access it in navigation.vm file. Following is a dummy snippet - xyz.jsp (part) <body> <% final class DummyABC { public String method1() { } public String method2() { } public String method3() { } } %> </body> I need to access this class in my navigation.vm file.

Editing velocity template of Liferay changes not showing or takes a while

匆匆过客 提交于 2019-12-11 09:26:54
问题 I'm currently editing my portal_normal.vm (server/tomcat/webapps/mytheme-theme/templates) testing if I can write on the file and see it on my browser. I tried putting a test comment "<!-- test -->" just to see if I can really write on the file. So I refreshed the file and hope I can see the comment I've added, but there we're none. So I continued refreshing (ctrl+r),\ and viewing the source code for almost an twenty minutes. After a while when I tried viewing it again it reflected in my

Liferay 6.2 Search result on separate page

与世无争的帅哥 提交于 2019-12-11 07:28:06
问题 Is it possible to redirect search-Result (portlet: $theme.journalContentSearch() ) to my " http://localhost/search " page? I need this, because on home-page I don't have any portlets-placeholder, and after submit search-form, I see nothing. If I use this function on other page, it work fine, but stay in same page where I do form-submit, e.g. "/contact?****blablabla****" /* new */ long searchPlid = plid; System.out.println(TAG + "plid: " + plid); //My Hidden search page Layout searchPage =

How to get Server Name and Server Port from Liferay velocity template?

强颜欢笑 提交于 2019-12-10 21:05:33
问题 In jsp page we can get Server Name and Server Port by using request.getServerName() and request.getServerPort().` As we can't get HttpServletRequest from Liferay velocity template, Is there any other way to get both Server Name and Server Port ? Please answer with a small code snippet.. 回答1: In your Liferay sources you can find com.liferay.portal.velocity.VelocityVariablesImpl . This class is placed under portal-impl/src/com/liferay/portal/velocity/VelocityVariablesImpl.java . If you check

rendering Liferay page URLs inside of portlets Liferay 6.1

[亡魂溺海] 提交于 2019-12-09 13:28:03
问题 I'm new to liferay and I'm almost positive this is blazingly simple to do: Using velocity markup, I want to be able to generate links to pages within my Liferay website and embed them inside of my portlets on different pages. I have a vague idea of how it might be done so I searched around figuring it would be posted somewhere, but I can't find anything on it. Incidentally, I want to put whatever code I come up with inside the view.jsp of the portlet. I would use velocity markup here but I

Velocity (VM) template request parameters: Getting GET variables

。_饼干妹妹 提交于 2019-12-08 09:31:12
问题 How do i access GET variables as passed in the URI in a VM template? This works only when loading the widget URL: $request.get("parameters").get("fav").get(0) I'm looking for a neat solution that works with friendly URLs. Here's my testing template: <br><br><br> #set($url = $request.attributes.CURRENT_URL) <h2>url: $url</h2> #set($favs = $url.split("fav=")) favs: $favs<br> favs.size(): $favs.size() <br> #if($favs.size() > 1) #set($fav1 = $favs.get(1).split("&").get(0)) fav1: $fav1<br> #else

Velocity (VM) template request parameters: Getting GET variables

此生再无相见时 提交于 2019-12-06 16:14:27
How do i access GET variables as passed in the URI in a VM template? This works only when loading the widget URL: $request.get("parameters").get("fav").get(0) I'm looking for a neat solution that works with friendly URLs. Here's my testing template: <br><br><br> #set($url = $request.attributes.CURRENT_URL) <h2>url: $url</h2> #set($favs = $url.split("fav=")) favs: $favs<br> favs.size(): $favs.size() <br> #if($favs.size() > 1) #set($fav1 = $favs.get(1).split("&").get(0)) fav1: $fav1<br> #else No fav! #end #if($favs.size() > 2) #set($fav2 = $favs.get(2).split("&").get(0)) fav2: $fav2<br> #end

Create object in velocity template

我的未来我决定 提交于 2019-12-05 03:38:24
I am writing velocity templates for my liferay theme and I am wondering, whether it is possible to create a new object inside the velocity template. The reason is that in liferay there is no contextTool registered in the context and I really want to be able to inspect the variables that are present in the template at a given time. There is a cool macro for this, but unfortunately it uses the contexttool. I'd like to do something like: #set($contextTool = new ContextTool()) Another solution would be java code that is provided with the liferay theme that is able to add stuff in the template

rendering Liferay page URLs inside of portlets Liferay 6.1

岁酱吖の 提交于 2019-12-03 16:39:19
I'm new to liferay and I'm almost positive this is blazingly simple to do: Using velocity markup, I want to be able to generate links to pages within my Liferay website and embed them inside of my portlets on different pages. I have a vague idea of how it might be done so I searched around figuring it would be posted somewhere, but I can't find anything on it. Incidentally, I want to put whatever code I come up with inside the view.jsp of the portlet. I would use velocity markup here but I don't think (don't know for sure) if that is allowed inside of a jsp. Please let me know if you need more

How to create Structure & Template programmatically in Liferay 6

我怕爱的太早我们不能终老 提交于 2019-12-01 08:54:28
问题 I need to create the Structure and Template progrmatically through java code.I used following code snippets. Structure: public void createStructure(String userName,long userId){ log_.info("Inside create structure "); long structureId=115203; DDMStructure ddmStructure=DDMStructureLocalServiceUtil.createDDMStructure(structureId); ddmStructure.setName("MigrationStructure"); ddmStructure.setDescription("This Structure created programatically"); ddmStructure.setUserId(userId); ddmStructure