IPC / Redirect portal page from a portlet
jferreyram Jun 15, 2010 6:49 PMHello
Because I can't pass a public render parameter (PRP) and redirect to another portal page from my portlet, I'm using javascript to do it. But, at first time this PRP is null, recent works the second time.
The portlet 'A' (located in page '1') set the PRP and call a javascript function which redirect to the page '2' , and portlet 'B' (located in page '2') will receive the public parameter.
Porlet 'A' (located in http://localhost:8080/portal/public/Intralot/home) :
home.xhtml:
<script type="text/javascript"> function redirect(){ SideBar_RedirectUrl = 'http://#{facesContext.externalContext.request.serverName}:#{facesContext.externalContext.request.serverPort}/portal/public/Intralot/home/detail'; setTimeout( "window.location.href = SideBar_RedirectUrl", 1000 ); } </script> <h:commandLink action="#{myBean.detail}" value="A title" onclick="redirect();"> <f:param name="param" value="1"/> </h:commandLink>
MyBean.java:
public String detail(){ try { FacesContext context = FacesContext.getCurrentInstance(); PortletRequest request = (PortletRequest) context.getExternalContext().getRequest(); String parameter = request.getParameter("param"); if(parameter!=null){ this.par = parameter; Object response = context.getExternalContext().getResponse(); if (response instanceof StateAwareResponse) { StateAwareResponse stateResponse = (StateAwareResponse) response; stateResponse.setRenderParameter("prp",parameter); } }else{ System.out.println("Null parameter"); } } catch (Exception e) { } return null; }
Portlet 'B':
MyBean.java:
try { FacesContext context = FacesContext.getCurrentInstance(); PortletRequest request = (PortletRequest) context.getExternalContext().getRequest(); String parameter = request.getParameter("prp"); if (parameter != null && parameter.trim().length()!=0) //using the parameter 'prp' }catch (Exception e) { }
I repeat, this work, except the first time, and don't know why.
Anyone can help me and tell me the reason, please????