How to prepare
- There is no shortcut. Don’t rely on any sample questions online(including this post) completely. Best way to prepare is to practice tutorial here . Even the experienced developers should try to go through the tutorial, try to create portlets, hooks and learn the concepts by doing things.
- One question will definitely come from this blog post
- At least 1-3 question will be around Liferay Lifecycle, Phases, Modes and States. Learn which ones are introduced in JSR-286
- Hooks Hooks Hooks learn as much as possible about hooks.
- Especially whether or not and how it can implement core JSP overwrites and custom action.
- Learn about the tags in the liferay-hook.xml
- Learn APIs for Util and User – for e.g., how to get organizations for a user OrganlizationServiceUtil.getUserOrganizations(long userId)
- Learn about EXT practices – how to cleanly deploy in the production environment and how to deploy in development environment
- liferay-portlet.xml, portlet.xml, portlet-custom.xml, portlet-ext.xml, liferay-plugin-package.properties, liferay-look-and-feel.xml – you understand about these files when you learn about them individually. But when you appear for the exam it is very very confusing.
- Ext vs Hook. Be very clear what can be done in hook and what can be done in EXT. The exam comes to this tricky issue again and again
- Don’t under estimate Layout Template and Theme sections. Read it from developer guide. It’s an easy win
- It is a good idea to look into liferay-hook dtd and portal.properties. But practically speaking you won’t be able to remember all the possible portal-properties. Objective is to learn about as many of them as possible
Example Questions(Not exact questions from actual exams)
Architecture
- What is true – class in plugin has access to every class in portal, every class in portal-service plus plugin class, every class in portal-impl.jar plus plugin class etc.
- What has to be done to prevent submission of form again?
- What happens after a portlets action is called. Options are – render of only that portlet is called, render of all portlets on the page is called, render of any portlet whose data changed is called.
- Expando is – service available to add custom attributes
- How to get organizations associated to a user. Options are UserServiceUtil, OrganizationServiceUtil, SiteServiceUtil, All of the above etc. I have answered UserLocalServiceUtil.getOrganizations() .
- The right answer is OrganlizationServiceUtil.getUserOrganizations(long userId)
- companyId is – options are organization, site, portal etc.
- Right answer – companyId represents a portal instance. Liferay can host multiple portals in a single database. companyId is primary key for a particular instance. In scope terms companyId is on top of the hierarchy, followed by GroupID which represents site or organization and then UserId, which identifies a user
- There is a plugin portlet which required another plugin portlet how to ensure that.
- Answer – is you will use required-deployment-contexts in liferay-plugin-packages.properties. LEARN MORE about it.
Hooks
- There was a question about removing a portlet from whitelist which is mentioned in portal.properties of the Portal. portlet.add.default.resource.check.whitelist . To remove one of the portlets from whitelist what has to be done.
- This is important. Hooks can just add to the whitelist because properties are merged. To remove, you may have to create ext. Some properties are just mergeable not overrideable
- Language properties for a locale en_Us is implemented. Now the language values for that particular locale will come from
- Yes, the answer is plugin’s Language_en plus core Language_en
- If you have to add a new field for indexing what would you do?
- I think indexer post processor hook should do it.
- What is the syntax for a custom-struts path in hook? I think I have answered this correctly. <!ELEMENT struts-action (struts-action-path, struts-action-impl)>. It involves structs-action-path root element with struts-action-path and struts-action-impl
- When you override a JSP say view.jsp using hook what happens to original JSP.
- Answer is that it gets replaced with view.portal.jsp
Layout templates
- two questions on how to include portlet plugin in layout template – $processor.processPortlet with Fully Qualified Portlet Id
- Please note that in theme you will include using theme.runtime(..)
Portlet
- Syntax of <liferay-ui:success key=”key” message=”message” /> was asked. I thought only key attribute is required.
- As per dtd both key and message are required
- How to escape special characters. For such questions, please learn about important utility methods in the following
- HtmlUtil
- ParamUtil
- GetterUtil
Development practices
- ant command to remove classes – ant clean
- how to get portal-developer.properties (read https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/lp-6-1-theme-developer-mode)
Themes
- how the base theme settings are imported.
- Just set theme.parent in build.xml
- Javascript method called after each portlet is executed.
- Right answer is Liferay.Portlet.ready(fn) . This is an important question. This comes in one way or another. Link
- AlloyUI is based on – answer is YUI3
- How to remove portlet borders in custom theme
- answers http://www.liferay.com/community/forums/-/message_boards/message/100695
- In custom theme use liferay-settings
- How to embed a portlet in theme. Answer is theme.runtime()
EXT
- Best way to undeploy / redeploy ext hook – I think best is to unzip clean portal
- Best way to remove some customization from ext and deploy changes in development environment .
Service Builder
- What are the services available/injected to each service generated by service builder. CounterLocalService, AssetLocalService, ResourceLocalService and two more..
- Counter
- Resource
- User
Others
- There was one question where they wanted to strip out something from returned response. where can we do it? options were Request post processor in hook/ext, servlet filters, post action etc
- It could be done by StripFilter and if the requirement is not met by that we can use servletfilter
- It’s interesting, servlet filters can be used for both requests and responses
- If you have to run a code which has to be run just once, where will you put it.
- It would be Upgrade process https://web.liferay.com/web/ryan.park/blog/-/blogs/implementing-upgradingprocess-for-your-liferay-portlets!
- If you want to remove some core portlet from Add Portlet option to control panel what will you do.
- A service.xml mapping was shown with entity something and localservice=true and remoteservice=false was asked what classes will be generated. In general, it’s better to understand what are the different classes which are generated in various options
- Take example of Event entity
- Persistence
- EventPersistence
- EventPersistenceImpl
- EventUtil
- Local Service
- EventLocalService
- EventLocalServiceImpl(CLASS TO BE MANUALLY CHANGED)
- EventLocalServiceBaseImpl
- EventLocalServiceUtil
- EventLocalServiceWrapper
- Remote Service
- EventService
- EventServiceImpl(CLASS TO BE MANUALLY CHANGED)
- EventServiceBaseImpl
- EventServiceUtil
- EventServiceWrapper
- EventServiceSoap
- EventSoap
- Model
- EventModel
- EventModelImpl
- Event
- EventImpl(CLASS TO BE MANUALLY CHANGED)
- EventWrapper
- Persistence
- Take example of Event entity
- You have to update core jsps for Document and Media portlet. Where will you do it.
- You have to implement a solution involving lot of core JSP changes and a custom action what would you do.
- I don’t remember the exact question. but if the question is intending to ask what to do if we have to override multiple JSPs. I think the answer is that the best approach is to have all the customization in one hook.
Some notes
Portlet
Hook
– Generally overrides web resources found int portal-web – asp, jspf, javascript , css, images
– JSPF changes won’t take effect unless you modify the JSP that includes it
– CSS – you have to modify the css which includes it. just changing sub-css won’t work
– Portal Properties
— Model Listeners
— Validators
— Generators
— Content Sanitizers
– Override and define Struts actions
– Override portal services for e.g. MyUserLocalServiceImpl
– Language properties
– Search summaries, indexes and queries (index post processor)
– Servlet filter hooks – pre and post actions
Summary
Hooks are used to modify
– Portal Properties (Not all, only those listed in dtd)
– Language properties
– JSP files
– Index post processor
– Services
– Servlet filter
– Struts action
<!ELEMENT hook (portal-properties?, language-properties*, custom-jsp-dir?,
custom-jsp-global?, indexer-post-processor*, service*, servlet-filter*,
servlet-filter-mapping*, struts-action*)>
Ext
Steps for Application Display templates
- Create a *PortletDisplayHandler
- Register the hander in liferay-portlet.xml using <template-handler> tag
- Assign ADD_PORTLET_DISPLAY_TEMPLATE permissions in resource-actions/default.xml
- In your configuration JSP use <liferay-ui:ddm-template-selector> in the tag classNameId is what specifies your template
- Update view.jsp accordingly
Liferay Portlets Lifecycle
- void init(PortletConfig config) in GenericPortlet and init() in MVCPortlet
- void render(RenderRequest request, RenderResponse response)
- void processAction(ActionRequest request, ActionResponse response)
- void processEvent(EventRequest request, EventResponse response)
- void serveResource(ResourceRequest request, ResourceResponse response)
- void destroy()
GenericPortlet implements Portlet
LiferayPortlet extends GenericPortlet
MVCPortlet extends LiferayPortlet
Liferay Portlets Phases
- Render Phase (168)
- Action Phase(168)
- Event Phase(286)
- Resource Serving Phase(286)
Portlet Modes
- View
- Edit
- Help
Portlet Window States
- Normal
- Maximized
- Minimized
Services Injected by Service Builder
- counterService
- resourceService
- userService