1 9 package org.jboss.portal.portlet; 10 11 import javax.portlet.PortletMode; 12 import javax.portlet.PortletURL; 13 import javax.portlet.WindowState; 14 15 import org.apache.log4j.Logger; 16 import org.jboss.portal.portlet.impl.PortletURLImpl; 17 import org.jboss.portal.server.PortalResponse; 18 import org.jboss.portal.server.Window; 19 import org.jboss.portal.server.WindowURL; 20 21 25 public class PortletUtils 26 { 27 28 private static Logger log = Logger.getLogger(PortletUtils.class); 29 30 public static WindowState decodeWindowState(String s) 31 { 32 if (WindowState.NORMAL.toString().equals(s)) 33 { 34 return WindowState.NORMAL; 35 } 36 else if (WindowState.MINIMIZED.toString().equals(s)) 37 { 38 return WindowState.MINIMIZED; 39 } 40 else if (WindowState.MAXIMIZED.toString().equals(s)) 41 { 42 return WindowState.MAXIMIZED; 43 } 44 else 45 { 46 return new WindowState(s); 47 } 48 } 49 50 public static PortletMode decodePortletMode(String s) 51 { 52 if (PortletMode.EDIT.toString().equalsIgnoreCase(s)) 53 { 54 return PortletMode.EDIT; 55 } 56 else if (PortletMode.HELP.toString().equalsIgnoreCase(s)) 57 { 58 return PortletMode.HELP; 59 } 60 else if (PortletMode.VIEW.toString().equalsIgnoreCase(s)) 61 { 62 return PortletMode.VIEW; 63 } 64 else 65 { 66 return new PortletMode(s); 67 } 68 } 69 70 73 public static PortletURL createActionURL( 74 PortalResponse resp, 75 Window window, 76 String contentType) 77 { 78 return new PortletURLImpl(createWindowActionURL(resp, window), window, contentType, resp); 79 } 80 81 84 public static PortletURL createRenderURL( 85 PortalResponse resp, 86 Window window, 87 String contentType) 88 { 89 WindowURL portalURL = createWindowRenderURL(resp, window); 90 return new PortletURLImpl(portalURL, window, contentType, resp); 91 } 92 93 96 public static WindowURL createWindowActionURL( 97 PortalResponse resp, 98 Window window) 99 { 100 WindowURL windowURL = (WindowURL)window.createURL(); 101 windowURL.setType(WindowURL.TYPE_ACTION); 102 return windowURL; 103 } 104 105 108 public static WindowURL createWindowRenderURL( 109 PortalResponse resp, 110 Window window) 111 { 112 WindowURL windowURL = (WindowURL)window.createURL(); 113 windowURL.setType(WindowURL.TYPE_RENDER); 114 return windowURL; 115 } 116 117 public static PortletURL createUpdateWindowStateURL( 118 PortalResponse resp, 119 Window window, 120 String contentType) 121 { 122 return createNavigationURL(resp, window, contentType); 123 } 124 125 public static PortletURL createUpdatePortletModeURL( 126 PortalResponse resp, 127 Window window, 128 String contentType) 129 { 130 return createNavigationURL(resp, window, contentType); 131 } 132 133 public static PortletURL createNavigationURL( 134 PortalResponse resp, 135 Window window, 136 String contentType) 137 { 138 WindowURL windowURL = (WindowURL)window.createURL(); 139 windowURL.setType(WindowURL.TYPE_NAVIGATION); 140 return new PortletURLImpl(windowURL, window, contentType, resp); 141 } 142 } 143 | Popular Tags |