Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
l ll
service.xml Collection
February 21, 2012 11:17 PM
Answer

l ll

Rank: Junior Member

Posts: 71

Join Date: December 12, 2011

Recent Posts

The table has three columns: id,userId,status
example

id______userId_______status
1_______100_________1_________true
2_______200_________2_________true
3_______200_________1_________false
4_______200_________2_________true
5_______100_________1_________true
6_______200_________1_________false
7_______300_________1_________false
8_______300_________2_________true


How to make a collection of service.xml, to get the results userId == 100 with any status, otherwise only the status of two ?
David H Nebinger
RE: service.xml Collection
February 22, 2012 6:07 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7157

Join Date: September 1, 2006

Recent Posts

Define two finders, one that does the userId match. After service rebuild, create a method in the package.service.impl.MyServiceLocalServiceImpl class to return a collection using just the two statuses and re-run service builder.
l ll
RE: service.xml Collection
February 24, 2012 2:09 AM
Answer

l ll

Rank: Junior Member

Posts: 71

Join Date: December 12, 2011

Recent Posts

<entity name="Rlist" local-service="true" remote-service="true">
<column name="Id" type="long" primary="true" />
<column name="userId" type="long"></column>
<column name="status" type="int" />

<finder name="S" return-type="Collection">
<finder-column name="status" />
</finder>
<finder name="I" return-type="Collection">
<finder-column name="Id" />
</finder>
<finder name="U" return-type="Collection">
<finder-column name="userId" />
</finder>
</entity>

MyServiceLocalServiceImpl

 1    public List<Rlist> getStatus(int status, int start,
 2            int end, OrderByComparator orderByComparator) throws SystemException{
 3                return rlistPersistence.findByS(status, start, end, orderByComparator);
 4    }
 5   
 6    public int getStatusCount(int status) throws SystemException{
 7        return rlistPersistence.countByS(status);
 8    }
 9   
10    public List<Rlist> getuserid(long userId, int start,
11            int end, OrderByComparator orderByComparator) throws SystemException{
12            
13            return rlistPersistence.findByU(userId, start, end, orderByComparator);
14    }
15   
16    public int getuserCount(int status) throws SystemException{
17        return rlistPersistence.countU(status);
18    }
l ll
RE: service.xml Collection
February 24, 2012 2:14 AM
Answer

l ll

Rank: Junior Member

Posts: 71

Join Date: December 12, 2011

Recent Posts

JSP


 1
 2<liferay-ui:search-container
 3    searchContainer="<%= new RISSearch(renderRequest, iteratorURL) %>"
 4>
 5
 6    <liferay-ui:search-container-results
 7        results="<%= RlistServiceUtil.getStatus(2, searchContainer.getStart(), searchContainer.getEnd(), searchContainer.getOrderByComparator()) %>"
 8        total="<%= RlistServiceUtil.getStatusCount(2) %>"
 9    />
10
11????