portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r1090090 - in /portals/jetspeed-2/applications/j2-admin/trunk: ./ src/main/java/org/apache/jetspeed/portlets/clone/ src/main/java/org/apache/jetspeed/portlets/prm/ src/main/resources/org/apache/jetspeed/portlets/prm/ src/main/webapp/WEB-INF...
Date Fri, 08 Apr 2011 02:21:14 GMT
Author: woonsan
Date: Fri Apr  8 02:21:14 2011
New Revision: 1090090

URL: http://svn.apache.org/viewvc?rev=1090090&view=rev
Log:
JS2-1247: Implementing close button. Upgraded wicket dependency to 1.4.17 to enable external
pages to get modal-closing-script code.

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/pom.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/prm/ApplicationsListHome.html
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/pom.xml?rev=1090090&r1=1090089&r2=1090090&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/pom.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/pom.xml Fri Apr  8 02:21:14 2011
@@ -57,7 +57,7 @@
     <velocity-tools.version>1.3</velocity-tools.version>
     <velocity.version>1.6.3</velocity.version>
     <xerces.version>2.8.1</xerces.version>
-    <wicket.version>1.4.5</wicket.version>
+    <wicket.version>1.4.17</wicket.version>
   </properties>
 
   <!-- Dependencies -->

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java?rev=1090090&r1=1090089&r2=1090090&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/clone/PortletCloneManagerPortlet.java
Fri Apr  8 02:21:14 2011
@@ -35,7 +35,6 @@ import javax.portlet.RenderResponse;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.jetspeed.CommonPortletServices;
-import org.apache.jetspeed.components.portletregistry.FailedToStorePortletDefinitionException;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
 import org.apache.jetspeed.om.portlet.PortletDefinition;
 import org.apache.jetspeed.om.portlet.Preference;
