how to set portlet load order in liferay portlets - liferay

I have around 4 portlets and 2 web content on my page. Among 4 portlets, one is custom portlet. my requirement is like I need to load my custom portlet at the end.
I got to know we can set this by adding following entry in liferay-portlet.xml
<render-weight>0</render-weight>
from liferay-portlet-app_6_2_0.dtd I got to know
, The default value of render-weight is 1. If set to a value less than 1, the
portlet is rendered in parallel. If set to a value of 1 or greater, then the
portlet is rendered serially. Portlets with a greater render weight have greater
priority and will be rendered before portlets with a lower render weight.
My question is, how can i set render weight of liferay portlets. Do i need to do entry in some properties file or i can achieve this using control panel.

There is no guarantee of render order and you shouldn't change any state in the render phase - in fact no state change (e.g. public render parameter etc) is propagated, if only because you can't even change them on RenderRequest/RenderResponse.
If you rely on the assumption of a specific rendering order, you should rather change the architecture so that this assumption is no longer required. If your portlet takes some time to render, you can have it display asynchronously (e.g. like the built-in RSS portlet). If I remember correctly this is done by setting <render-weight> to 0 and <ajaxable> to true in liferay-portlet.xml

Related

Pass parameters to a computed custom control

I'm using the xp:include tag for displaying custom controls according business rules.
I configured my custom controls with parameters (the custom prperties) that I used through the compositeData syntax.
My question is :
How can I declare the computed xpages for passing arguments to my custom control ?
Switch control or Dynamic Content Control may be a better option to choose. The difference is Switch control loads all facets into the component tree, Dynamic Content Control only loads the current facet to be displayed. So if they're specific to different parts in the business process, Dynamic Content Control may be more suitable.
Alternatively, use different XPages for different stages in the business process. With XPages links from views can be computed to go to a specific XPage rather than a single one defined for the form.

Navigation after IPC in Liferay

we want to navigate in Liferay to an other portlet after receiving a IPC-Event.
So we send the event from one portlet, implemented an second Portlet extends from MVCPortlet, and receive the event with some information!
So we want to navigate in Liferay to the second portlet.
The methode were we receive the event is this
#ProcessEvent(qname = "{http://liferay.com}empinfo")
public void handleProcessempinfoEvent(final javax.portlet.EventRequest request, final javax.portlet.EventResponse response) throws javax.portlet.PortletException, java.io.IOException
Also we override the methods from com.liferay.util.bridges.mvc.MVCPortlet but no one was called after sending the event.
Is there any way to navigate inside liferay (6.1.2)?
Thx Tim
Is the event handled at all? What do you mean with "navigate to the second portlet"?. Events - by default - only get distributed to the portlets that appear on the same page. If you want to receive an event on a portlet that exists on a different page, you'll have to explicitly configure Liferay to distribute events to all pages in the same site. Note that this might dig into your performance. Also - once you navigate to another page - by default the portlet's state on that page is being reset.
Check the following (and related) portal.properties:
#
# Set this property to specify how events are distributed. If the value is
# "layout-set", then events will be distributed to all portlets contained in
# a layout set. If the value is "layout", then events will be distributed to
# all portlets that are present in a layout.
#
portlet.event.distribution=layout
#
# Set this property to specify how public render parameters are distributed.
# If the value is "layout-set", then public render parameters will be
# distributed to all portlets contained in a layout set. This will only work
# correctly if the property "layout.default.p_l_reset" is set to false. If
# the value is "layout", then public render parameters will be distributed
# to all portlets that are present in a layout.
#
portlet.public.render.parameter.distribution=layout
#
# Set the default value for the "p_l_reset" parameter. If set to true,
# render parameters are cleared when different pages are hit. This is not
# the behavior promoted by the portlet specification, but is the one that
# most end users seem to prefer.
#
layout.default.p_l_reset=true
If you intend to navigate to a different page, you'll also have to note that this is not covered by the portlet API. Thus you'll have to identify how to find the relevant page, its URL and how to redirect. It's probably easier to have some more logic in the action-handling portlet and do the redirect there: At least you'll only handle one action. Potentially there might be several Events handled per Action - thus it's undefined which potential redirect will be triggered if they conflict. I'd see a real redirect (any way) as rather unexpected behavior if it comes from an EventHandler, but somewhat understandable from an ActionHandler.

