1 9 package org.jboss.portlet; 10 11 import org.jboss.portal.portlet.impl.RenderResponseImpl; 12 import org.jboss.portal.portlet.impl.PortletURLImpl; 13 import org.jboss.portal.server.PortalRequest; 14 import org.jboss.portal.server.PortalResponse; 15 import org.jboss.portal.server.Window; 16 import org.jboss.portal.server.WindowContext; 17 import org.jboss.portal.server.WindowURL; 18 import org.jboss.portal.server.output.FragmentResult; 19 import org.jboss.portal.server.util.Properties; 20 21 import javax.portlet.PortletURL; 22 import java.lang.reflect.Field ; 23 24 28 public class JBossRenderResponse extends RenderResponseImpl 29 { 30 public JBossRenderResponse( 31 Window window, 32 WindowContext windowContext, 33 PortalRequest req, 34 PortalResponse resp, 35 FragmentResult result, 36 Properties properties) 37 { 38 super(window, windowContext, req, resp, result, properties); 39 } 40 41 44 public String createAbsoluteURL(PortletURL url) 45 { 46 return createAbsoluteURL(resp, url); 47 } 48 49 51 static String createAbsoluteURL(PortalResponse resp, PortletURL url) 52 { 53 if (url == null) 54 { 55 throw new IllegalArgumentException ("No null URL accepted"); 56 } 57 58 try 60 { 61 Field f = ((PortletURLImpl)url).getClass().getDeclaredField("windowURL"); 62 if (!f.isAccessible()) 63 { 64 f.setAccessible(true); 65 } 66 WindowURL windowURL = (WindowURL)f.get(url); 67 return resp.createURL(windowURL, false); 68 } 69 catch (NoSuchFieldException e) 70 { 71 IllegalArgumentException iae = new IllegalArgumentException ("No windowURL field on portlet url"); 72 iae.initCause(e); 73 throw iae; 74 } 75 catch (IllegalAccessException e) 76 { 77 IllegalArgumentException iae = new IllegalArgumentException ("Cannot have access to the windowURL field"); 78 iae.initCause(e); 79 throw iae; 80 } 81 } 82 } 83 | Popular Tags |