Foros de discusión
Display data in Liferay Search Container from different database tables
Seeya S Kudtarker, modificado hace 10 años.
Display data in Liferay Search Container from different database tables
Regular Member Mensajes: 187 Fecha de incorporación: 16/01/13 Mensajes recientes
I have been using search container in liferay to display data from a table. Works well!! here is a snippet of code:
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
<%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, modificado hace 10 años.
RE: Display data in Liferay Search Container from different database tables
Liferay Master Mensajes: 529 Fecha de incorporación: 21/10/10 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, modificado hace 10 años.
RE: Display data in Liferay Search Container from different database tables
Regular Member Mensajes: 187 Fecha de incorporación: 16/01/13 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
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 azaruddin, modificado hace 10 años.
RE: Display data in Liferay Search Container from different database tables
Expert Mensajes: 492 Fecha de incorporación: 17/09/12 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 reference
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
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 reference
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:
mohammad azaruddin, modificado hace 10 años.
RE: Display data in Liferay Search Container from different database tables
Expert Mensajes: 492 Fecha de incorporación: 17/09/12 Mensajes recientes
JSP page look something like this
ArrayList<RankingModel> ranking = new ArrayList<RankingModel>();
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