[portal-commits] JBoss Portal SVN: r12938 - in tags/JBoss_Portal_2_7_2/core/src: bin/portal-core-war/js and 3 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Wed Mar 4 07:25:27 EST 2009


Author: chris.laprun at jboss.com
Date: 2009-03-04 07:25:26 -0500 (Wed, 04 Mar 2009)
New Revision: 12938

Added:
   tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/js/login.js
Modified:
   tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/css/login.css
   tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
   tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java
   tags/JBoss_Portal_2_7_2/core/src/resources/portal-server-war/login.jsp
Log:


Modified: tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/css/login.css
===================================================================
--- tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/css/login.css	2009-03-04 11:37:55 UTC (rev 12937)
+++ tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/css/login.css	2009-03-04 12:25:26 UTC (rev 12938)
@@ -20,6 +20,17 @@
    position: absolute;
 }
 
+input.disabled-button {
+   background-color: #9db3cf;
+   border-color: #c5d7df #8598ab #8598ab #c5d7df;
+   border-style: solid;
+   border-width: 1px;
+   color: #FFFFFF;
+   font-size: 10px;
+   font-weight: bold;
+   position: absolute;
+}
+
 input.login-button {
    bottom: 25px;
    right: 90px;
@@ -53,12 +64,12 @@
 }
 
 div.login-container div.login-content {
-   background-image: url( ../images/modal/login-content-bg.gif );
-   background-position: top left;
-   background-repeat: repeat-x;
+   background: url(../images/modal/login-content-bg.gif) repeat-x top left;
    width: 255px;
    font-weight: bold;
    text-align: right;
+   padding: 0;
+
 }
 
 div.login-container div.login-content div.form-field {
@@ -79,4 +90,8 @@
 div.button-container{
    height: 50px;
    position: relative;
+}
+
+div.form-field .highlight {
+   border: 2px solid #6a9cd4;
 }
\ No newline at end of file

Copied: tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/js/login.js (from rev 12932, branches/JBoss_Portal_Branch_2_7/core/src/bin/portal-core-war/js/login.js)
===================================================================
--- tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/js/login.js	                        (rev 0)
+++ tags/JBoss_Portal_2_7_2/core/src/bin/portal-core-war/js/login.js	2009-03-04 12:25:26 UTC (rev 12938)
@@ -0,0 +1,131 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat                                               *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual                    *
+ * contributors as indicated by the @authors tag. See the                     *
+ * copyright.txt in the distribution for a full listing of                    *
+ * individual contributors.                                                   *
+ *                                                                            *
+ * This is free software; you can redistribute it and/or modify it            *
+ * under the terms of the GNU Lesser General Public License as                *
+ * published by the Free Software Foundation; either version 2.1 of           *
+ * the License, or (at your option) any later version.                        *
+ *                                                                            *
+ * This software is distributed in the hope that it will be useful,           *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU           *
+ * Lesser General Public License for more details.                            *
+ *                                                                            *
+ * You should have received a copy of the GNU Lesser General Public           *
+ * License along with this software; if not, write to the Free                *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
+ ******************************************************************************/
+
+if (typeof JBossPortal == 'undefined') {
+    var JBossPortal = {
+        login : { }
+    };
+}
+
+JBossPortal.login = function() {
+
+    //namespace login functions and variables
+    var isModal = true;
+
+    return{
+        /**
+         * Gets the current display status of the login box (modal or page) sets global variable and
+         * performs dynamic rendering options for login box
+         *
+         * @public
+         * @type Function
+         * @name displayStatus
+         * @return {void}
+         */
+        displayStatus : function() {
+            if (window.parent.frames.length >= 1)
+            {
+                //loaded as modal
+            }
+            else
+            {
+                isModal = false;
+                try
+                {
+                    if (document.getElementById('login-content').scrollHeight > 0)
+                    {
+                        document.body.style.paddingTop = ((document.documentElement.clientHeight / 2) - document.getElementById('login-content').scrollHeight) + 'px';
+                    }
+                }
+                catch(e)
+                {
+                //swallow
+                }
+                //give the cancel button back button functionality (hackish) but there is no other way
+                //to get returning page
+                document.getElementById('login-cancel').onclick = function()
+                {
+                    self.history.go(-1);
+                };
+                document.getElementById('login-submit').style.right = '';
+            }
+        },
+
+        /**
+         * set focus on username
+         *
+         * @public
+         * @type Function
+         * @name setFocusOnLoginForm
+         * @return {void}
+         */
+        setFocusOnLoginForm : function() {
+            try
+            {
+                document.loginform.j_username.focus();
+                highlightField(document.getElementById('j_username'));
+            }
+            catch (e)
+            {
+            }
+
+        },
+
+        /**
+         * simple validate login fields and disable submit
+         *
+         * @public
+         * @type Function
+         * @name validate
+         * @return {void}
+         */
+        validate : function() {
+            try
+            {
+               
+                if (document.getElementById('j_username').value.length < 1 || document.getElementById('j_password').value.length < 1){
+                   document.getElementById('login-submit').disabled = true;
+                   document.getElementById('login-submit').className = 'login-button disabled-button';
+               }else{
+                   document.getElementById('login-submit').disabled = false;
+                   document.getElementById('login-submit').className = 'login-button';
+               }
+            }
+            catch (e)
+            {
+            }
+
+        },
+
+        highlight : function(id) {
+            var el = document.getElementById(id);
+            if ( el.className != 'highlight' ) {
+                el.className = 'highlight';
+            }
+            else {
+                el.className = '';
+            }
+        }
+    };
+
+}();

Modified: tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java
===================================================================
--- tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java	2009-03-04 11:37:55 UTC (rev 12937)
+++ tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/controller/ajax/AjaxResponseHandler.java	2009-03-04 12:25:26 UTC (rev 12938)
@@ -20,6 +20,7 @@
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA         *
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.                   *
  ******************************************************************************/
+
 package org.jboss.portal.core.controller.ajax;
 
 import org.apache.log4j.Logger;
@@ -49,6 +50,7 @@
 import org.jboss.portal.core.model.portal.command.response.UpdatePageResponse;
 import org.jboss.portal.core.model.portal.command.view.ViewPageCommand;
 import org.jboss.portal.core.model.portal.content.WindowRendition;
+import org.jboss.portal.core.model.portal.navstate.PageNavigationalState;
 import org.jboss.portal.core.model.portal.navstate.WindowNavigationalState;
 import org.jboss.portal.core.navstate.NavigationalStateChange;
 import org.jboss.portal.core.navstate.NavigationalStateContext;
@@ -85,36 +87,6 @@
  */
 public class AjaxResponseHandler implements ResponseHandler
 {
-
-   // Detect any change that would require a total refresh
-//      HttpServletRequest req = invocation.getServerContext().getClientRequest();
-//      String clientViewId = req.getHeader("view_id");
-//      if (clientViewId != null)
-//      {
-//         PortalObjectNavigationalStateContext ctx = (PortalObjectNavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
-//         String serverViewId = ctx.getViewId();
-//         if (!clientViewId.equals(serverViewId))
-//         {
-//            // todo : that will not work for FORMS submissions, we need a response for the client
-//            // to tell to do the request the normal way
-//            try
-//            {
-//               UpdatePageLocationResponse dresp = new UpdatePageLocationResponse(req.getRequestURL().toString());
-//               AjaxResponse aresp = new AjaxResponse(dresp);
-//               aresp.sendResponse(invocation.getServerContext());
-//            }
-//            catch (IOException e)
-//            {
-//               e.printStackTrace();
-//            }
-//            catch (ServletException e)
-//            {
-//               e.printStackTrace();
-//            }
-//            return;
-//         }
-//      }
-
    /** . */
    private static final Logger log = Logger.getLogger(AjaxResponseHandler.class);
 
@@ -173,10 +145,9 @@
       {
          UpdatePageResponse upw = (UpdatePageResponse)controllerResponse;
 
-         // Obtain page and portal
+         // Obtain page
          final Page page = (Page)portalObjectContainer.getObject(upw.getPageId());
 
-
          //
          NavigationalStateContext ctx = (NavigationalStateContext)controllerContext.getAttributeResolver(ControllerCommand.NAVIGATIONAL_STATE_SCOPE);
 
@@ -211,7 +182,8 @@
                NavigationalStateKey key = update.getKey();
 
                // We consider only portal object types
-               if (key.getType() == WindowNavigationalState.class)
+               Class type = key.getType();
+               if (type == WindowNavigationalState.class)
                {
                   // Get old window state
                   WindowNavigationalState oldNS = (WindowNavigationalState)update.getOldValue();
@@ -239,6 +211,23 @@
                   // Collect the dirty window id
                   dirtyWindowIds.add(key.getId());
                }
+               else if (type == PageNavigationalState.class)
+               {
+                  // force full refresh for now...
+                  fullRefresh = true;
+
+                  // TODO: implement proper propagation of PRPs and events
+                  /*PageNavigationalState pns = (PageNavigationalState)update.getNewValue();
+
+                  if (pns != null)
+                  {
+                     CoordinationManager coordinationManager = controllerContext.getController().getCoordinationManager();
+                     for (QName qName : pns.getParameters().keySet())
+                     {
+                        //
+                     }
+                  }*/
+               }
             }
          }
 
@@ -249,10 +238,13 @@
          if (!fullRefresh)
          {
             ArrayList<PortalObject> refreshedWindows = new ArrayList<PortalObject>();
-            for (PortalObject child : page.getChildren(PortalObject.WINDOW_MASK))
+
+            for (Object dirtyWindowId : dirtyWindowIds)
             {
-               PortalObjectId childId = child.getId();
-               if (dirtyWindowIds.contains(childId))
+               PortalObjectId poid = (PortalObjectId)dirtyWindowId;
+               String windowName = poid.getPath().getLastComponentName();
+               PortalObject child = page.getChild(windowName, Window.class);
+               if (child != null)
                {
                   refreshedWindows.add(child);
                }

Modified: tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java
===================================================================
--- tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java	2009-03-04 11:37:55 UTC (rev 12937)
+++ tags/JBoss_Portal_2_7_2/core/src/main/org/jboss/portal/core/model/portal/PortalObjectPath.java	2009-03-04 12:25:26 UTC (rev 12938)
@@ -1,6 +1,6 @@
 /******************************************************************************
  * JBoss, a division of Red Hat                                               *
- * Copyright 2006, Red Hat Middleware, LLC, and individual                    *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual                    *
  * contributors as indicated by the @authors tag. See the                     *
  * copyright.txt in the distribution for a full listing of                    *
  * individual contributors.                                                   *
@@ -181,6 +181,11 @@
       return names[index - from];
    }
 
+   public String getLastComponentName()
+   {
+      return names[names.length - 1];
+   }
+
    public boolean equals(Object obj)
    {
       if (obj == this)

Modified: tags/JBoss_Portal_2_7_2/core/src/resources/portal-server-war/login.jsp
===================================================================
--- tags/JBoss_Portal_2_7_2/core/src/resources/portal-server-war/login.jsp	2009-03-04 11:37:55 UTC (rev 12937)
+++ tags/JBoss_Portal_2_7_2/core/src/resources/portal-server-war/login.jsp	2009-03-04 12:25:26 UTC (rev 12938)
@@ -25,105 +25,71 @@
 <%@page import="java.util.ResourceBundle" %>
 
 <%
-   ResourceBundle rb = ResourceBundle.getBundle("Resource", request.getLocale());
+    ResourceBundle rb = ResourceBundle.getBundle("Resource", request.getLocale());
 %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-   <title><%= rb.getString("LOGIN_TITLE")%></title>
+    <title><%= rb.getString("LOGIN_TITLE")%>
+    </title>
 
-   <script>
-      var isModal = true;
-      function displayStatus(){
-          if(window.parent.frames.length > 0){
-              //loaded as modal
-          }else{
-              try{
-                  //normal page
-                  isModal = false;
-                  document.body.style.paddingTop = ((window.innerHeight / 2) - document.getElementById('login-content').offsetHeight) + 'px';
-                  //document.getElementById('login-cancel').value = "<< Back";
-                  document.getElementById('login-cancel').onclick = function(){self.history.go(-1)};
-                  document.getElementById('login-submit').style.right = '';
-              }catch(e){
-                  //swallow
-              }
-          }
-      }
-      function setFocusOnLoginForm()
-      {
-         try
-         {
-            document.loginform.j_username.focus();
-         }
-         catch (e)
-         {
-         }
-      }
+    <script type="text/javascript" src="/portal-core/js/login.js"></script>
 
-   </script>
-
-   <link rel="stylesheet" href="/portal-core/css/login.css" type="text/css"/>
+    <link rel="stylesheet" href="/portal-core/css/login.css" type="text/css"/>
 </head>
-<body onload="displayStatus();setFocusOnLoginForm();">
+<body onload="JBossPortal.login.setFocusOnLoginForm();JBossPortal.login.displayStatus();JBossPortal.login.validate();">
 
 <div class="login-container">
 
 
-   <div class="login-header">
-       <%--text title--%>
-       <%--<h2><%= rb.getString("LOGIN_TITLE") %></h2>--%>
-       <%--img title--%>
-       <img src="/portal-core/images/logo-small-blue.gif" width="118px" height="17px"alt=""/>
-   </div>
-   <div class="login-content" id="login-content">
-      <div class="error-message"
-           style="<%=(request.getAttribute(!UserStatus.OK.equals("org.jboss.portal.userStatus") ? "" : "display:none"))%>;">
-         <%
+    <div class="login-header">
+        <%--text title--%>
+        <%--<h2><%= rb.getString("LOGIN_TITLE") %></h2>--%>
+        <%--img title--%>
+        <img src="/portal-core/images/logo-small-blue.gif" width="118px" height="17px" alt=""/>
+    </div>
+    <div class="login-content" id="login-content">
+        <div class="error-message" id="login-error-message"
+             style="<%=(request.getAttribute(!UserStatus.OK.equals("org.jboss.portal.userStatus") ? "" : "display:none"))%>;">
+            <%
 
-            if (UserStatus.DISABLE.equals(request.getAttribute("org.jboss.portal.userStatus")))
-            {
-               out.println(rb.getString("ACCOUNT_DISABLED"));
-            }
-            else if (UserStatus.WRONGPASSWORD.equals(request.getAttribute("org.jboss.portal.userStatus")) || UserStatus.UNEXISTING.equals(request.getAttribute("org.jboss.portal.userStatus")))
-            {
-               out.println(rb.getString("ACCOUNT_INEXISTING_OR_WRONG_PASSWORD"));
-            }
-            else if (UserStatus.NOTASSIGNEDTOROLE.equals(request.getAttribute("org.jboss.portal.userStatus")))
-            {
-               out.println(rb.getString("ACCOUNT_NOTASSIGNEDTOROLE"));
-            }
-         %>
-      </div>
-      <form method="post" action="<%= response.encodeURL("j_security_check") %>" name="loginform" id="loginForm"
-            target="_parent">
-         <div class="form-field">
-            <label for="j_username"><%= rb.getString("LOGIN_USERNAME") %>
-            </label>
-            <input type="text" name="j_username" id="j_username" value=""/>
-         </div>
-         <div class="form-field">
-            <label for="j_password"><%= rb.getString("LOGIN_PASSWORD") %>
-            </label>
-            <input type="password" name="j_password" id="j_password" value=""/>
-         </div>
-         <br class="clear"/>
-
-         <div class="button-container">
+                if (UserStatus.DISABLE.equals(request.getAttribute("org.jboss.portal.userStatus"))) {
+                    out.println(rb.getString("ACCOUNT_DISABLED"));
+                } else if (UserStatus.WRONGPASSWORD.equals(request.getAttribute("org.jboss.portal.userStatus")) || UserStatus.UNEXISTING.equals(request.getAttribute("org.jboss.portal.userStatus"))) {
+                    out.println(rb.getString("ACCOUNT_INEXISTING_OR_WRONG_PASSWORD"));
+                } else if (UserStatus.NOTASSIGNEDTOROLE.equals(request.getAttribute("org.jboss.portal.userStatus"))) {
+                    out.println(rb.getString("ACCOUNT_NOTASSIGNEDTOROLE"));
+                }
+            %>
+        </div>
+        <form method="post" action="<%= response.encodeURL("j_security_check") %>" name="loginform" id="loginForm"
+              target="_parent" style="margin:0;padding:0">
+            <div class="form-field">
+                <label for="j_username"><%= rb.getString("LOGIN_USERNAME") %>
+                </label>
+                <input type="text" style="width:155px;" name="j_username" id="j_username" value="" onkeyup="JBossPortal.login.validate();" onFocus="JBossPortal.login.highlight('j_username');" onblur="JBossPortal.login.highlight('j_username');"/>
+            </div>
+            <div class="form-field">
+                <label for="j_password"><%= rb.getString("LOGIN_PASSWORD") %>
+                </label>
+                <input type="password" style="width:155px;" name="j_password" id="j_password" value="" onkeyup="JBossPortal.login.validate();" onFocus="JBossPortal.login.highlight('j_password');" onblur="JBossPortal.login.highlight('j_password');"/>
+            </div>
             <br class="clear"/>
-            <input type="button" name="cancel" id="login-cancel"
-                   value="<%= rb.getString("LOGIN_CANCEL")  %>" class="cancel-button"
-                   onclick="window.parent.hideContentModal('login-modal');"/>
-            <br class="clear"/>
-            <input type="submit" name="login" id="login-submit"
-                   value="<%= rb.getString("LOGIN_SUBMIT")  %>" class="login-button"/>
-         </div>
-         <br class="clear"/>
-      </form>
 
-   </div>
+            <div class="button-container">
+                <br class="clear"/>
+                <input type="button" name="cancel" id="login-cancel"
+                       value="<%= rb.getString("LOGIN_CANCEL")  %>" class="cancel-button"
+                       onclick="window.parent.hideContentModal('login-modal');"/>
+                <br class="clear"/>
+                <input type="submit" name="login" id="login-submit"
+                       value="<%= rb.getString("LOGIN_SUBMIT")  %>" class="login-button"/>
+            </div>
+        </form>
+
+    </div>
 </div>
 </body>
 </html>




More information about the portal-commits mailing list