You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by dr...@apache.org on 2007/07/26 18:31:42 UTC

svn commit: r559876 - in /myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs: Core.js MessageBox.js

Author: drobinson
Date: Thu Jul 26 09:31:39 2007
New Revision: 559876

URL: http://svn.apache.org/viewvc?view=rev&rev=559876
Log:
TRINIDAD-94 & TRINIDAD-123
Added pop'ing of js alert when input has no label and there's no message box on-screen.

Modified:
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
    myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/MessageBox.js

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?view=diff&rev=559876&r1=559875&r2=559876
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js Thu Jul 26 09:31:39 2007
@@ -1298,20 +1298,25 @@
     // Loop through the messages for this input
     for (var j=0; j < messages.length; j = j+2)
     {
-      // Move the focus back to the first failed field
       if (noFailures)
       {
-        _setFocus(currInput);
         noFailures = false;
+
+        // Move the focus back to the first failed field
+        // TODO - Remove once inline validation uses onblur/onchange
+        _setFocus(currInput);
       }
 
       // Get the current message
       var facesMessage = messages[j];
 
       if (msgElem)
-      {
         msgElem.innerHTML += facesMessage.getDetail();
-      }
+
+      // if there's nowhere to display the message in either
+      // summary or detail, then pop an alert to warn the page developer
+      if (!msgElem && !TrMessageBox.isPresent())
+        alert("Field Error [" + currId + "] - " + facesMessage.getDetail());
       
       // Add the message to the MessageBox
       TrMessageBox.addMessage(currId, label, facesMessage);
@@ -1320,7 +1325,7 @@
     // If we got this far, we know there's something to display so
     // make the inline message and icon visible.
     if (msgElem)
-        msgElem.style.display = "inline";
+      msgElem.style.display = "inline";
     if (iconElem)
       iconElem.style.display = "inline";
   }

Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/MessageBox.js
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/MessageBox.js?view=diff&rev=559876&r1=559875&r2=559876
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/MessageBox.js (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/MessageBox.js Thu Jul 26 09:31:39 2007
@@ -25,6 +25,12 @@
     TrMessageBox._MESSAGE_BOX = new TrMessageBox(messageBoxId);
 }
 
+/**
+ * Adds a message to the message box for a given input.  The
+ * label is used as the anchor text for rendering a link to
+ * the given input.  Also shows the message box if it was previously
+ * empty.
+ **/
 TrMessageBox.addMessage = function(inputId, label, facesMessage)
 {
   var messageBox = TrMessageBox._MESSAGE_BOX;
@@ -34,6 +40,10 @@
   messageBox.addMessage(inputId, label, facesMessage);
 }
 
+/**
+ * Removes any messages that are shown for the given input.
+ * Also hides the message box if there are no.
+ **/
 TrMessageBox.removeMessages = function(inputId)
 {
   var messageBox = TrMessageBox._MESSAGE_BOX;
@@ -44,8 +54,13 @@
 }
 
 /**
- *
+ * Checks if a tr:messages component is present on-screen.
  **/
+TrMessageBox.isPresent = function()
+{
+  return (TrMessageBox._MESSAGE_BOX) ? true : false;
+}
+
 function TrMessageBox(messageBoxId)
 {
   if (messageBoxId == undefined)