Pages

Hot News

Monday 28 April 2014

How to use Dialog Box (Popup) in Liferay 6.2?

Hi guys,

AlloyUI provide many components for different purposes. These components are very flexible and easy to use.

If you want to create/open DialogBox in liferay 6.2  then you can use the AlloyUI component. 

Lets see example.
  • create portlet.
  • Inside view.jsp put below code

Monday 21 April 2014

How to get string parameter from request when using enctype="multipart/form-data" ?

Hi guys,

Descriptions:

When [ <form> tag ] which has enctype="multipart/form-data"  and also contain additional input type="text" with name="username" and a submit button.

jsp:

<form action="upload" method="post" enctype="multipart/form-data">
User Name: <input type="text" name="username" /><br/>
<input type="file" name="file" />
<input type="submit" value="upload" />
</form>

retrieve string paramName as:
String username = request.getParameter("username"); 
That's prints NULL when form has enctype="multipart/form-data"  If I remove this attributes from the form tag then prints value input by user. 


Whenever a form has enctype="multipart/form-data" . You can not get other form fields by using request.getParameter("paramName");
It will always give you NULL value.

*This problem can be resolved by using below way.

Write the below code in your servlet and get the values of additional formfields :

   List<FileItem> multiparts = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
   String inputName = null;
for(FileItem item : multiparts){
if(!item.isFormField()){   // Check regular field.
String name = new File(item.getName()).getName();
item.write( new File(UPLOAD_DIR + File.separator + name));
}
if(item.isFormField()){  // Check regular field.
inputName = (String)item.getFieldName(); 
if(inputName.equalsIgnoreCase("username")){ 
username = (String)item.getString(); 
        System.out.println("UserName is:"+username); 
}
}
}

That's All !!
Let me know if u have any suggestions/queries, I would like to hear from your side.


















Saturday 19 April 2014

Display Webcontent in JSP?

Hi guys,

There are many way to display webcontent in jsp.
Here, I am explaining  two easiest way.

First Way :
If you are thinking to display web content in JSP page, Its only 2 steps you follow as given below :


Step 1.

Put Below configuration in " portal-ext.properties " :

article.name=YourJournalArticleName
no.actical.text=No Article Exists with this name.

Step 2.
Put Below code inside your jsp.
JSP File : 

<%
String content = StringPool.BLANK;
try{ 
String articleName = PropsUtil.get("article.name");

JournalArticle journalArticle = JournalArticleLocalServiceUtil.getArticleByUrlTitle (themeDisplay.getScopeGroupId(), articleName);
String articleId = journalArticle.getArticleId(); 
JournalArticleDisplay articleDisplay =  JournalContentUtil.getDisplay (themeDisplay.getScoprGroupId(), articleId,"","",themeDisplay);
content = articleDisplay.getContent();
}Catch(Exception e){
content = PropsUtil.get("no.article.text");
}
%>

<%= content %>

*Note: In this way you required to restart server because we have updated portal-ext.properties file.

 ----------------------------------------------------------------------------------------------------------------------------------

Alternate cool option to display webcontent in jsp as:

Follow the list of below steps.
Step 1:

Put below code inside your java class.
For retrieve the wecontentid  and  GroupId.

 long lGroupId = themeDisplay.getScopeGroupId();
String lGroupName = themeDisplay.getScopeGroupName();


JournalArticle jArticleId = JournalArticleLocalServiceUtil.getArticleByUrlTitle(

lGroupId, "webcontentname");

renderReq.setAttribute("lGroupId", lGroupId);
renderReq.setAttribute("jArticleId", jArticleId.getArticleId());

Step 2:

Put below code inside your jsp.


<liferay-ui:journal-article articleId="${jArticleId}"

groupId="${lGroupId}" />

*Note: If we are follow the above way then we don't required to restart the server.

That's all !!

Let me know if u have any suggestions/queries, I would like to hear from your side.

Thursday 17 April 2014

Cognos Integration with Liferay Portal.


There are two easiest way from which we can achieve this things.

1. IFrame
2. WSRP

1. IFrames:
  • This is one of the easier options
  • It is very useful when you have lots of things to expose or to display third party data.
  • It provides loose-coupling between Portal and Cognos so as reports change the Portal doesn't need to change
Implementation way:
  • The portlet will be accessible to logged in user only. Either This portlet has been developed as a custom portlet using Plugins-SDK or OOB Iframe portlet.
  • To display third party data in iframe so used iFrame to achieve this functionality. The information is being fetched by the web services.
  • Using Iframe in cognos-integration-portlet makes it possible to embed another HTML page inside the current page.  
  • Furthermore the user can navigate through the embedded page without loosing the context of the portal page.

The configurations for this portlet are stored in portlet.properties file under WEB-INF/src folder. Here is a reference of the same:

cognos.page.targeturl =
cognos.graphic.format=


2. WSRP:
  • You can expose cognos portlets running on a WebSphere server as a WSRP (Web Services for Remote Portlets) producer.
  • In your portal, you can consume the cognos portlets via the OOB WSRP portlet .
  • This provides a good level of decoupling because the Cognos portlets can run on a separate WAS server from your Portal server.

That's it!!:)