You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2015/05/27 16:29:21 UTC

svn commit: r1682044 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-example/tobago-example-demo/src/main/webapp/layout/ tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ tobago-theme/to...

Author: lofwyr
Date: Wed May 27 14:29:21 2015
New Revision: 1682044

URL: http://svn.apache.org/r1682044
Log:
TOBAGO-1368: Create a new theme which uses Bootstrap
 - revise UIMessages

Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MessagesRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml?rev=1682044&r1=1682043&r2=1682044&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-example/tobago-example-demo/src/main/webapp/layout/overview.xhtml Wed May 27 14:29:21 2015
@@ -52,7 +52,7 @@
             <tc:flexLayout rows="auto;*;auto"/>
           </f:facet>
 
-          <tc:messages/>
+          <tc:messages orderBy="SEVERITY"/>
 
           <tc:box label="#{title}" id="content">
             <ui:insert/>

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MessagesRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MessagesRenderer.java?rev=1682044&r1=1682043&r2=1682044&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MessagesRenderer.java (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/MessagesRenderer.java Wed May 27 14:29:21 2015
@@ -29,7 +29,6 @@ import org.apache.myfaces.tobago.compone
 import org.apache.myfaces.tobago.component.UIMessages;
 import org.apache.myfaces.tobago.component.UIPanel;
 import org.apache.myfaces.tobago.component.UIPopup;
-import org.apache.myfaces.tobago.config.Configurable;
 import org.apache.myfaces.tobago.context.Markup;
 import org.apache.myfaces.tobago.context.ResourceManagerUtils;
 import org.apache.myfaces.tobago.internal.ajax.AjaxInternalUtils;
@@ -82,10 +81,6 @@ public class MessagesRenderer extends La
     final List<UIMessages.Item> messageList = messages.createMessageList(facesContext);
 
     if (messageList.size() > 0) { // in ie empty span gets a height
-      writer.startElement(HtmlElements.DIV, messages);
-      final FacesMessage.Severity maximumSeverity = FacesContext.getCurrentInstance().getMaximumSeverity();
-      writer.writeClassAttribute(TobagoClass.MESSAGES, BootstrapClass.ALERT, BootstrapClass.alert(maximumSeverity));
-      HtmlRendererUtils.writeDataAttributes(facesContext, writer, messages);
       writer.writeStyleAttribute(new Style(facesContext, messages));
 
       // with id
@@ -99,9 +94,30 @@ public class MessagesRenderer extends La
         clientIds = facesContext.getClientIdsWithMessages();
       }*/
 
+      FacesMessage.Severity lastSeverity = null;
+      boolean first = true;
+
       for (final UIMessages.Item item : messageList) {
-        encodeMessage(writer, messages, item.getFacesMessage(), item.getClientId());
+        final FacesMessage message = item.getFacesMessage();
+        final FacesMessage.Severity severity = message.getSeverity();
+
+        if (!first && lastSeverity != severity) {
+          writer.endElement(HtmlElements.DIV);
+        }
+
+        if (first || lastSeverity != severity) {
+          writer.startElement(HtmlElements.DIV, messages);
+          writer.writeClassAttribute(
+              TobagoClass.MESSAGES, BootstrapClass.ALERT, BootstrapClass.alert(severity));
+          HtmlRendererUtils.writeDataAttributes(facesContext, writer, messages);
+        }
+
+        encodeMessage(writer, messages, message, item.getClientId());
+
+        lastSeverity = severity;
+        first = false;
       }
+      writer.endElement(HtmlElements.DIV);
 /*
       while(clientIds.hasNext()) {
         String clientId = (String) clientIds.next();
@@ -117,19 +133,16 @@ public class MessagesRenderer extends La
 */
       writer.endElement(HtmlElements.DIV);
       if (messages.getFor() == null) {
-        final String clientId = messages.getClientId(facesContext);
+        final String id = messages.getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "messagesExists";
         writer.startElement(HtmlElements.INPUT, null);
         writer.writeAttribute(HtmlAttributes.VALUE, Boolean.TRUE.toString(), false);
-        writer.writeAttribute(HtmlAttributes.ID,
-            clientId + ComponentUtils.SUB_SEPARATOR + "messagesExists", false);
-        writer.writeAttribute(HtmlAttributes.NAME,
-            clientId + ComponentUtils.SUB_SEPARATOR + "messagesExists", false);
+        writer.writeAttribute(HtmlAttributes.ID, id, false);
+        writer.writeAttribute(HtmlAttributes.NAME, id, false);
         writer.writeAttribute(HtmlAttributes.TYPE, HtmlInputTypes.HIDDEN, false);
         writer.endElement(HtmlElements.INPUT);
       }
     }
-    if (messages.getFor() == null
-        && !AjaxUtils.isAjaxRequest(facesContext)) {
+    if (messages.getFor() == null && !AjaxUtils.isAjaxRequest(facesContext)) {
       AjaxInternalUtils.storeMessagesClientIds(facesContext, messages);
     }
   }
@@ -246,17 +259,7 @@ public class MessagesRenderer extends La
       writer.writeText("");
     }
     writer.endElement(HtmlElements.LABEL);
-    writer.startElement(HtmlElements.BR, null);
-    writer.endElement(HtmlElements.BR);
 
     message.rendered();
   }
-
-  @Override
-  public Measure getPreferredHeight(final FacesContext facesContext, final Configurable component) {
-    final Measure measure = super.getPreferredHeight(facesContext, component);
-    final UIMessages messages = (UIMessages) component;
-    final int count = messages.createMessageList(facesContext).size();
-    return measure.multiply(count);
-  }
 }

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css?rev=1682044&r1=1682043&r2=1682044&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css (original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/style/tobago.css Wed May 27 14:29:21 2015
@@ -82,6 +82,16 @@ table.tobago-gridLayout > tbody > tr:fir
     border-top: 0;
 }
 
+/* messages ----------------------------------------------------------- */
+
+.tobago-messages-item {
+  display: block;
+}
+
+.tobago-messages-item:last-child {
+  margin-bottom: 0;
+}
+
 /* page ----------------------------------------------------------- */
 
 body > form > .navbar-fixed-top + * {