Calling OOTB portlet struts actions

General Blogs June 7, 2014 By Sushil Patidar

Many a time it is required to call OOTB portlet struts action from custom portlets.This can be done using the simple approach as follows.

 

public class TestPortlet extends MVCPortlet{
 
 @Override
 public void processAction(ActionRequest actionRequest,
 ActionResponse actionResponse)
 throws IOException, PortletException {
 
    try {
       
        PortletActionInvoker.processAction(
         "com.liferay.portlet.documentlibrary.action.EditFolderAction",                               getPortletConfig(),
          actionRequest, actionResponse);
 
     }
     catch(Exception e) {
 
        e.printStackTrace();
     }
}
 
}

Comma separated multiple Autocomplete in one field

General Blogs June 4, 2014 By Sushil Patidar

As there are lot more improvements in the Alloy UI 2.X . Some attributes have been removed and some are replaced for auto complete. So to implement the comma separeted multiple autocomplete in one field in Alloy UI 1.5 there was attribute delimChar: ','   that have been replaced with queryDelimiter : ','   

In Liferay 6.2 this functionality can be achieved by using the following AUI script.

 

 

<aui:input name="states" type="textarea" ></aui:input>

 

<aui:script use="autocomplete-list,aui-base,autocomplete-filters,autocomplete-highlighters">
 
   var states = [
           {"name":"California"},
           {"name":"Colorado"},
           {"name":"Connecticut"},
           {"name":"Colorado"}
           ]; 
   new A.AutoCompleteList(
       {
        allowBrowserAutocomplete: 'false',
        activateFirstItem: 'true',
        inputNode: '#<portlet:namespace/>states',
        resultTextLocator: 'name',
        resultHighlighter:'phraseMatch',
        resultFilters: ['startsWith'],
        minQueryLength: 2,
        maxResults: 10,
        queryDelimiter : ',',
        render: 'true',
        source:states
   });  
</aui:script>
 

Searching entities through custom attribute value.

General Blogs April 5, 2014 By Sushil Patidar

If you need to search Users who has particular custom attribute value .Using liferay expando API ,this can be acheived easly as follows.

String attrValue ="IT";
 
String attributeName ="user-department-name";
 
String tableName = ExpandoTableConstants.DEFAULT_TABLE_NAME;
 
long classNameId =ClassNameLocalServiceUtil.getClassNameId(User.class);
 
 
List<ExpandoValue> expandoValues =ExpandoValueLocalServiceUtil.getColumnValues(companyId, classNameId, tableName, attributeName, attrValue, -1,-1);
 
 
for(ExpandoValue expandoValue:expandoValues)
 
  try {
      long userId = expandoValue.getClassPK();
      User user  =UserLocalServiceUtil.getUser(userId);
  }
  catch(NoSuchUserException nsue) {
 
   _log.error("No Such User Exist");
  }
}
 

 

Showing 3 results.