WebSphere Portal Server - JSF Portlets: Render a jsp other than the default on switchin a

This is Interesting: Free IT Magazines  
Home > Archive > WebSphere Portal Server > February 2007 > JSF Portlets: Render a jsp other than the default on switchin a





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author JSF Portlets: Render a jsp other than the default on switchin a
Manmeet Gill

2007-02-19, 7:16 pm

Hi all,
In a JSF portlet, on switching the mode, the default jsp(as given in the initialization param of portlet.xml) is rendered. Is there any way we can display another jsp on switchin the mode programatically.

I am using the below code to switch the mode.
------------
ActionResponse resp = (ActionResponse)facesContext.getExternalContext().getResponse();
try{
resp.setPortletMode(PortletMode.EDIT);
}catch(Exception e){
}
return "Edit2";

Init param in portlet.xml
-------------------------
<init-param>
<name>com.ibm.faces.portlet.page.edit</name>
<value>/ModesEdit.jsp</value>
</init-param>

On switching the mode, it takes us to ModesEdit.jsp

But my requirement is to switch the mode and render another jsp as defined in the navigation rules on outcome 'Edit2' which id ModesEdit2.jsp

Is it possible?? Appeciate any response on this.
Pat

2007-02-19, 7:16 pm

you can update the session parameter 'com.ibm.faces.portlet.page.view'. This holds the name of the jsp.
In order to do this you can subclass the faces generic portlet and update the paramter in processAction or in doView (before invoking super.doView)
Same parameter exists for edit, help etc

Another way is to explicitly set a new viewroot, ex in a managed bean

FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot newView = facesContext.getApplication().getViewHandler().createView(facesContext,viewName));
facesContext.setViewRoot(newView);


Manmeet Gill

2007-02-19, 7:16 pm

hi pat,

1. I tried updating the 'com.ibm.faces.portlet.page.view' param. It didnt work. I tried quering the param without setting it. It returns null.

2. I tried using the other approach also, below is the code of the button action class

ActionResponse resp = (ActionResponse)facesContext.getExternalContext().getResponse();
ActionRequest req = (ActionRequest)facesContext.getExternalContext().getRequest();
try{
resp.setPortletMode(PortletMode.EDIT);
}catch(Exception e){

String viewName = "/DummyEdit.jsp";
UIViewRoot newView = facesContext.getApplication().getViewHandler().createView(facesContext,viewName);
facesContext.setViewRoot(newView);
}
return "edit";

yurykats

2007-02-20, 1:28 am

Which version of RAD do you use, 6 or 7?
If you switch to "edit" mode and choose to set the session scope var, it should be .edit, not .view.
Manmeet Gill

2007-02-20, 1:28 am

yeah i tried .edit actually, it didnt work
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com