mua nha bien hoa
Tự viết một hàm trong liferay 6.0.x
Bước 1:
Trong package: com.fpt.portlet.parameter.service.persistence ta thêm một class parameterFinderImpl
packagecom.fpt.portlet.parameter.service.persistence;
importcom.liferay.portal.service.persistence.impl.BasePersistenceImpl;
public class parameterFinderImplextends BasePersistenceImplimplements parameterFinder {
}
Bước 2: Build file Service.xml của portlet để ant tự động sinh các class có liên quan
Bước 3 : thực hiện viết một hàm trong class parameterFinderImpl
Bước 4: bổ xung hàm vừa viết vào class parameterLocalServiceImpltrong package: com.fpt.portlet.parameter.service.impl
Hàm này sẽ gọi đến Persistence.callfunctionname
/*ducdv write this code*/
publicList<definitionField> getDefinitionFieldByIdTemplate(long idTemplate) throwscom.liferay.portal.kernel.exception.SystemException{
return definitionFieldPersistence.findByidTemplate(idTemplate);
}
Bước 5: Build file Service.xml của portlet để ant tự động sinh các class có liên quan
Bước 6: Có thể gọi hàm từ action qua parameterLocalServiceUtil.java
Viết finder trong portlet
Muấn gọi được finder từ action thì phải làm các bước sau
1. Viết một hàm trong …….LocalServiceImp
Hàm này sẽ gọi đến Persistence.callfunctionname
/*ducdv write this code*/
publicList<definitionField> getDefinitionFieldByIdTemplate(long idTemplate) throwscom.liferay.portal.kernel.exception.SystemException{
return definitionFieldPersistence.findByidTemplate(idTemplate);
}
2. Bước tiếp theo ta build lại fiel service.xml
3. Bây giờ ta có thể gọi từ action đươc
4. Chúc các bạn thành công
Không có nhận xét nào:
Đăng nhận xét