List Info

Thread: serialize a form bean using portlet bridges




serialize a form bean using portlet bridges
user name
2006-07-31 18:44:47
hi,

maybe you´re right. but if i don´t extend from facesportlet
the portlet cannot be rendered since there is no doView() to
call. so where´s the catch?  maybe you can shed some light
on this issue, please?

regards,
nicolas

> -----Ursprüngliche Nachricht-----
> Von: "MyFaces Discussion" <usersmyfaces.apache.org>
> Gesendet: 31.07.06 20:39:02
> An: "MyFaces Discussion" <usersmyfaces.apache.org>
> Betreff: Re: serialize a form bean using portlet
bridges

I think u are starting to use JSF for portlet development in
wrong way, your backing beans doensn't need extends from
FacesPortlet.
> 
> 
> 2006/7/31, Nicolas Kalkhof <
> nkalkhofweb.de>:hi folks,
> 
> is there a way to serialize a formbean(backingbean)
using the myfaces portlet brigde? i need to validate input
values during a tabbed pane switch. so far the
TabChangeListener seems to fire on every tab switch but the
backingbean cannot be serialized and therefore i cannot
access the input fields when the TabChangeListener fires.
> 
> 
> or is there another way to accomplish this????
> 
> so far i wasnŽt successful using:
> 
> public class UserProfileBean extends FacesPortlet
implements Serializable, TabChangeListener {
> ...
> }
> 
>
org.apache.portals.bridges.jsf.PortletExternalContextImpl
>  is not serializable.
> 
> any help is very much apprechiated.
> 
> best regards,
> nicolas
>
____________________________________________________________
_________
> Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer
Onlinekosten zu sparen!
> 
> http://smartsurfer.web.de/?mc=100071&dis
tributionid=000000000071
> 
> 
> 
> 
> -- 
> Yours truly (Atenciosamente),
> 
> 
> Rogério
> 


____________________________________________________________
__
Verschicken Sie romantische, coole und witzige Bilder per
SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193


serialize a form bean using portlet bridges
user name
2006-07-31 18:47:52
My Portlet class is something like this:

package br.eti.faces.mail;

import java.io.IOException;

import javax.portlet.PortletException;
import javax.portlet.PortletMode ;
import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;

import org.apache.myfaces.portlet.MyFacesGenericPortlet ;

public class MailPortlet extends MyFacesGenericPortlet {

 &nbsp;  private String viewPage = null;
&nbsp; &nbsp; private String editPage = null;
&nbsp; &nbsp; private String helpPage = null;

&nbsp; &nbsp; public void init() throws UnavailableException, PortletException {
 &nbsp;   &nbsp;  viewPage = (String) this.getInitParameter("ViewPage");
 &nbsp;   &nbsp;  editPage = (String) this.getInitParameter("EditPage");
 &nbsp;   &nbsp;  helpPage = (String) this.getInitParameter("HelpPage");
 &nbsp;   &nbsp;  super.init();
 &nbsp;  }

 &nbsp;  public void render(RenderRequest request, RenderResponse response)
 &nbsp;  throws PortletException, IOException {
 &nbsp;   &nbsp;  PortletSession session = request.getPortletSession ();
&nbsp; &nbsp;  &nbsp;  PortletMode mode = (PortletMode)session.getAttribute("CurrentPortletMode");

 &nbsp;   &nbsp;  if (mode == null) {
 &nbsp;   &nbsp;   &nbsp;  mode = request.getPortletMode(); &nbsp;   
 &nbsp;   &nbsp;  }

 &nbsp;   &nbsp;  if (!mode.equals( request.getPortletMode())) {
 &nbsp;   &nbsp;   &nbsp;  request.setAttribute("isPortletModeChanged", Boolean.TRUE);
   ;  &nbsp;  } else {
 &nbsp;   &nbsp;   &nbsp;  request.setAttribute("isPortletModeChanged", Boolean.FALSE);
&nbsp; &nbsp;  &nbsp;  }

 &nbsp;   &nbsp;  session.setAttribute("CurrentPortletMode", request.getPortletMode());
 ; &nbsp;  &nbsp;  super.render(request, response);
 &nbsp;  } &nbsp; 
 &nbsp; 
 &nbsp;  protected void setDefaultView() throws UnavailableException {
 &nbsp;   ; &nbsp; this.defaultView = getPortletConfig().getInitParameter(DEFAULT_VIEW);
&nbsp; &nbsp; &nbsp;   if (defaultView == null) {
 &nbsp; &nbsp;   ;  &nbsp;  this.defaultView = this.viewPage;
   ; &nbsp; &nbsp; }
 &nbsp; &nbsp;   ; if (defaultView == null) {
 &nbsp;   ; &nbsp; &nbsp; &nbsp; String msg = "Fatal2: must specify a JSF view id as the default view in portlet.xml";
&nbsp; &nbsp;   ; &nbsp; &nbsp;  throw new UnavailableException(msg);
 ; &nbsp; &nbsp; &nbsp; }
 &nbsp;  } &nbsp; 

