Getting Portlet Instacne Name From JBoss Portal
matw Feb 8, 2006 7:36 PMHi,
I was wondering if it was possible to retrieve the instance name ( given to an instance of a ortlet by the Management Portlet ) of a portlet from JBoss?
I have a portlet which can be told at run time to point to the location of a video feed (multipart jpeg) and display it. I have many instances of this portlet pointing to different video feeds. When i reboot JBoss though the locations are lost because i am storing the location in a class variable. When the objects are reistanciated the location variable goes back to null.
My sneaky solution ( avoiding extra work ) is to name the portlet instances the location which they should be pointing to, when the portlets are displayed i hope to retrieve the intance name, and thus the location of the video feed.
It would also be useful if i could change the name of an instance from inside my portlet too.
My code is shown here. The doEdit method just displays a jsp page with a text input box.
public class ImageViewPortlet extends GenericPortlet {
String imageLocation;
protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, PortletSecurityException, IOException {
renderResponse.setContentType("text/html");
Writer writer = renderResponse.getWriter();
if(imageLocation == null)
imageLocation = "none";
writer.write("<img src=" + imageLocation + "/>");
}
protected void doEdit(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, PortletSecurityException, IOException {
renderResponse.setContentType("text/html");
try {
PortletRequestDispatcher prd = getPortletContext().getRequestDispatcher("/jsp/ImageEdit.jsp");
prd.include(renderRequest, renderResponse);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, PortletSecurityException, IOException {
String imageLocation = actionRequest.getParameter("imageLocation");
this.imageLocation = imageLocation;
actionResponse.setPortletMode(PortletMode.VIEW);
}
}cheers
Mat