views:

527

answers:

2

I've written a fairly basic portlet using the struts portlet bridge and deployed it to liferay, navigation within my portlet seems fine, but whenever I click a link on another portlet in the portal my portlet reverts to the view action setup in my portlet.xml rather than re-rendering the existing state. What am I doing wrong?

My portlet.xml is:

<?xml version="1.0"?>

<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"&gt;
  <portlet>
    <portlet-name>test</portlet-name>
    <display-name>Test</display-name>
    <portlet-class>com.perceptive.ctms.test.portlet.TestPortlet</portlet-class>

    <init-param>
      <name>ServletContextProvider</name>
      <value>com.liferay.util.bridges.struts.LiferayServletContextProviderWrapper</value>
    </init-param>
    <init-param>
      <name>StrutsPortletConfigLocation</name>
      <value>/WEB-INF/struts-portlet-config.xml</value>
    </init-param>
    <init-param>
      <name>HelpPage</name>
      <value>/portlet_action/test/help</value>
    </init-param>
    <init-param>
      <name>ViewPage</name>
      <value>/portlet_action/test/start</value>
    </init-param>
    <init-param>
      <name>EditPage</name>
      <value>/portlet_action/test/preferences</value>
    </init-param>

    <expiration-cache>0</expiration-cache>
    <supports>
      <mime-type>text/html</mime-type>
      <portlet-mode>view</portlet-mode>
      <portlet-mode>edit</portlet-mode>
      <portlet-mode>help</portlet-mode>
    </supports>
    <portlet-info>
      <title>Test</title>
      <short-title>Test</short-title>
      <keywords>Test</keywords>
    </portlet-info>
  </portlet>

  <filter>
    <filter-name>AuthenticationFilter</filter-name>
    <filter-class>com.perceptive.ctms.framework.portlet.filter.AuthenticationFilter</filter-class>
    <lifecycle>RENDER_PHASE</lifecycle>
    <lifecycle>ACTION_PHASE</lifecycle>
  </filter>

  <filter-mapping>
    <filter-name>AuthenticationFilter</filter-name>
    <portlet-name>test</portlet-name>
  </filter-mapping>
</portlet-app>

and struts-portlet-config.xml is:

<?xml version="1.0" encoding="UTF-8"?>

<config>
  <render-context>
    <attribute name="errors"/>
    <attribute name="message" keep="true"/>
    <attribute prefix="com.perceptive" keep="true"/>
  </render-context>
  <portlet-url-type default="render">
    <render path="/test/help.do"/>
    <render path="/test/start.do"/>
    <render path="/test/preferences.do"/>
    <render path="/test/tableTest.do"/>
    <render path="/test/displayTagTest.do"/>
    <render path="/test/lookupTest.do"/>
    <render path="/test/lookupTestSave.do"/>
  </portlet-url-type>
</config>

PS I've already asked this on the liferay forums, but am asking here as well in the hope of a quick answer.

+2  A: 

In the portlet.xml try changing the line:

<expiration-cache>0</expiration-cache>

which means the cached version of the portlet expires immediately to:

<expiration-cache>-1</expiration-cache>

which means it never expires. From the portlet-app_2_0.xsd:

    <annotation>
  <documentation>
  Expiration-time defines the time in seconds after which the portlet output expires. 
  -1 indicates that the output never expires.
  Used in: portlet
  </documentation>
 </annotation>
Tella
Aargh! I knew the answer was staring me in the face
Steve Bosman
A: 

Hi Steve, Tella, I get the following error when i use expiration-cache in my jsr-286 portlet, with Inter portlet communication implementation in it. Any suggestions ?

15:49:28,166 ERROR [PortletLocalServiceImpl:542] com.liferay.portal.kernel.xml.DocumentException: Error on line 45 of document : cvc-complex-type.2.4.a: Invalid content was found starting with element 'expiration-cache'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-publishing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected. Nested exception: cvc-complex-type.2.4.a: Invalid content was found starting with element 'expiration-cache'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-publishing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected. com.liferay.portal.kernel.xml.DocumentException: Error on line 45 of document : cvc-complex-type.2.4.a: Invalid content was found starting with element 'expiration-cache'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-publishing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected. Nested exception: cvc-complex-type.2.4.a: Invalid content was found starting with element 'expiration-cache'. One of '{"http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-publishing-event, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":supported-public-render-parameter, "http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd":container-runtime-option}' is expected. at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:377) at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:388) at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:156) at com.liferay.portal.service.impl.PortletLocalServiceImpl._readPortletXML(PortletLocalServiceImpl.java:1281) at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:477) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy49.initWAR(Unknown Source) at com.liferay.portal.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:184) at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:230) at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:127) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:108) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:153) at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:43) at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(PortletContextListener.java:113) at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitableUtil.java:48) at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:109) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117) at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610) at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590) at java.lang.Thread.run(Thread.java:619) 15:49:28,198 INFO [PortletHotDeployListener:351] 0 portlets for abc-search-portlet are available for use

Sam