Xpages add a custom control that doesn't take up space (rendered versus loaded versus visible)

I have some custom controls that I want to include in Xpages, but I don't want them to be visible to the user or to take up space on the screen, as it is throwing my alignment off. I have looked at the properties rendered, loaded, and visible, but I don't really understand them and they don't seem to do what I want, which is to include some functionality but not change the layout.
I am sure there is a way to do this, but I can't figure it out.
Loaded means it won't be added to the component tree and only affects server-side functionality. Because it's not in the component tree (the server-side map of the page) it can't be passed to the browser or processed during partial refreshes. Rendered and visible are the same and mean they're in the component tree, so server-side processing can interact with them, but no HTML is passed to the browser for them. So you can't interact with them via CSJS. If you want it passed to the browser, available for CSJS but not visible to the user, you'll need to set the style as display:none. Another option is to put that style in a theme and allocate the themeId you choose to your custom control.

Placement of portlets on a liferay page

I am using 1-2 Columns (70-30) layout for the page in liferay. The problem that I am facing is that I am not able to place them properly in 1-2 columns form even after dragging them properly on the page. I am making use of web content portlets. The portlet that should be placed on '30' side;its data appears the way I want on the RHS but the portlet window covers the entire screen. How should I place the portlets to get the exact 1-2 columns layout?
EDIT:
Is it possible to place a portlet over another portlet?
If the portlets that you are trying to place are custom portlets, It may be worth checking if custom css width property forcing portlet to occupy more width than supposed.
You can't place one portlet over another portlet. But "Nested Portlet" can be used to include more than one portlet in their own layout.
As you don't have public URL, I can only suggest steps to debug your issue.
Login to portal as Administrator.
Create a new page.
Apply liferay default classic theme to the page and apply 70-30 layout.
Add one Web content display portlet instance in column 1 and another in column 2.
Checkpoint: Enable Edit checkbox and see if the default portlet boundaries are occupying width they are supposed to take. If yes, then your liferay default working fine.
Checkpoint: Select your web content article and see if width of display changes. If Yes, then the problem is with with your web content article.
Checkpoint: Apply your theme and then see the issue. Then issue may be with your custom css files in _diff folder.
Use Firebug in Firefox or chrome dom viewer (F12 in chrome window) and observe which CSS style is causing the issue.

Can you compute which custom control to use?

Think "computed subform", but in Xpages.
On one of my custom controls, depending on a certain value, I want to either present a custom control that renders a drop-down list using a combobox or renders an input box with a type-ahead.
This is on a custom control that renders a view, with all view configuration choices handled by a document rather than design, so several different views utilize the same custom control.
For example: I have a By Status view using the custom control that has status as the first column and we use a combobox to allow the user to select which Status value to filter by. Another view is sorted by Requisition number and I want to use a type-ahead instead of the combobox.
My preference is to use the same dynamic view custom control for both and have a formula that determines which of the two (comboBox or inputText) to use. How do I compute which custom control to load?
(Credit for the dynamic view control goes to Scott Good's folks over at Teamworks Solutions.)
During it's life cycle, an XPage exists in two places. First of all a representation of the XPage's relevant components is stored on the server. Then the page goes through a lifecycle, retrieving properties from documents, checking which components should be rendered, retrieving the data for any repeating control such as a View Panel etc., and passing the relevant HTML to the browser. The browser is the second place it exists.
So you can't compute a custom control as such. All you can do is set the loaded property, and loaded needs to be based on a non-dynamic calculation such as a viewScope variable, the current XPage name, a view name stored on the XPage etc. What you would have difficulty doing would be using a different custom control based on data on that row entry.
The other option is the Dynamic Content control or Switch control from the Extension Library. Both are similar to using the loaded property, in that you're putting both custom controls on the page and choosing which to display.
From what you're describing, the loaded property should cover what you need.
Some time back I saw this question on StackOverflow where the author had used Include Page control (xp:include) to include custom controls using pageName attribute based on formula.
<xp:include>
<xp:this.pageName><![CDATA[${javascript:sessionScope.ccPageName + ".xsp";}]]> </xp:this.pageName>
</xp:include>
Similar to the technique described by Paul Withers in his answer the attribute of pageName is also computed on page load.

Resources