You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-user@portals.apache.org by Nicolas Kalkhof <nk...@web.de> on 2006/06/25 15:56:26 UTC

portlet communication between JSF bridged portlets

hello folks,

first of all...iŽm pretty new to portlets so please be patient with me ;). iŽd like to build a small portal using the latest pluto-trunk and myfaces/jsf bridges. so far everything seems to be smooth but now iŽm at a point where i want to share data between portlets. example: user presses a logout button in one portlet and all other portlets change their content. how can i get a portlet to do something when i klick a submitbutton in an other portlet?

i guess i have to overwrite generic methods like doView() in my own class. this method is called, whenever a portlet refreshes, right? to achieve that i did the following:

public class LogonAction extends MyFacesGenericPortlet {
....          
public void doView(RenderRequest request, RenderResponse response)
 throws PortletException, IOException {
 super.doView(request, response);
}
}

unfortunately doView() is never called. is this the right way?

my portlet.xml for the portlet described above looks like this:

    <portlet>
        <portlet-name>LogonPortlet</portlet-name>			        
        <init-param>
            <name>ViewPage</name>
            <value>/WEB-INF/jsp/index_nolog.jsp</value>
        </init-param>        
        <init-param>
            <name>default-view</name>
            <value>/WEB-INF/jsp/index_nolog.jsp</value>
        </init-param>
        <init-param>
            <name>HelpPage</name>
            <value>/WEB-INF/jsp/help.jsp</value>
        </init-param>                
        <portlet-class>org.apache.portals.bridges.jsf.FacesPortlet</portlet-class>        
        <expiration-cache>-1</expiration-cache>        
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>HELP</portlet-mode>
        </supports>                
        <portlet-info>
            <title>login</title>
            <short-title>LogonPortlet</short-title>
            <keywords>LogonPortlet</keywords>
        </portlet-info>        
    </portlet>

and my web.xml:

  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>  
  </context-param>  
  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param>  
  <context-param>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>  
  <context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>false</param-value>
  </context-param>

  <filter>
    <filter-name>extensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
      <param-name>uploadMaxFileSize</param-name>
      <param-value>100m</param-value> 
    </init-param>
    <init-param>
      <param-name>uploadThresholdSize</param-name>
      <param-value>100k</param-value>
    </init-param>
  </filter>  
  <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>/PlutoInvoker/LogonPortlet</url-pattern>
  </filter-mapping>  
  
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
  
  <servlet>
    <servlet-name>LogonPortlet</servlet-name>
    <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class>  
    <init-param>
      <param-name>portlet-name</param-name>
      <param-value>LogonPortlet</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  
  <servlet-mapping>
    <servlet-name>LogonPortlet</servlet-name>
    <url-pattern>/PlutoInvoker/LogonPortlet</url-pattern>
  </servlet-mapping>    

any help to get me out of this mess is very much apprechiated. :)

regards,
nicolas
__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach!		
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131


Re: portlet communication between JSF bridged portlets

Posted by Elliot Metsger <em...@jhu.edu>.
Hi Nicolas,

Nicolas Kalkhof wrote:
<snip>

> so far everything seems to be smooth but now
> iŽm at a point where i want to share data between portlets. example:
> user presses a logout button in one portlet and all other portlets
> change their content. how can i get a portlet to do something when i
> klick a submitbutton in an other portlet?

Since the portlet api doesn't define any methods for inter portlet 
communication, you'll need to deal with it on your own.  There are 
probably multiple ways to do this, but the way I've done it in the past 
is to use an application-scoped portlet session variable (or variables). 
  All the portlets monitor the state of the application-scope variable 
and act accordingly.  Ugly, but effective.

> i guess i have to overwrite generic methods like doView() in my own
> class. this method is called, whenever a portlet refreshes, right? 

Thats correct.  If you go the route above - the application-scoped 
portlet session - you'll need some logic in each portlet's doView() 
method which acts according to the value of the session variable.

I'm not familiar with myfaces or jsf bridges so I don't think I can 
offer any advice specific to those technologies.

