exception handling - How to catch NoSuchLayoutException in Liferay Velocity theme when layout not found? -
i have following code in velocity template theme:
#set($currlayout = $layoutlocalservice.getfriendlyurllayout($group_id, true, $currfriendlyurl))
which throws
com.liferay.portal.nosuchlayoutexception @ com.liferay.portal.service.impl.layoutlocalserviceimpl.getfriendlyurllayout(layoutlocalserviceimpl.java:959)
when matching layout not exist.
how catch exception in velocity template?
to knowledge, not possible catch exceptions inside velocity template. generally, there 2 ways of dealing such situation:
- handle exception in application uses template, such servlet
- avoid throwing exceptions; instead, have method return valid (default) value, or
null
if not possible
the velocity manual recommends use second option whenever possible.
Comments
Post a Comment