June 24th, 2010
No Comments
We all work in different environments, development, test (maybe integration) and production servers or, maybe a set of servers that run the same application with different configurations.
Maven helps us build our jar and war components for different environments configuring profiles.
We are going to see here how we can use Maven profiles to build and package Java jar files configured for specific environments.
Popularity: 4% [?]
April 19th, 2010
No Comments
Let’s summarise here how to disable, enable, check, assign values and get selected values from your html document.
1
2
3
4
5
| <select name="client.idClient" id="idClient">
<option value="1">CLIENT 1</option>
<option value="2">CLIENT 2</option>
<option value="3">CLIENT 3</option>
</select> |
You can disable an element by setting the disabled attribute to disabled:
1
| jQuery("#idClient").attr("disabled","disabled"); |
And enable the element by removing the disabled attribute:
1
| jQuery("#idClient").removeAttr("disabled"); |
If the element is an input:
1
| <input type="checkbox" id="yes"/> |
then you have to set the checked attribute to checked:
1
2
| jQuery("#yes").attr("checked","checked");
jQuery("#yes").removeAttr("checked"); |
If you want to set a value for an element in your document:
1
| jQuery("#idClient").val('1'); |
will set the selected option in the dropdown to the value 1.
To get the selected value:
1
| jQuery("#idClient").val(); |
and the selected text:
1
| jQuery("#idClient option:selected").text(); |
Very useful link: jQuery – FAQ
Popularity: 29% [?]
April 16th, 2010
No Comments
Liferay Portal has a JavaScript library that allows the creation of portletURLs inside your JavaScript code. Something like:
<input type="button" value="<liferay-ui:message key="cancel" />"
onclick="<portlet:namespace/>_back();"/>
<script type="text/javascript">
function <portlet:namespace/>_back() {
var backURL = Liferay.PortletURL.createRenderURL();
backURL.setPortletId("");
backURL.setParameter("networkId", ${networkId});
backURL.setPortletMode("view");
location.href = backURL;
}
</script>
All the available methods are (as in Liferay 5.2.3):
- setCopyCurrentRenderParameters: function(copyCurrentRenderParameters);
- setDoAsUserId: function(doAsUserId);
- setEncrypt: function(encrypt);
- setEscapeXML: function(escapeXML);
- setLifecycle: function(lifecycle);
- setName: function(name);
- setParameter: function(key, value);
- setPlid: function(plid);
- setPortletConfiguration: function(portletConfiguration);
- setPortletId: function(portletId);
- setPortletMode: function(portletMode);
- setResourceId: function(resourceId);
- setSecure: function(secure);
- setWindowState: function(windowState);
- toString: function();
And you can create any portlet URL:
- var actionURL = Liferay.PortletURL.createActionURL(); // (‘ACTION_PHASE’);
- var renderURL = Liferay.PortletURL.createRenderURL(); // (‘RENDER_PHASE’);
- var resourceURL = Liferay.PortletURL.createResourceURL(); // (‘RESOURCE_PHASE’);
- var permissionURL = Liferay.PortletURL.createPermissionURL(portletResource, modelResource, modelResourceDescription, resourcePrimKey);
Have a look at the library in
liferay-portal-src-5.2.3/portal-web/docroot/html/js/liferay/portlet_url.js
Popularity: 38% [?]
April 6th, 2010
No Comments
Liferay Hooks are plugins that let you customise some of the Portal functionality.
In this post we are creating a simple Liferay hook to change the value of a property in the portal.properties, override one of the Portal jsps and handling an event.
Popularity: 81% [?]
April 6th, 2010
No Comments
March 18th, 2010
No Comments
Here’s a method to get the month name from the Calendar.MONTH field:
public String getMonthFromInt(int iMonth) {
String month = "invalid";
DateFormatSymbols dfs = new DateFormatSymbols();
String[] months = dfs.getMonths();
if (iMonth >= 0 && iMonth <= 11)
month = months[iMonth];
return month;
}
Popularity: 25% [?]
March 18th, 2010
No Comments
These are – roughly – the steps that you need to follow if you are planing to use the displaytag library in your portlet.
Popularity: 100% [?]