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!!:)

Sunday, 2 September 2012

How To Execute Trigger in Liferay Databases?

A Trigger is a named database object which defines some action that the database should take when some databases related event occurs. Triggers are executed when you issues a data manipulation command like INSERT, DELETE, UPDATE on a table for which the trigger has been created. They are automatically executed and also transparent to the user. But for creating the trigger the user must have the CREATE TRIGGER privilege. In this section we will describe you about the syntax to create and drop the triggers and describe you some examples of how to use them.

How to create triggers ?

Syntax For Create :
CREATE TRIGGER trigger_name trigger_time trigger_event ON tbl_name FOR EACH ROW trigger_statement

Syntax of Drop TRIGGER is :
  DROP TRIGGER mycentral_user_trigger;

Syntax of show all TRIGGER is :
  select trigger_schema, trigger_name, action_statement from information_schema.triggers;

The trigger can associate only with the table name and that must be refer to a permanent table. Trigger_time means trigger action time. It can be BEFORE or AFTER. It is used to define that the trigger fires before or after the statement that executed it. Trigger_event specifies the statement that executes the trigger. The trigger_event can be any of the DML Statement : INSERT, UPDATE, DELETE.

We can not have the two trigger for a given table, which have the same trigger action time and event. For Instance : we cannot have two BEFORE INSERT triggers for same table. But we can have a BEFORE INSERT and BEFORE UPDATE trigger for a same table.

Trigger_statement have the statement that executes when the trigger fires but if you want to execute multiple statement the you have to use the BEGIN?END compound statement.

We can refer the columns of the table that associated with trigger by using the OLD and NEW keyword. OLD.column_name is used to refer the column of an existing row before it is deleted or updated and NEW.column_name is used to refer the column of a new row that is inserted or after updated existing row.

/----- errors display query ------/
show count(*) errors;
show errors;