HTH,
Elliot

Re: portlet communication between JSF bridged portlets

Posted by CD...@hannaford.com.
Nicolas,

As Elliot has suggested, application-scoped portlet session attributes is 
the standard way of dealing with this issue. Michelle Osmond has created 
an open-source library to facilitate doing IPC in a JSR-168 compliant way. 
Check it out at: 
http://www.doc.ic.ac.uk/~mo197/portlets/portlet_messaging/
/Craig




Nicolas Kalkhof <nk...@web.de> 
06/25/2006 09:56 AM
Please respond to
pluto-user@portals.apache.org


To
pluto-user@portals.apache.org
cc

Subject
portlet communication between JSF bridged portlets






hello folks,

first of all...iŽm pretty new to portlets so please be patient with me ;). 
iŽd like to build a small portal using the latest pluto-trunk and 
myfaces/jsf bridges. so far everything seems to be smooth but now iŽm at a 
point where i want to share data between portlets. example: user presses a 
logout button in one portlet and all other portlets change their content. 
how can i get a portlet to do something when i klick a submitbutton in an 
other portlet?

i guess i have to overwrite generic methods like doView() in my own class. 
this method is called, whenever a portlet refreshes, right? to achieve 
that i did the following:

public class LogonAction extends MyFacesGenericPortlet {
.... 
public void doView(RenderRequest request, RenderResponse response)
 throws PortletException, IOException {
 super.doView(request, response);
}
}

unfortunately doView() is never called. is this the right way?

my portlet.xml for the portlet described above looks like this:

    <portlet>
        <portlet-name>LogonPortlet</portlet-name>  
        <init-param>
            <name>ViewPage</name>
            <value>/WEB-INF/jsp/index_nolog.jsp</value>
        </init-param> 
        <init-param>
            <name>default-view</name>
            <value>/WEB-INF/jsp/index_nolog.jsp</value>
        </init-param>
        <init-param>
            <name>HelpPage</name>
            <value>/WEB-INF/jsp/help.jsp</value>
        </init-param> 
 
<portlet-class>org.apache.portals.bridges.jsf.FacesPortlet</portlet-class> 
 
        <expiration-cache>-1</expiration-cache> 
        <supports>
            <mime-type>text/html</mime-type>
            <portlet-mode>VIEW</portlet-mode>
            <portlet-mode>HELP</portlet-mode>
        </supports> 
        <portlet-info>
            <title>login</title>
            <short-title>LogonPortlet</short-title>
            <keywords>LogonPortlet</keywords>
        </portlet-info> 
    </portlet>

and my web.xml:

  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>server</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value> 
  </context-param> 
  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param> 
  <context-param>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param> 
  <context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>false</param-value>
  </context-param>

  <filter>
    <filter-name>extensionsFilter</filter-name>
 
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
      <param-name>uploadMaxFileSize</param-name>
      <param-value>100m</param-value> 
    </init-param>
    <init-param>
      <param-name>uploadThresholdSize</param-name>
      <param-value>100k</param-value>
    </init-param>
  </filter> 
  <filter-mapping>
    <filter-name>extensionsFilter</filter-name>
    <url-pattern>/PlutoInvoker/LogonPortlet</url-pattern>
  </filter-mapping> 
 
  <listener>
 
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
 
  <servlet>
    <servlet-name>LogonPortlet</servlet-name>
    <servlet-class>org.apache.pluto.core.PortletServlet</servlet-class> 
    <init-param>
      <param-name>portlet-name</param-name>
      <param-value>LogonPortlet</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>LogonPortlet</servlet-name>
    <url-pattern>/PlutoInvoker/LogonPortlet</url-pattern>
  </servlet-mapping> 

any help to get me out of this mess is very much apprechiated. :)

regards,
nicolas
__________________________________________________________________________
Erweitern Sie FreeMail zu einem noch leistungsstärkeren E-Mail-Postfach!   
 
Mehr Infos unter http://freemail.web.de/home/landingpad/?mc=021131