Foros de discusión

Portlet stop with ambiguous error

thumbnail
Sandeep Bandhani, modificado hace 6 años.

Portlet stop with ambiguous error

New Member Mensajes: 5 Fecha de incorporación: 6/08/17 Mensajes recientes
Hello everyone,

I am using liferay 7 for portal development, I use service builder to create a finder method and no issue if I search by correct key, then I get a correct result, but the problem is when I input a search key that have no result, then program stop with below message, not as my expectation:
" Your request failed to complete."

Please suggest me how to deal with this problem so that it can return message that I set when have no record found.

Thank you and best regards,
thumbnail
Sandeep Bandhani, modificado hace 6 años.

RE: Portlet stop with ambiguous error

New Member Mensajes: 5 Fecha de incorporación: 6/08/17 Mensajes recientes
is there any ideal for this?

Best regards,
thumbnail
Amos Fong, modificado hace 6 años.

RE: Portlet stop with ambiguous error

Liferay Legend Mensajes: 2047 Fecha de incorporación: 7/10/08 Mensajes recientes
It would be helpful if you can post some code snippets.

For finders that return an object (eg User, NOT a collection), you'll get a NoSuchObjectException if doesn't find anything. If it's expected that there might not be an object returned, instead of the findByXXX, use the fetchByXXX method which will return null if nothing is found.
thumbnail
Sandeep Bandhani, modificado hace 6 años.

RE: Portlet stop with ambiguous error

New Member Mensajes: 5 Fecha de incorporación: 6/08/17 Mensajes recientes
Hello Amos,

Thank for your suggestion!

I think it is NoSuchObjectException if doesn't find anything as you said, but I dont know how to deal with it so that my program wont stop.

I follow some guide to create the finder method like below:
1. Define finder tag and finder columns in Entity Tag
2. Run service Builder
3. Implement Custom method in XXXLocalServiceImpl class
snippets
com.meera.dbservice.model.Student findByGender(int studentGender)
throws com.liferay.portal.kernel.exception.SystemException {
return StudentUtil.findByGender(studentGender, studentAge);
}
4. Run service Builder
5. Call Implemented method using XXXLocalServiceUtil

Do you have any ideal to deal with this?

Thank you and best regards,
thumbnail
Amos Fong, modificado hace 6 años.

RE: Portlet stop with ambiguous error (Respuesta)

Liferay Legend Mensajes: 2047 Fecha de incorporación: 7/10/08 Mensajes recientes
Try creating a new method:

com.meera.dbservice.model.Student fetchByGender(int studentGender)
throws com.liferay.portal.kernel.exception.SystemException {
return XXXPersistence.fetchByGender(studentGender, studentAge);
}

Then run service builder and use that method. It should return a null if nothing is found.

Also, servicebuilder makes the persistence bean is automatically available in the localservice so you can use it directly.
thumbnail
Sandeep Bandhani, modificado hace 6 años.

RE: Portlet stop with ambiguous error

New Member Mensajes: 5 Fecha de incorporación: 6/08/17 Mensajes recientes
Hello Amos,

Thank you very much for your suggestion, it worked.

Thank you and best regards,
Hung Tran