Fórum

Portlet stop with ambiguous error

thumbnail
Sandeep Bandhani, modificado 6 Anos atrás.

Portlet stop with ambiguous error

New Member Postagens: 5 Data de Entrada: 06/08/17 Postagens Recentes
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 6 Anos atrás.

RE: Portlet stop with ambiguous error

New Member Postagens: 5 Data de Entrada: 06/08/17 Postagens Recentes
is there any ideal for this?

Best regards,
thumbnail
Amos Fong, modificado 6 Anos atrás.

RE: Portlet stop with ambiguous error

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
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 6 Anos atrás.

RE: Portlet stop with ambiguous error

New Member Postagens: 5 Data de Entrada: 06/08/17 Postagens Recentes
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 6 Anos atrás.

RE: Portlet stop with ambiguous error (Resposta)

Liferay Legend Postagens: 2047 Data de Entrada: 07/10/08 Postagens Recentes
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 6 Anos atrás.

RE: Portlet stop with ambiguous error

New Member Postagens: 5 Data de Entrada: 06/08/17 Postagens Recentes
Hello Amos,

Thank you very much for your suggestion, it worked.

Thank you and best regards,
Hung Tran