Forums de discussion
ServiceBuilder - adding search methods in a custom portlet
Armando Gallo, modifié il y a 14 années.
ServiceBuilder - adding search methods in a custom portlet
New Member Publications: 18 Date d'inscription: 28/12/07 Publications récentes
Hi,
i created an address-book portlet using service builder; In this portlet i can view,add,modify and delete records from my table but i don't know how to develop a search functionality within this portlet.
I checked administration portlet's code (users list) but i can't understand how to report it to my portlet.
I noticed that in the classes generated by service.xml there's no "search" method. In the wiki's section dedicated to servicebuilder i've seen a schema in which the XXXLocalService class has a search method.
Is this method automatically generated by servicebuilder? Maybe I must write something else in the service.xml
Instead, how can i add search functionality to my portlet ?
Thank you
i created an address-book portlet using service builder; In this portlet i can view,add,modify and delete records from my table but i don't know how to develop a search functionality within this portlet.
I checked administration portlet's code (users list) but i can't understand how to report it to my portlet.
I noticed that in the classes generated by service.xml there's no "search" method. In the wiki's section dedicated to servicebuilder i've seen a schema in which the XXXLocalService class has a search method.
Is this method automatically generated by servicebuilder? Maybe I must write something else in the service.xml
Instead, how can i add search functionality to my portlet ?
Thank you
Babu Janarthanan, modifié il y a 14 années.
RE: ServiceBuilder - adding search methods in a custom portlet
Regular Member Publications: 128 Date d'inscription: 31/07/08 Publications récentes
Hi,
which version of liferay you are using.
if you want to add search functionality, you can generate finder method using service.xml
Thx,
Babu
which version of liferay you are using.
if you want to add search functionality, you can generate finder method using service.xml
<finder name="name" return-type="Collection">
<finder-column name="coulmnname" />
</finder>
Thx,
Babu
Armando Gallo, modifié il y a 14 années.
RE: ServiceBuilder - adding search methods in a custom portlet
New Member Publications: 18 Date d'inscription: 28/12/07 Publications récentes
Thanks Babu, I'm using LR 5.2.3 in ext environment
I successfully generated the code with finder tag. I see the "findByName" (more than one) method in AddressBookEntryUtil in 'persistence' package but how can i use it ?
Do i have to develop my search method in xxxlocalserviceutil in which i call findbyname?
Can you post a code for example?
probably, it's easier than it seems but i had no coffee this morning
Thank you
I successfully generated the code with finder tag. I see the "findByName" (more than one) method in AddressBookEntryUtil in 'persistence' package but how can i use it ?
Do i have to develop my search method in xxxlocalserviceutil in which i call findbyname?
Can you post a code for example?
probably, it's easier than it seems but i had no coffee this morning
Thank you
Babu Janarthanan, modifié il y a 14 années.
RE: ServiceBuilder - adding search methods in a custom portlet
Regular Member Publications: 128 Date d'inscription: 31/07/08 Publications récentes
you have to develop a method in your serviceimpl.java, and then access the util method.
assuming that you have given 2 columns in the finder tag.
public List getByName (String abc, String sample) throws PortalException, SystemException {
return AddressBookEntryUtil.findByName(abc, sample);
}
you can take a look @ portal source for more clarity.
Thx,
Babu
assuming that you have given 2 columns in the finder tag.
public List getByName (String abc, String sample) throws PortalException, SystemException {
return AddressBookEntryUtil.findByName(abc, sample);
}
you can take a look @ portal source for more clarity.
Thx,
Babu
Armando Gallo, modifié il y a 14 années.
RE: ServiceBuilder - adding search methods in a custom portlet
New Member Publications: 18 Date d'inscription: 28/12/07 Publications récentes
Hi Babu,
thanks for your reply and example. I'm getting some errors when i call my method;
My code:
in AddressBookLocalServiceUtil.java
and then in view_address.jsp:
I'm getting this error:
what's my fault?
thank you
thanks for your reply and example. I'm getting some errors when i call my method;
My code:
in AddressBookLocalServiceUtil.java
public static List<addressbookentry> getByName(String title)
throws PortalException, SystemException {
return AddressBookEntryUtil.findByTitle(title);
}
</addressbookentry>
and then in view_address.jsp:
List<addressbookentry> addresses = (List<addressbookentry>)AddressBookLocalServiceUtil.getByName("a string");
</addressbookentry></addressbookentry>
I'm getting this error:
Caused by: org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at com.liferay.portal.spring.hibernate.SessionFactoryInvocationHandler.invoke(SessionFactoryInvocationHandler.java:68)
at $Proxy1.getCurrentSession(Unknown Source)
at com.liferay.portal.dao.orm.hibernate.SessionFactoryImpl.openSession(SessionFactoryImpl.java:61)
at com.liferay.portal.service.persistence.impl.BasePersistenceImpl.openSession(BasePersistenceImpl.java:70)
at com.ext.portlet.addressbook.service.persistence.AddressBookEntryPersistenceImpl.findByTitle(AddressBookEntryPersistenceImpl.java:754)
at com.ext.portlet.addressbook.service.persistence.AddressBookEntryUtil.findByTitle(AddressBookEntryUtil.java:147)
at com.ext.portlet.addressbook.action.AddressBookLocalServiceUtil.getByName(AddressBookLocalServiceUtil.java:95)
at org.apache.jsp.html.portlet.ext.address_005fbook.view_005faddress_jsp._jspService(view_005faddress_jsp.java:702)
.....
....
....
more and more
what's my fault?
thank you
Babu Janarthanan, modifié il y a 14 années.
RE: ServiceBuilder - adding search methods in a custom portlet
Regular Member Publications: 128 Date d'inscription: 31/07/08 Publications récentes
you should write your code in AddressBookLocalServiceImpl.java.
public static List<AddressBookEntry> getByName(String title)
throws PortalException, SystemException {
......
}
public static List<AddressBookEntry> getByName(String title)
throws PortalException, SystemException {
......
}
Navin Singh, modifié il y a 11 années.
RE: ServiceBuilder - adding search methods in a custom portlet
New Member Publications: 8 Date d'inscription: 14/11/11 Publications récentes
As per you guys' instructions, I was able to successfully implement search indexing and open search on my custom portlet. It indexes my portlet data when running re-index process. But I have problem now, when I try to search, it gives me an exception stating "Error displaying content of type liferay open search... ", any help will be really appreciated.