@@ -67,10 +66,17 @@ public class PortletCloneManagerPortlet 
     {
         RequestContext rc = (RequestContext) request.getAttribute(RequestContext.REQUEST_PORTALENV);
         String portletUniqueName = rc.getRequestParameter("portlet");
+        
+        if (portletUniqueName == null)
+        {
+            portletUniqueName = (String) request.getPortletSession(true).getAttribute("originalPortletUniqueName");
+        }
+        
         PortletDefinition def = null;
         
         if (!StringUtils.isBlank(portletUniqueName))
         {
+            request.getPortletSession(true).setAttribute("originalPortletUniqueName", portletUniqueName);
             def = registry.getPortletDefinitionByUniqueName(portletUniqueName);
         }
         
@@ -106,37 +112,37 @@ public class PortletCloneManagerPortlet 
     @Override
     public void processAction(ActionRequest request, ActionResponse response) throws PortletException,
IOException
     {
-        String action = request.getParameter("action");
+        String status = "fail";
+        ClonePortletInfo clonePortletInfo = readClonePortletInfoFromRequest(request);
+        PortletDefinition def = registry.getPortletDefinitionByUniqueName(clonePortletInfo.getOriginalPortletUniqueName());
         
-        if ("clone".equals(action))
+        try
         {
-            ClonePortletInfo clonePortletInfo = readClonePortletInfoFromRequest(request);
-            PortletDefinition def = registry.getPortletDefinitionByUniqueName(clonePortletInfo.getOriginalPortletUniqueName());
-            
             if (def == null)
             {
-                log.error("Cannot find the portlet or clone: {}", clonePortletInfo.getOriginalPortletUniqueName());
+                throw new IllegalArgumentException("Cannot find the portlet or clone: " +
clonePortletInfo.getOriginalPortletUniqueName());
             }
-            else
+            
+            if (StringUtils.isBlank(clonePortletInfo.getPortletName()))
             {
-                if (!StringUtils.isBlank(clonePortletInfo.getPortletName()))
-                {
-                    try
-                    {
-                        PortletDefinition clone = registry.clonePortletDefinition(def, StringUtils.trim(clonePortletInfo.getPortletName()));
-                        clone.getPortletInfo().setTitle(StringUtils.defaultString(clonePortletInfo.getPortletTitle()));
-                        clone.getPortletInfo().setShortTitle(StringUtils.defaultString(clonePortletInfo.getPortletShortTitle()));
-                        clone.getPortletInfo().setKeywords(StringUtils.defaultString(clonePortletInfo.getPortletKeywords()));
-                        // TODO displayName, preferences..
-                        registry.savePortletDefinition(clone);
-                    }
-                    catch (FailedToStorePortletDefinitionException e)
-                    {
-                        log.error("Failed to clone portlet from " + clonePortletInfo.getOriginalPortletUniqueName()
+ " to " + clonePortletInfo.getPortletName(), e);
-                    }
-                }
+                throw new IllegalArgumentException("Invalid clone name: " + clonePortletInfo.getPortletName());
             }
+
+            PortletDefinition clone = registry.clonePortletDefinition(def, StringUtils.trim(clonePortletInfo.getPortletName()));
+            clone.getPortletInfo().setTitle(StringUtils.defaultString(clonePortletInfo.getPortletTitle()));
+            clone.getPortletInfo().setShortTitle(StringUtils.defaultString(clonePortletInfo.getPortletShortTitle()));
+            clone.getPortletInfo().setKeywords(StringUtils.defaultString(clonePortletInfo.getPortletKeywords()));
+            // TODO displayName, preferences..
+            registry.savePortletDefinition(clone);
+            status = "success";
         }
+        catch (Exception e) 
+        {
+            request.getPortletSession(true).setAttribute("errorMessage", e.toString());
+            log.error("Failed to clone portlet from " + clonePortletInfo.getOriginalPortletUniqueName()
+ " to " + clonePortletInfo.getPortletName(), e);
+        }
+        
+        request.getPortletSession(true).setAttribute("status", status);
     }
     
     private ClonePortletInfo readClonePortletInfoFromRequest(ActionRequest request)

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java?rev=1090090&r1=1090089&r2=1090090&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/prm/ApplicationsListHome.java
Fri Apr  8 02:21:14 2011
@@ -75,6 +75,9 @@ public class ApplicationsListHome extend
     static final Logger logger = LoggerFactory.getLogger(ApplicationsListHome.class);
 
     public static final String PORTLET_REGISTRY_MANAGER = "Portlet Registry Manager";
+    
+    private String clonePopupPagePath = "/system/prm/cloneportlet.psml";
+    private String currentModalWindowCloseScript;
 
     public ApplicationsListHome()
     {
@@ -280,8 +283,37 @@ public class ApplicationsListHome extend
         add(portletListView);
         add(new PagingNavigator("plNavigator", portletListView));
         
-        ModalWindow modalWindow = new ModalWindow("modalwindow");
+        CloneModalWindow modalWindow = new CloneModalWindow("modalwindow");
         add(modalWindow);
+        
+        Label modalWindowCloseScript = new Label("modalWindowCloseScript", new PropertyModel<String>(this,
"currentModalWindowCloseScript"));
+        modalWindowCloseScript.setOutputMarkupId(true);
+        add(modalWindowCloseScript);
+    }
+    
+    public String getCurrentModalWindowCloseScript()
+    {
+        return currentModalWindowCloseScript;
+    }
+
+    public void setCurrentModalWindowCloseScript(String currentModalWindowCloseScript)
+    {
+        this.currentModalWindowCloseScript = currentModalWindowCloseScript;
+    }
+
+    class CloneModalWindow extends ModalWindow
+    {
+        private static final long serialVersionUID = 1L;
+        
+        public CloneModalWindow(String id)
+        {
+            super(id);
+        }
+        
+        public String getCloseJavacript()
+        {
+            return super.getCloseJavacript();
+        }
     }
 
     class RunningPanel extends Panel
@@ -617,9 +649,9 @@ public class ApplicationsListHome extend
                         PortletRegistry registry = locator.getPortletRegistry();
                         PortletDefinition def = registry.getPortletDefinitionByUniqueName(pdb.getUniqueName());
 
-                        ModalWindow modalWindow = (ModalWindow) getPage().get("modalwindow");
+                        CloneModalWindow modalWindow = (CloneModalWindow) getPage().get("modalwindow");
                         RequestContext rc = ((AbstractAdminWebApplication) getApplication()).getPortalRequestContext();
-                        final String pagePath = rc.getPortalURL().getBasePath() + "/system/prm/cloneportlet.psml?portlet="
+ def.getUniqueName();
+                        final String pagePath = rc.getPortalURL().getBasePath() + clonePopupPagePath
+ "?portlet=" + def.getUniqueName();
                         modalWindow.setPageCreator(new ModalWindow.PageCreator() 
                         {
                             private static final long serialVersionUID = 1L;
@@ -629,6 +661,8 @@ public class ApplicationsListHome extend
                                 return new RedirectPage(pagePath);
                             }
                         });
