Skip to content

Instantly share code, notes, and snippets.

<aui:script use="liferay-portlet-url">
var portletURL = Liferay.PortletURL.createRenderURL();
portletURL.setPortletId('<%= portletId %>');
var urlToUse=portletURL.toString();
</aui:script>
@topolik
topolik / gist:3147100
Created July 19, 2012 21:51
Filtering faceted search
<%@ page import="com.liferay.portal.kernel.search.*" %>
<%
// should add something like: (+(entryClassName:com.liferay.portlet.documentlibrary.model.DLFileEntry) -(extension:png))
BooleanQuery q1 = BooleanQueryFactoryUtil.create(searchContext);
BooleanQuery subQ = BooleanQueryFactoryUtil.create(searchContext);
subQ.addTerm("entryClassName", "com.liferay.portlet.documentlibrary.model.DLFileEntry");
q1.add(subQ, BooleanClauseOccur.MUST);
22:52:52,726 ERROR [http-bio-8080-exec-1][JDBCExceptionReporter:76] data exception: numeric value out of range
22:52:52,729 ERROR [http-bio-8080-exec-1][JSONWebServiceServiceAction:103] com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.DataException: could not execute query
com.liferay.portal.kernel.exception.SystemException: com.liferay.portal.kernel.dao.orm.ORMException: org.hibernate.exception.DataException: could not execute query
at com.liferay.calendar.service.persistence.CalendarBookingFinderImpl.doFindByC_G_C_C_P_T_D_L_S_E_S(CalendarBookingFinderImpl.java:533)
at com.liferay.calendar.service.persistence.CalendarBookingFinderImpl.findByC_G_C_C_P_T_D_L_S_E_S(CalendarBookingFinderImpl.java:319)
at com.liferay.calendar.service.persistence.CalendarBookingFinderImpl.findByKeywords(CalendarBookingFinderImpl.java:283)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Nati
// Groovy
themeDisplay = actionRequest.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
out.println(com.liferay.portal.util.PortalUtil.getControlPanelPortlets("portal", themeDisplay));
@topolik
topolik / asset-ext.xml
Created September 3, 2012 07:41
Tag portlet in control panel for Liferay 6.0.5
<?xml version="1.0"?>
<resource-action-mapping>
<!-- put this file into ROOT/WEB-INF/resource-actions/asset-ext.xml -->
<portlet-resource>
<portlet-name>99</portlet-name>
<permissions>
<supports>
<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
<action-key>CONFIGURATION</action-key>
<action-key>VIEW</action-key>
@topolik
topolik / gist:3619076
Created September 4, 2012 09:24
redirect after exception from serve resource
@Override
public void serveResource(
ResourceRequest resourceRequest, ResourceResponse resourceResponse)
throws PortletException {
try {
... generate csv
... set response headers
... write csv
@topolik
topolik / run-tests.sh
Created September 12, 2012 11:16
Bash script for running Liferay tests
#!/bin/bash
cat > portal-impl/src/portal-test-ext.properties <<EOF
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost/lportal_test?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=
index.on.startup=true
EOF
@topolik
topolik / web.xml
Created October 3, 2012 17:43
Liferay plugin JSON WS configuration for 6.1.20 / 6.1.1
<filter>
<filter-name>Secure JSON Web Service Servlet Filter</filter-name>
<filter-class>com.liferay.portal.kernel.servlet.PortalClassLoaderFilter</filter-class>
<init-param>
<param-name>filter-class</param-name>
<param-value>com.liferay.portal.servlet.filters.secure.SecureFilter</param-value>
</init-param>
<init-param>
<param-name>basic_auth</param-name>
<param-value>true</param-value>
@topolik
topolik / search.jsp
Created October 16, 2012 09:21
Redirecting to the only one search result in wiki/search portlet
<%
// ... OLD CONTENT
searchContext.setEnd(searchContainer.getEnd());
searchContext.setKeywords(keywords);
searchContext.setNodeIds(nodeIds);
searchContext.setStart(searchContainer.getStart());
Hits results = indexer.search(searchContext);
int total = results.getLength();
@topolik
topolik / gist:3899194
Created October 16, 2012 13:12
Checkbox in look & feel portlet settings
portlet/portlet_css/view.jsp:
==================================
<aui:input name="my-checkbox" type="checkbox" onClick="updateMyCheckbox()" />
<script type="text/javascript">
function updateMyCheckbox(){
AUI().io.request(
themeDisplay.getPathMain() + '/portlet_configuration/update_my_checkbox',
{
data: {