You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by wo...@apache.org on 2009/04/17 19:26:12 UTC

svn commit: r766091 - in /portals/jetspeed-2/applications/j2-admin/trunk/src: main/java/org/apache/jetspeed/portlets/dojo/AbstractAdminDojoVelocityPortlet.java webapp/WEB-INF/view/selectors/category-portlet-header.vm

Author: woonsan
Date: Fri Apr 17 17:26:11 2009
New Revision: 766091

URL: http://svn.apache.org/viewvc?rev=766091&view=rev
Log:
APA-8: Reverting j2-admin's dojo enabled portlet to use the jetspeed's head contribution api.
Without reverting, portlet selector and desktop do not work at all. Anyway, it's working now. (sigh)

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/dojo/AbstractAdminDojoVelocityPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/selectors/category-portlet-header.vm

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/dojo/AbstractAdminDojoVelocityPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/dojo/AbstractAdminDojoVelocityPortlet.java?rev=766091&r1=766090&r2=766091&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/dojo/AbstractAdminDojoVelocityPortlet.java (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/dojo/AbstractAdminDojoVelocityPortlet.java Fri Apr 17 17:26:11 2009
@@ -23,6 +23,10 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 
+import org.apache.jetspeed.headerresource.HeaderResource;
+import org.apache.jetspeed.portlet.PortletHeaderRequest;
+import org.apache.jetspeed.portlet.PortletHeaderResponse;
+import org.apache.jetspeed.portlet.SupportsHeaderPhase;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.portals.gems.dojo.AbstractDojoVelocityPortlet;
 import org.apache.portals.gems.dojo.DojoPortletHelper;
@@ -30,10 +34,11 @@
 /**
  * Extending AbstractDojoVelocityPortlet because admin portlets can use jetspeed-api
  * to detect the portal webapp context path.
+ * FIXME: Use portlet 2.0 head contribution API only.
  * 
  * @version $Id$
  */
-public abstract class AbstractAdminDojoVelocityPortlet extends AbstractDojoVelocityPortlet
+public abstract class AbstractAdminDojoVelocityPortlet extends AbstractDojoVelocityPortlet implements SupportsHeaderPhase
 {
     
     protected static final String DOJO_JS_RELATIVE_URL_INIT_PARAM = "dojo.js.relative.url";
@@ -55,45 +60,88 @@
         this.dojoJsRelativeUrl = getInitParameter(DOJO_JS_RELATIVE_URL_INIT_PARAM);
     }
     
-    @Override
-    protected void doHeaders(RenderRequest request, RenderResponse response)
+    /**
+     * Include Dojo and Turbo header content using header resource component.
+     *
+     * @param request render request
+     * @param response render response
+     */
+    @Deprecated
+    public void doHeader( PortletHeaderRequest request, PortletHeaderResponse response )
+    throws PortletException
     {
-        if (this.dojoJsRelativeUrl != null)
-        {
-            RequestContext requestContext = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
-            String portalContextPath = requestContext.getRequest().getContextPath();
-            DojoPortletHelper.enableDojo(response, portalContextPath + this.dojoJsRelativeUrl);
-        }
-        else
-        {
-            DojoPortletHelper.enableDojo(response, this.dojoJsUrl);
-        }
-        
-        if (this.headerPage != null)
-        {
-            try
-            {
-                this.getPortletContext().getRequestDispatcher(this.headerPage).include(request, response);
-            }
-            catch (PortletException e)
-            {
-                throw new RuntimeException("Failed to include header page.", e);
-            }
-            catch (IOException e)
-            {
-                throw new RuntimeException("Failed to include header page.", e);
-            }
-        }
+        // use header resource component to ensure header logic is included only once
+        HeaderResource headerResource = response.getHeaderResource();
 
-        if (this.dojoRequiresCoreList != null)
-        {
-            DojoPortletHelper.contributeDojoRequires(response, this.dojoRequiresCoreList);
-        }
+        headerResource.dojoEnable();
+        includeHeaderContent( headerResource );
         
-        if (this.dojoRequiresAddOnList != null)
+        if ( this.headerPage != null )
         {
-            DojoPortletHelper.contributeDojoRequires(response, this.dojoRequiresAddOnList);
+            include( request, response, this.headerPage );
         }
     }
+    
+    @Deprecated
+    protected void includeHeaderContent( HeaderResource headerResource )
+    {
+        // do nothing - intended for derived classes
+    }
+    
+    @Deprecated
+    protected void include(PortletHeaderRequest request, PortletHeaderResponse response, String headerPagePath, StringBuffer headerText) throws PortletException
+    {
+        response.include(request, response, headerPagePath);
+        headerText.append(response.getContent());
+    }
+    
+    @Deprecated
+    protected void include(PortletHeaderRequest request, PortletHeaderResponse response, String headerPagePath) throws PortletException
+    {
+        response.include(request, response, headerPagePath);
+        response.getHeaderResource().addHeaderInfo(response.getContent());
+    }
+    
+    @Override
+    protected void doHeaders(RenderRequest request, RenderResponse response)
+    {
+        /* FIXME: enable the following by using portlet 2.0 head contribution API */
+//        if (this.dojoJsRelativeUrl != null)
+//        {
+//            RequestContext requestContext = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
+//            String portalContextPath = requestContext.getRequest().getContextPath();
+//            DojoPortletHelper.enableDojo(response, portalContextPath + this.dojoJsRelativeUrl);
+//        }
+//        else
+//        {
+//            DojoPortletHelper.enableDojo(response, this.dojoJsUrl);
+//        }
+//        
+//        if (this.headerPage != null)
+//        {
+//            try
+//            {
+//                this.getPortletContext().getRequestDispatcher(this.headerPage).include(request, response);
+//            }
+//            catch (PortletException e)
+//            {
+//                throw new RuntimeException("Failed to include header page.", e);
+//            }
+//            catch (IOException e)
+//            {
+//                throw new RuntimeException("Failed to include header page.", e);
+//            }
+//        }
+//
+//        if (this.dojoRequiresCoreList != null)
+//        {
+//            DojoPortletHelper.contributeDojoRequires(response, this.dojoRequiresCoreList);
+//        }
+//        
+//        if (this.dojoRequiresAddOnList != null)
+//        {
+//            DojoPortletHelper.contributeDojoRequires(response, this.dojoRequiresAddOnList);
+//        }
+    }
 
 }

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/selectors/category-portlet-header.vm
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/selectors/category-portlet-header.vm?rev=766091&r1=766090&r2=766091&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/selectors/category-portlet-header.vm (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/view/selectors/category-portlet-header.vm Fri Apr 17 17:26:11 2009
@@ -14,129 +14,124 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 *#
-#set($styleTextContent = 
-  ".portlet-selector-title "
-+ "{ "
-+ "    font-size: 9pt; "
-+ "        color: blue; "
-+ "} "
-+ ".portlet-selector-text "
-+ "{ "
-+ "    font-size: 8pt; "
-+ "        color: green; "
-+ "} "
-+ ".dojoDialog { "
-+ "    background : #eee; "
-+ "    border : 1px solid #999; "
-+ "    -moz-border-radius : 5px; "
-+ "    padding : 4px; "
-+ "    width: 420px; "
-+ "} "
-+ " "
-+ ".buttonbox { "
-+ "    display: block; "
-+ "    text-align: center; "
-+ "} "
-+ ".buttonbox .dojoButton { "
-+ "    float: left; "
-+ "    margin-right: 10px; "
-+ "    margin-bottom: 6px; "
-+ "} "
-+ " "
-+ ".buttonboxright { "
-+ "    display: block; "
-+ "    text-align: center; "
-+ "} "
-+ ".buttonboxright .dojoButton { "
-+ "    float: right; "
-+ "    margin-left: 10px; "
-+ "    margin-bottom: 6px; "
-+ "} "
-+ " "
-+ ".constraints { "
-+ "    font-family:Lucida Grande, Verdana; "
-+ "    font-size:0.8em; "
-+ "    width:100%; "
-+ "    border:1px solid #ccc; "
-+ "    cursor:default; "
-+ "} "
-+ " "
-+ "#mainTabContainer { "
-+ "    width: 100%; "
-+ "    height: 304px; "
-+ "} "
-+ " "
-+ "* html div.tableContainer {    /* IE only hack */ "
-+ "    width: 95%; "
-+ "    border: 1px solid #ccc; "
-+ "    height: 285px; "
-+ "    overflow-x: hidden; "
-+ "    overflow-y: auto; "
-+ "} "
-+ " "
-+ ".constraints td, "
-+ ".constraints th{ "
-+ "    border-right: 1px solid #999; "
-+ "    padding: 2px; "
-+ "    font-weight: normal; "
-+ "    font-size: small; "
-+ "} "
-+ " "
-+ ".constraints thead td, .constraints thead th { "
-+ "    background-image:url(/j2-admin/images/st-head.gif); "
-+ "    background-repeat:no-repeat; "
-+ "    background-position:top right; "
-+ "    font-size: small; "
-+ "    font-weight: bold; "
-+ "    text-align: left; "
-+ "} "
-+ ".constraints thead td.selectedUp, .constraints thead th.selectedUp { "
-+ "    background-image:url(/j2-admin/images/st-headup.gif); "
-+ "} "
-+ ".constraints thead td.selectedDown, .constraints thead th.selectedDown { "
-+ "    background-image:url(/j2-admin/images/st-headdown.gif); "
-+ "} "
-+ " "
-+ "* html div.tableContainer table thead tr td, "
-+ "* html div.tableContainer table thead tr th{ "
-+ "    /* IE Only hacks */ "
-+ "    position:relative; "
-+ "    top:expression(dojo.html.getFirstAncestorByTag(this,'table').parentNode.scrollTop-2); "
-+ "} "
-+ " "
-+ " "
-+ "html>body tbody.scrollContent { "
-+ "    height: 262px; "
-+ "    overflow-x: hidden; "
-+ "    overflow-y: auto; "
-+ "} "
-+ " "
-+ "tbody.scrollContent td, tbody.scrollContent tr td { "
-+ "    background: #FFF; "
-+ "    padding: 2px; "
-+ "} "
-+ " "
-+ "tbody.scrollContent tr.alternateRow td { "
-+ "    background: #e3edfa; "
-+ "    padding: 2px; "
-+ "} "
-+ " "
-+ "tbody.scrollContent tr.selected td { "
-+ "    background: yellow; "
-+ "    padding: 2px; "
-+ "} "
-+ "tbody.scrollContent tr:hover td { "
-+ "    background: #a6c2e7; "
-+ "    padding: 2px; "
-+ "} "
-+ "tbody.scrollContent tr.selected:hover td { "
-+ "    background: #ff3; "
-+ "    padding: 2px; "
-+ "}"
-)
-#set($headElem = $renderResponse.createElement("style"))
-#set($headElemDoc = $headElem.ownerDocument)
-#set($styleTextNode = $headElemDoc.createTextNode($styleTextContent))
-#set($result = $headElem.appendChild($styleTextNode))
-#set($result = $headElem.setAttribute("id", "category-portlet-header.vm"))
-#set($result = $renderResponse.addProperty("javax.portlet.markup.head.element", $headElem))
+<style>
+.portlet-selector-title
+{    
+    font-size: 9pt;
+        color: blue;
+}
+.portlet-selector-text
+{    
+    font-size: 8pt;
+        color: green;
+}
+.dojoDialog {
+    background : #eee;
+    border : 1px solid #999;
+    -moz-border-radius : 5px;
+    padding : 4px;
+    width: 420px;
+}
+
+.buttonbox {
+    display: block;
+    text-align: center;
+}
+.buttonbox .dojoButton {
+    float: left;
+    margin-right: 10px;
+    margin-bottom: 6px;
+}
+
+.buttonboxright {
+    display: block;
+    text-align: center;
+}
+.buttonboxright .dojoButton {
+    float: right;
+    margin-left: 10px;
+    margin-bottom: 6px;
+}
+
+.constraints {
+    font-family:Lucida Grande, Verdana;
+    font-size:0.8em;
+    width:100%;
+    border:1px solid #ccc;
+    cursor:default;
+}
+
+#mainTabContainer {
+    width: 100%;
+    height: 304px;
+}
+
+* html div.tableContainer {    /* IE only hack */
+    width: 95%;
+    border: 1px solid #ccc;
+    height: 285px;
+    overflow-x: hidden;
+    overflow-y: auto;
+}
+
+.constraints td,
+.constraints th{
+    border-right: 1px solid #999;
+    padding: 2px;
+    font-weight: normal;
+    font-size: small;
+}
+
+.constraints thead td, .constraints thead th {
+    background-image:url(/j2-admin/images/st-head.gif);
+    background-repeat:no-repeat;
+    background-position:top right;
+    font-size: small;
+    font-weight: bold;
+    text-align: left;
+}
+.constraints thead td.selectedUp, .constraints thead th.selectedUp {
+    background-image:url(/j2-admin/images/st-headup.gif);
+}
+.constraints thead td.selectedDown, .constraints thead th.selectedDown {
+    background-image:url(/j2-admin/images/st-headdown.gif);
+}
+
+* html div.tableContainer table thead tr td,
+* html div.tableContainer table thead tr th{
+    /* IE Only hacks */
+    position:relative;
+    top:expression(dojo.html.getFirstAncestorByTag(this,'table').parentNode.scrollTop-2);
+}
+
+
+html>body tbody.scrollContent {
+    height: 262px;
+    overflow-x: hidden;
+    overflow-y: auto;
+}
+
+tbody.scrollContent td, tbody.scrollContent tr td {
+    background: #FFF;
+    padding: 2px;
+}
+
+tbody.scrollContent tr.alternateRow td {
+    background: #e3edfa;
+    padding: 2px;
+}
+
+tbody.scrollContent tr.selected td {
+    background: yellow;
+    padding: 2px;
+}
+tbody.scrollContent tr:hover td {
+    background: #a6c2e7;
+    padding: 2px;
+}
+tbody.scrollContent tr.selected:hover td {
+    background: #ff3;
+    padding: 2px;
+}
+
+</style>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org