+                        ((ApplicationsListHome) getPage()).setCurrentModalWindowCloseScript(modalWindow.getCloseJavacript());
+                        target.addComponent(getPage().get("modalWindowCloseScript"));
                         modalWindow.show(target);
                     }
                     catch (Exception e) 

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/prm/ApplicationsListHome.html
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/prm/ApplicationsListHome.html?rev=1090090&r1=1090089&r2=1090090&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/prm/ApplicationsListHome.html
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/resources/org/apache/jetspeed/portlets/prm/ApplicationsListHome.html
Fri Apr  8 02:21:14 2011
@@ -95,6 +95,7 @@
 </table>
 
 <div wicket:id="modalwindow"></div>
+<div wicket:id="modalWindowCloseScript" class="modal-window-close-script" style="DISPLAY:
none"></div>
 
 </body>
 </html>
\ No newline at end of file

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp?rev=1090090&r1=1090089&r2=1090090&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/prm/portlet-clone-manager-view.jsp
Fri Apr  8 02:21:14 2011
@@ -23,10 +23,30 @@ limitations under the License.
 <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
 <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
 <portlet:defineObjects/>
+
 <fmt:setBundle basename="org.apache.jetspeed.portlets.clone.resources.PortletCloneManagerResources"
/>
 
 <br/>
 
+<%
+String status = (String) renderRequest.getPortletSession(true).getAttribute("status");
+if (status != null) 
+{
+    renderRequest.getPortletSession(true).removeAttribute("status");
+}
+%>
+
+<% if (status != null) { %>
+    <% if ("fail".equals(status)) { %>
+        <div>Error: <%=renderRequest.getPortletSession(true).getAttribute("errorMessage")%></div>
+    <% } else { %>
+        <script type="text/javascript" language="javascript">
+            var el = parent.document.getElementsByClassName('modal-window-close-script')[0];
+            eval(el.textContent ? el.textContent : el.innerText);
+        </script>
+    <% } %>
+<% } %>
+
 <form method="POST" action="<portlet:actionURL/>">
   <table cellpadding="0" cellspacing="1" border="0" width="100%">
     <tbody>
@@ -105,7 +125,8 @@ limitations under the License.
       <tr>
         <th class="portlet-section-alternate" colspan="2">
           <input type="submit" value="<fmt:message key='portlet.clone.label.action.clone'/>"
/>
-          <input type="hidden" name="action" value="clone" />
+          <input type="button" value="<fmt:message key='portlet.clone.label.action.cancel'/>"
+                 onclick="var el = parent.document.getElementsByClassName('modal-window-close-script')[0];
eval(el.textContent ? el.textContent : el.innerText); return false;" />
           <input type="hidden" name="originalPortletUniqueName" value="<c:out value='${clonePortletInfo.originalPortletUniqueName}'/>"
/>
         </th>
       </tr>



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


Mime
View raw message