Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Seeya S Kudtarker
Display data in Liferay Search Container from different database tables
April 23, 2013 7:09 AM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

I have been using search container in liferay to display data from a table. Works well!! here is a snippet of code:

<%List<testapp> pendingApprovals = ActionClass.getPendingLeaveApplications();

<liferay-ui:search-container delta="20" emptyResultsMessage="No Results Found">
<liferay-ui:search-container-results total="<%= pendingApprovals.size() %>"
results="<%= ListUtil.subList(pendingApprovals , searchContainer.getStart(), searchContainer.getEnd()) %>" />
<liferay-ui:search-container-row keyProperty = "empId" modelVar="search"
className="com.test.mis.portal.model.testapp">
<liferay-ui:search-container-column-text name='Leave Duration' value = '<%=String.valueOf(search.getLeaveDuration())%>' href="" />

</liferay-ui:search-container-row>
<liferay-ui:search-iterator/>
</liferay-ui:search-container>



Using the above code I display data from the testapp table based on some condition. In the same code I would like to add a row and display data. The data for this row should come from another table. In short I want to display data using search container from two different database tables. Is it possible to do? My requirement is such that data should come from two different database tables in the same display table
Vilmos Papp
RE: Display data in Liferay Search Container from different database tables
April 23, 2013 7:55 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Liferay Master

Posts: 521

Join Date: October 21, 2010

Recent Posts

Basically I think it's not possible to make the join the way you want, but you could write your custom finder and use the joined results as input for the search container. At least, I would try to go this way.
Seeya S Kudtarker
RE: Display data in Liferay Search Container from different database tables
April 23, 2013 8:52 AM
Answer

Seeya S Kudtarker

Rank: Regular Member

Posts: 187

Join Date: January 15, 2013

Recent Posts

Vilmos Papp:

Thanks Vilmos for your reply.
Well even I was thinking the same because we provide the specific clasName.
Including a search container within a search container gives a different display table altogether.

Thanks for the custom finder suggestion.

Regards

Seeya
Mohammad Azharuddin
RE: Display data in Liferay Search Container from different database tables
April 23, 2013 10:34 PM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 471

Join Date: September 17, 2012

Recent Posts

Hi
Write pojo(model) class to display data from two table in single search container.
ie create simple java class with instance variable, getters and setters.check the attached file for referenceemoticon

1)In jsp, create new arraylist ex:ArrayList<RankingModel> developerRanking = new ArrayList<RankingModel>();
2)loop through two list, from two different table..
3)create object of pojo class.use setter to set the value. and finally add the pojo object in the list
Attachments: RankingModel.java (0.4k)
Mohammad Azharuddin
RE: Display data in Liferay Search Container from different database tables
April 23, 2013 11:06 PM
Answer

Mohammad Azharuddin

Rank: Expert

Posts: 471

Join Date: September 17, 2012

Recent Posts

JSP page look something like this

ArrayList<RankingModel> ranking = new ArrayList<RankingModel>();



Loop through your list and
Inside the for loop
RankingModel rankingModelObject = new RankingModel();
rankingModelObject .setName(//pass the name here);
rankingModelObject .setEfficiency(//pass the Efficiency value here );
ranking .add(rankingModelObject );// add to list