Skip to content

Instantly share code, notes, and snippets.

@sammso
Last active April 12, 2018 22:26
Show Gist options
  • Save sammso/33a47664163b9999cd9c9b2b849ce340 to your computer and use it in GitHub Desktop.
Save sammso/33a47664163b9999cd9c9b2b849ce340 to your computer and use it in GitHub Desktop.

Appication training developer at leiden

Portlet examples

https://www.dropbox.com/s/8j7rheyr9ic59cq/portlet-examples.zip?dl=0

IntelliJ

https://github.com/liferay/liferay-ide/blob/master/liferay-idea-plugin/

https://github.com/holatuwol/liferay-intellij

Configuraiton example

https://www.dropbox.com/s/wsspavxno4gesw4/supercoolmvc.zip?dl=0

Fixes for the Validation for AddAssignmentMVCActionCommand and EditAssignmentMVCActionCommand

		else {
			errors.forEach(key->SessionErrors.add(actionRequest, key));
			
			actionResponse.setRenderParameter(
				"mvcRenderCommandName", "/gradebook/assignment/edit");
		}

How to Use Liferay Services

Tool that helps you to import Liferay source code to Eclips

https://github.com/jorgediaz-lr/generate-modules-classpath

6.2 example how to create JSONWS services

https://github.com/sammso/liferay-rest-consumer

Fixes for the Gradebook AssetPublisher part

AssignmentRenderingFactory

@Reference(target = "(osgi.web.symbolicname=com.liferay.training.space.gradebook)")
private ServletContext _servletContext;
@Override
public PortletURL getURLAdd(
	LiferayPortletRequest liferayPortletRequest,
	LiferayPortletResponse liferayPortletResponse, long classTypeId) {
	PortletURL portletURL = null;

	portletURL = _portal.getControlPanelPortletURL(
				liferayPortletRequest, getGroup(liferayPortletRequest),
				GradebookPortletKeys.PORTLET_NAME, 0, 0, PortletRequest.RENDER_PHASE);
	
	portletURL.setParameter("mvcRenderCommandName", "/gradebook/assignment/edit");
	portletURL.setParameter("showback", Boolean.FALSE.toString());
	
	return portletURL;
}

From gradebook-web/build.gradle change version like below

compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "2.6.0"

AssignmentAssetRenderer

Modify the getURLEdit

@Override
public PortletURL getURLEdit(
		LiferayPortletRequest liferayPortletRequest,
		LiferayPortletResponse liferayPortletResponse)
	throws Exception {

	Group group = (Group)liferayPortletRequest.getAttribute(
			WebKeys.ASSET_RENDERER_FACTORY_GROUP);

	PortletURL portletURL = PortalUtil.getControlPanelPortletURL(
		liferayPortletRequest, group,
		GradebookPortletKeys.PORTLET_NAME, 0, 0, PortletRequest.RENDER_PHASE);

	portletURL.setParameter("mvcRenderCommandName", "/gradebook/assignment/edit");
	portletURL.setParameter(
		"assignmentId", String.valueOf(_assignment.getAssignmentId()));
	portletURL.setParameter("showback", Boolean.FALSE.toString());

	return portletURL;
}

GradebookPortlet

Make also portlet non instanceable by modifying GradebookPortlet class.

@Component(
	immediate = true,
	property = {
		"com.liferay.portlet.add-default-resource=true",
		"com.liferay.portlet.display-category=category.sample",
		"com.liferay.portlet.instanceable=false",
		"javax.portlet.display-name=gradebook-web Portlet",
		"javax.portlet.init-param.template-path=/",
		"javax.portlet.init-param.view-template=/view.jsp",
		"javax.portlet.name=" + GradebookPortletKeys.PORTLET_NAME,
		"javax.portlet.resource-bundle=content.Language",
		"javax.portlet.security-role-ref=power-user,user",
		"javax.portlet.init-param.add-process-action-success-action=false"
	    
	},
	service = Portlet.class
)

GOGO Shell scripting example

portalUtilReference=(serviceReference "com.liferay.portal.kernel.util.PortalUtil")
portalUtil=(service $portalUtilReference)
defaultCompanyId=($portalUtil getDefaultCompanyId)
userServiceReference=(serviceReference "com.liferay.portal.kernel.service.UserLocalService")
userService=(service $userServiceReference)
users=$userService getCompanyUsers $defaultCompanyId 0 100   
each $users { $it getFullName }

Felix web console:

install http://central.maven.org/maven2/org/apache/felix/org.apache.felix.webconsole/4.3.4/org.apache.felix.webconsole-4.3.4.jar

JSP hooks

How to include page at JSP fragment

<liferay-util:include page="/create_account.portal.jsp" servletContext="<%= application %>"/>

Extra Slides

https://www.dropbox.com/s/7rp5r0mmtccrjy9/app-dev-extra.pdf?dl=0

https://www.dropbox.com/s/gpcrlnte756bru6/Upgrading-to-DXP-v2.pdf?dl=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment