views:

157

answers:

2

Hi,

is there a way to provide my spring portlets a default state which is resolved if a unavailable expcetion occurs?

I recieve this exception

10:24:53,187 ERROR [517: org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl] The portlet threw an exception
javax.portlet.UnavailableException: No matching handler method found for portlet request: mode 'view', phase 'ACTION_PHASE', parameters map[[empty]]
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter$PortletHandlerMethodResolver.resolveHandlerMethod(AnnotationMethodHandlerAdapter.java:488)
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:354)
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.doHandle(AnnotationMethodHandlerAdapter.java:345)
    at org.springframework.web.portlet.mvc.annotation.AnnotationMethodHandlerAdapter.handleAction(AnnotationMethodHandlerAdapter.java:280)
    at org.springframework.web.portlet.DispatcherPortlet.doActionService(DispatcherPortlet.java:646)
    at org.springframework.web.portlet.FrameworkPortlet.processRequest(FrameworkPortlet.java:519)
    at org.springframework.web.portlet.FrameworkPortlet.processAction(FrameworkPortlet.java:460)

I would like to catch this exception and return simply the default "VIEW" state or something.

*-portlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
        <context:annotation-config/>
        <!-- Controllers -->
        <bean id="portletController" class="de.nv.spring.portlets.PortletController"/>

        <!-- Handler Mappings -->
        <bean class="org.springframework.web.portlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
</beans>
A: 

Do you have a default rendering/action -methods? For me the following default rendering method works:

@RenderMapping(params="!render")
public String defaultRender(RenderRequest req, RenderResponse res, Model model) throws PortalException, SystemException {
   // do something
}

The annotation value !render means that this is run if there exists no render-parameter. Intuitively, you could use the same approach on your action-parameter.

heikkim