Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Seeya S Kudtarker
Display data in Liferay Search Container from different database tables
23 de abril de 2013 7:09
Respuesta

Seeya S Kudtarker

Ranking: Regular Member

Mensajes: 187

Fecha de incorporación: 15 de enero de 2013

Mensajes recientes

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
23 de abril de 2013 7:55
Respuesta

Vilmos Papp

LIFERAY STAFF

Ranking: Liferay Master

Mensajes: 521

Fecha de incorporación: 21 de octubre de 2010

Mensajes recientes

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
23 de abril de 2013 8:52
Respuesta

Seeya S Kudtarker

Ranking: Regular Member

Mensajes: 187

Fecha de incorporación: 15 de enero de 2013

Mensajes recientes

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
23 de abril de 2013 22:34
Respuesta

Mohammad Azharuddin

Ranking: Expert

Mensajes: 474

Fecha de incorporación: 17 de septiembre de 2012

Mensajes recientes

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
archivos adjuntos: RankingModel.java (0,4k)
Mohammad Azharuddin
RE: Display data in Liferay Search Container from different database tables
23 de abril de 2013 23:06
Respuesta

Mohammad Azharuddin

Ranking: Expert

Mensajes: 474

Fecha de incorporación: 17 de septiembre de 2012

Mensajes recientes

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