Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Seeya S Kudtarker
Writing queries in Liferay
March 15, 2013 9:40 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

I have successfully tried getting data from the database and displayed it using search container.

I have also tried using custom query by following the steps mentioned in one of the wikis here but I wasn't successful.

The query which I wan to implement is very simple. I have many columns like empfirstname,empmname,emplastname,dateofbirth etc. in the entity Employee.

I want to display columns empfirstname and emplastname together as one column when I display it in jsp. The sql query for this is
select CONCAT(empFname," ",empLname) as empName from employee;

Is there any way to implement it inn search container? As far as I have tried till now search container displays each column separatly. Is there any way to display two columns together using search container? Or should I go with the steps mentioned to display data using custom queries?
Marco Re
RE: Writing queries in Liferay
March 17, 2013 8:08 AM
Answer

Marco Re

Rank: Junior Member

Posts: 28

Join Date: July 30, 2009

Recent Posts

You don't need custom queries if you want just to concatenate two SQL columns in one search container column.
You can work as presentation level without any problems with something like that:

 1
 2<liferay-ui:search-container-row
 3                    className="your.packages.Employee"
 4                    escapedModel="<%= true %>"
 5                    keyProperty="employeeId"
 6                    modelVar="employee"
 7                >
 8                    <liferay-ui:search-container-column-text
 9                        name="name"
10                        value='<%= employee.getFirstName()+" "+employee.getLastName()  %>'
11                    />
12
13                    ...other columns..
14                </liferay-ui:search-container-row>




Marco
Seeya S Kudtarker
RE: Writing queries in Liferay
March 17, 2013 8:57 PM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

Marco Re:
Thanks for the help. I was trying something like this but wasn't getting the correct results because I was placing the quotes(' , "") in wrong manner.
Thanks again for the help.

Regards,
Seeya S Kudtarker