Hi,

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

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3922433#3922433

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3922433


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to