 &nbsp;  protected void doEdit(RenderRequest request, RenderResponse response)
 &nbsp;  throws PortletException, IOException {

 &nbsp;   &nbsp;  Boolean isPortletModeChanged = (Boolean) request.getAttribute("isPortletModeChanged");
 &nbsp;   &nbsp;  if (isPortletModeChanged.booleanValue()) {
 &nbsp;   &nbsp;   &nbsp;  setPortletRequestFlag(request);
 &nbsp;   &nbsp;   &nbsp;  nonFacesRequest(request, response, editPage);
 &nbsp;   &nbsp;   &nbsp;  return;
&nbsp; &nbsp;  &nbsp;  }

 &nbsp;   &nbsp;  facesRender(request, response);
 &nbsp;  }

 &nbsp;  protected void doHelp(RenderRequest request, RenderResponse response)
 &nbsp;  throws PortletException, IOException {

 &nbsp;   &nbsp;  Boolean isPortletModeChanged = (Boolean) request.getAttribute("isPortletModeChanged");
 &nbsp;   &nbsp;  if (isPortletModeChanged.booleanValue()) {
 &nbsp;   &nbsp;   &nbsp;  setPortletRequestFlag(request);
 &nbsp;   &nbsp;   &nbsp;  nonFacesRequest(request, response, helpPage);
 &nbsp;   &nbsp;   &nbsp;  return;
&nbsp; &nbsp;  &nbsp;  }

 &nbsp;   &nbsp;  facesRender(request, response);
 &nbsp;  } &nbsp; 
}


And the bean used in the page in View mode is this:

package br.eti.faces.mail;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Serializable ;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Properties;

import javax.faces.context.FacesContext;
import javax.portlet.PortletPreferences;
import javax.portlet.RenderRequest ;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * author <a href=";mailto:gmail.com">rogerio.araujogmail.com">Rogerio P. Araujo</a>
&nbsp;*/
public class MailView implements Serializable
{
   ; static final long serialVersionUID = 1l;
   ;
 &nbsp;  private static Log log = LogFactory.getLog(MailView.class);
 &nbsp; 
 &nbsp;  private String  &nbsp;  usuario;
  ;  private String  &nbsp;  senha;
&nbsp; &nbsp;
 &nbsp;  private ArrayList&lt;Mensagem> &nbsp;  mensagens;
 &nbsp; 
 &nbsp;  private String mensagem;
  
 &nbsp;  public MailView()
 &nbsp;  {

 &nbsp;  }
 &nbsp; 
 &nbsp;  public String verificar()
 &nbsp;  {
 &nbsp;   &nbsp;  return null;
&nbsp; &nbsp; }

 &nbsp;  public ArrayList&lt;Mensagem> getMensagens() {
 &nbsp;   &nbsp;  return mensagens;
 &nbsp;  }

 &nbsp;  public void setMensagens(ArrayList<Mensagem> mensagens) {
 &nbsp;   &nbsp;  this.mensagens = mensagens;
 &nbsp;  }

 &nbsp;  public String getSenha() {
 &nbsp;   &nbsp;  return senha;
&nbsp; &nbsp; }

 &nbsp;  public void setSenha(String senha) {
 &nbsp;   &nbsp;  this.senha = senha;
&nbsp; &nbsp; }

 &nbsp;  public String getUsuario() {
 &nbsp;   &nbsp;  return usuario;
&nbsp;   }

 &nbsp;  public void setUsuario(String usuario) {
 &nbsp;   &nbsp;  this.usuario = usuario;
&nbsp;   }

 &nbsp;  public String getMensagem() {
 &nbsp;   &nbsp;  return mensagem;
  ;  }

 &nbsp;  public void setMensagem(String mensagem) {
 &nbsp;   &nbsp;  this.mensagem = mensagem;
  ;  }
}

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )