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 comes from two different tables
EDITED SECTION WITH REQUIREMENT I have Employee table with some fields I have another table Leave with some Fields. empId is in Leave table which maps to Employee table.
I have a search container whicg displays the data from the Leave table only if the leave is pending I want to display only those fields from Employee table which match with Leave table and satisfy the above condition.
Your problem here has 2 faces:
a) Retrieve results per Leave table, and filter out by employee ID and pending status. Then in each row, use the employeeId to get back again the Employee instance (by EmployeeLocalServiceUtil. getEmployee(empId)), then get Employye attributes, like employee Name etc. This will need to get your hands dirty on the jsp file
b) Create a custom Class (say EmployeePendingLeaves), and use it as the searchContainer's model class. Don't include it in your database model. Just create a function that scans the Employee and Leave tables, and creates a EmployeePendingLeaves instance for each result row. it should have a variable/attribute for each of the row's columns