Author: alexsmirnov
Date: 2010-12-16 20:09:52 -0500 (Thu, 16 Dec 2010)
New Revision: 20630
Added:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/TagExtensionBase.java
branches/RF-7654/ui/validator/ui/src/main/config/
branches/RF-7654/ui/validator/ui/src/main/config/faces-config.xml
branches/RF-7654/ui/validator/ui/src/main/config/messages.xml
branches/RF-7654/ui/validator/ui/src/main/java/org/richfaces/renderkit/MessageRendererBase.java
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js
branches/RF-7654/ui/validator/ui/src/main/templates/
branches/RF-7654/ui/validator/ui/src/main/templates/message.template.xml
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/MessageTestBase.java
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/SendMessageTest.java
branches/RF-7654/ui/validator/ui/src/test/resources/1.html
Removed:
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/convert/
Modified:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/csv.js
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
branches/RF-7654/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml
Log:
CODING IN PROGRESS - issue RF-7654: rich:message/rich:messages
https://issues.jboss.org/browse/RF-7654
Modified:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java
===================================================================
---
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/BehaviorBean.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -34,6 +34,7 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.PropertyModel;
+
/**
* @author akolonitsky
* @since Jan 21, 2010
@@ -90,6 +91,7 @@
super.setExtension(extension);
}
- public static class BehaviorExtension extends ExtensionBeanBase {
+ public static class BehaviorExtension extends TagExtensionBase {
+
}
}
Modified:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java
===================================================================
---
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ComponentBean.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -37,7 +37,6 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.FacetModel;
import org.richfaces.cdk.model.PropertyModel;
-import org.richfaces.cdk.model.TagModel;
import com.google.common.collect.Lists;
@@ -144,10 +143,9 @@
super.setExtension(extension);
}
- public static class ComponentExtension extends ExtensionBeanBase {
+ public static class ComponentExtension extends TagExtensionBase {
private FacesId rendererType;
private List<EventModel> events = Lists.newArrayList();
- private List<TagModel> tags = Lists.newArrayList();
private FacesId family;
/**
@@ -207,25 +205,6 @@
public void setEvents(List<EventModel> events) {
this.events = events;
}
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @return the tags
- */
- @XmlElement(name = "tag", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
- public List<TagModel> getTags() {
- return this.tags;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param tags the tags to set
- */
- public void setTags(List<TagModel> tags) {
- this.tags = tags;
- }
}
}
Modified:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java
===================================================================
---
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ConverterBean.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -33,6 +33,7 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.PropertyModel;
+
/**
* @author akolonitsky
* @since Jan 6, 2010
@@ -100,7 +101,7 @@
return super.getExtension();
}
- public static class ConverterExtension extends ExtensionBeanBase {
+ public static class ConverterExtension extends TagExtensionBase {
}
}
Added:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/TagExtensionBase.java
===================================================================
---
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/TagExtensionBase.java
(rev 0)
+++
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/TagExtensionBase.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -0,0 +1,36 @@
+package org.richfaces.cdk.xmlconfig.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.TagModel;
+
+import com.google.common.collect.Lists;
+
+public class TagExtensionBase extends ExtensionBeanBase {
+
+ private List<TagModel> tags = Lists.newArrayList();
+
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @return the tags
+ */
+ @XmlElement(name = "tag", namespace =
ComponentLibrary.CDK_EXTENSIONS_NAMESPACE)
+ public List<TagModel> getTags() {
+ return this.tags;
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ *
+ * @param tags the tags to set
+ */
+ public void setTags(List<TagModel> tags) {
+ this.tags = tags;
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/TagExtensionBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java
===================================================================
---
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/cdk/generator/src/main/java/org/richfaces/cdk/xmlconfig/model/ValidatorBean.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -33,6 +33,7 @@
import org.richfaces.cdk.model.FacesId;
import org.richfaces.cdk.model.PropertyModel;
+
/**
* @author akolonitsky
* @since Jan 13, 2010
@@ -91,7 +92,7 @@
super.setExtension(extension);
}
- public static class ValidatorExtension extends ExtensionBeanBase {
+ public static class ValidatorExtension extends TagExtensionBase {
}
}
Copied: branches/RF-7654/ui/validator/ui/src/main/config/faces-config.xml (from rev 20621,
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/faces-config.xml)
===================================================================
--- branches/RF-7654/ui/validator/ui/src/main/config/faces-config.xml
(rev 0)
+++ branches/RF-7654/ui/validator/ui/src/main/config/faces-config.xml 2010-12-17 01:09:52
UTC (rev 20630)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faces-config version="2.0" metadata-complete="false"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <behavior>
+ <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
+ <behavior-class>org.richfaces.component.behavior.ClientValidatorImpl</behavior-class>
+ <behavior-extension>
+ <cdk:tag>
+ <cdk:tag-name>validator</cdk:tag-name>
+ <cdk:tag-type>Facelets</cdk:tag-type>
+ </cdk:tag>
+ </behavior-extension>
+ </behavior>
+ <render-kit>
+ <client-behavior-renderer>
+ <client-behavior-renderer-type>org.richfaces.ClientValidatorRenderer</client-behavior-renderer-type>
+ <client-behavior-renderer-class>org.richfaces.renderkit.html.ClientValidatorRenderer</client-behavior-renderer-class>
+ </client-behavior-renderer>
+ </render-kit>
+ <faces-config-extension>
+ <cdk:taglib>
+ <cdk:shortName>csv</cdk:shortName>
+ <
cdk:uri>http://richfaces.org/csv</cdk:uri>
+ </cdk:taglib>
+ </faces-config-extension>
+
+</faces-config>
\ No newline at end of file
Property changes on: branches/RF-7654/ui/validator/ui/src/main/config/faces-config.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: branches/RF-7654/ui/validator/ui/src/main/config/messages.xml
===================================================================
--- branches/RF-7654/ui/validator/ui/src/main/config/messages.xml
(rev 0)
+++ branches/RF-7654/ui/validator/ui/src/main/config/messages.xml 2010-12-17 01:09:52 UTC
(rev 20630)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<faces-config version="2.0" metadata-complete="false"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
+
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <component>
+ <component-type>org.richfaces.Message</component-type>
+ <component-class>org.richfaces.component.html.HtmlMessage</component-class>
+ <component-extension>
+ <cdk:generate>true</cdk:generate>
+ <cdk:base-class>javax.faces.component.UIMessage</cdk:base-class>
+ <cdk:component-family>javax.faces.Message</cdk:component-family>
+
<cdk:renderer-type>org.richfaces.MessageRenderer</cdk:renderer-type>
+ <cdk:tag>
+ <cdk:tag-name>message</cdk:tag-name>
+ <cdk:tag-type>Facelets</cdk:tag-type>
+ </cdk:tag>
+ </component-extension>
+ </component>
+</faces-config>
Property changes on: branches/RF-7654/ui/validator/ui/src/main/config/messages.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/RF-7654/ui/validator/ui/src/main/java/org/richfaces/renderkit/MessageRendererBase.java
===================================================================
---
branches/RF-7654/ui/validator/ui/src/main/java/org/richfaces/renderkit/MessageRendererBase.java
(rev 0)
+++
branches/RF-7654/ui/validator/ui/src/main/java/org/richfaces/renderkit/MessageRendererBase.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -0,0 +1,152 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * 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.
+ */
+
+package org.richfaces.renderkit;
+
+import java.util.Iterator;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.application.FacesMessage.Severity;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.render.Renderer;
+
+import org.richfaces.renderkit.util.RendererUtils;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterators;
+import com.google.common.collect.Lists;
+import com.google.common.collect.UnmodifiableIterator;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class MessageRendererBase extends Renderer {
+
+ private static final ImmutableMap<Severity, SeverityAttributes> SEVERITY_MAP =
ImmutableMap
+ .of(FacesMessage.SEVERITY_INFO,
+ attrs("infoStyle", "infoClass",
"infoMarkerStyle", "infoMarkerClass", "infoLabelStyle",
"infoLabelClass"),
+ FacesMessage.SEVERITY_WARN,
+ attrs("warnStyle", "warnClass",
"warnMarkerStyle", "warnMarkerClass", "warnLabelStyle",
"warnLabelClass"),
+ FacesMessage.SEVERITY_ERROR,
+ attrs("errorStyle", "errorClass",
"errorMarkerStyle", "errorMarkerClass", "errorLabelStyle",
+ "errorLabelClass"),
+ FacesMessage.SEVERITY_FATAL,
+ attrs("fatalStyle", "fatalClass",
"fatalMarkerStyle", "fatalMarkerClass", "fatalLabelStyle",
+ "fatalLabelClass"));
+
+ protected Iterator<FacesMessage> getMessages(FacesContext context, String
forClientId, UIComponent component) {
+
+ Iterator<FacesMessage> msgIter;
+
+ if (forClientId != null) {
+
+ if (forClientId.length() != 0) {
+
+ UIComponent result =
RendererUtils.getInstance().findComponentFor(component, forClientId);
+ if (result == null) {
+ msgIter = Iterators.emptyIterator();
+ } else {
+ msgIter = context.getMessages(result.getClientId(context));
+ }
+
+ } else {
+ msgIter = context.getMessages(null);
+ }
+
+ } else {
+ msgIter = context.getMessages();
+ }
+
+ return msgIter;
+ }
+
+ /**
+ * <p class="changed_added_4_0">TODO - make Generator aware of
Iterator.</p>
+ * @param context
+ * @param component
+ * @return
+ */
+ protected Iterable<FacesMessage> getVisibleMessages(FacesContext context,
UIComponent component) {
+ String forId = getFor(component);
+ Iterator<FacesMessage> messages = getMessages(context, forId, component);
+ UnmodifiableIterator<FacesMessage> filteredMessages =
+ Iterators.filter(messages, getMessagesFilter(context, component));
+ return Lists.newArrayList(filteredMessages);
+
+ }
+
+ private Predicate<FacesMessage> getMessagesFilter(FacesContext context,
UIComponent component) {
+
+ Object levelName = component.getAttributes().get("level");
+ final Severity level =
+ (Severity) (FacesMessage.VALUES_MAP.containsKey(levelName) ?
FacesMessage.VALUES_MAP.get(levelName)
+ : FacesMessage.SEVERITY_INFO);
+ return new Predicate<FacesMessage>() {
+ public boolean apply(FacesMessage input) {
+ return input.getSeverity().compareTo(level) >= 0;
+ }
+ };
+ }
+
+ private String getFor(UIComponent component) {
+ return (String) component.getAttributes().get("for");
+ }
+
+ protected void encodeMessage(FacesContext facesContext, UIComponent component, Object
msg) {
+ // TODO fix generator to properly detect iteration variable type
+ FacesMessage message = (FacesMessage) msg;
+ }
+
+ static SeverityAttributes attrs(String styleAttribute, String classAttribute, String
markerStyleAttribute,
+ String markerClassAttribute, String labelStyleAttribute, String
labelClassAttribute) {
+ SeverityAttributes attrs =
+ new SeverityAttributes(styleAttribute, classAttribute, markerStyleAttribute,
markerClassAttribute,
+ labelStyleAttribute, labelClassAttribute);
+ return attrs;
+ }
+
+ private static final class SeverityAttributes {
+ private final String styleAttribute;
+ private final String classAttribute;
+ private final String markerStyleAttribute;
+ private final String markerClassAttribute;
+ private final String labelStyleAttribute;
+ private final String labelClassAttribute;
+
+ private SeverityAttributes(String styleAttribute2, String classAttribute2, String
markerStyleAttribute2,
+ String markerClassAttribute2, String labelStyleAttribute2, String
labelClassAttribute2) {
+ this.styleAttribute = styleAttribute2;
+ this.classAttribute = classAttribute2;
+ this.markerStyleAttribute = markerStyleAttribute2;
+ this.markerClassAttribute = markerClassAttribute2;
+ this.labelStyleAttribute = labelStyleAttribute2;
+ this.labelClassAttribute = labelClassAttribute2;
+ }
+ }
+}
Property changes on:
branches/RF-7654/ui/validator/ui/src/main/java/org/richfaces/renderkit/MessageRendererBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
===================================================================
--- branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml 2010-12-16
22:32:17 UTC (rev 20629)
+++ branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml 2010-12-17
01:09:52 UTC (rev 20630)
@@ -1,15 +0,0 @@
-<?xml-stylesheet type="text/xsl" href=""?>
-<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
- version="2.0">
- <
namespace>http://richfaces.org/csv</namespace>
-
- <tag>
- <tag-name>validator</tag-name>
- <behavior>
- <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
- </behavior>
- </tag>
-
-</facelet-taglib>
Deleted: branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
---
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-12-17
01:09:52 UTC (rev 20630)
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<faces-config version="2.0" metadata-complete="false"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/extensions"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-<behavior>
- <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
-
<behavior-class>org.richfaces.component.behavior.ClientValidatorImpl</behavior-class>
-</behavior>
-<render-kit>
- <client-behavior-renderer>
-
<client-behavior-renderer-type>org.richfaces.ClientValidatorRenderer</client-behavior-renderer-type>
-
<client-behavior-renderer-class>org.richfaces.renderkit.html.ClientValidatorRenderer</client-behavior-renderer-class>
- </client-behavior-renderer>
-</render-kit>
-</faces-config>
\ No newline at end of file
Modified:
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/csv.js
===================================================================
---
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/csv.js 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/csv.js 2010-12-17
01:09:52 UTC (rev 20630)
@@ -22,18 +22,16 @@
$.extend(rf.csv, {
RE_DIGITS: /^-?\d+$/,
RE_FLOAT: /^(-?\d+)?(\.(\d+)?(e[+-]?\d+)?)?$/,
- MESSAGE_EVENT_NAME: "onmessage."+rf.Event.RICH_NAMESPACE,
+ MESSAGE_EVENT_NAME: "onmessage",
// Messages API
getMessage :function(facesMessage,values){
return
{detail:_interpolateMessage(facesMessage.detail,values),summary:_interpolateMessage(facesMessage.summary,values)};
},
sendMessage: function (componentId, message) {
- rf.Event.fireById(document, rf.csv.MESSAGE_EVENT_NAME, message);
- rf.Event.fireById(componentId, rf.csv.MESSAGE_EVENT_NAME, message);
+ rf.Event.fire(window.document, rf.csv.MESSAGE_EVENT_NAME, {componentId:componentId,
message:message});
},
clearMessage: function (componentId) {
- rf.Event.fireById(document, rf.csv.MESSAGE_EVENT_NAME, message);
- rf.Event.fireById(componentId, rf.csv.MESSAGE_EVENT_NAME, message);
+ rf.Event.fire(window.document, rf.csv.MESSAGE_EVENT_NAME, {componentId:componentId,
message:''});
},
getValue: function (clientId, element){
var value;
Added:
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js
===================================================================
---
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js
(rev 0)
+++
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js 2010-12-17
01:09:52 UTC (rev 20630)
@@ -0,0 +1,77 @@
+(function($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ // Constructor definition
+ rf.ui.Base = function(componentId, options, defaultOptions) {
+ this.namespace = "."+rf.Event.createNamespace(this.name, componentId);
+ // call constructor of parent class
+ $super.constructor.call(this, componentId);
+ this.options = $.extend(this.options, defaultOptions, options);
+ this.attachToDom();
+ this.__bindEventHandlers();
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.BaseComponent.extend(rf.ui.Base);
+
+ // define super class link
+ var $super = rf.ui.Base.$super;
+
+ $.extend(rf.ui.Base.prototype, {
+ __bindEventHandlers: function () {
+ },
+ destroy: function () {
+ rf.Event.unbind(this.id, this.namespace);
+ $super.destroy.call(this);
+ }
+ });
+
+})(jQuery, window.RichFaces || (window.RichFaces={}));
+
+(function($, rf) {
+
+ // Constructor definition
+ rf.ui.Message = function(componentId, options) {
+ // call constructor of parent class
+ $super.constructor.call(this, componentId, options, defaultOptions);
+ };
+
+ // Extend component class and add protected methods from parent class to our container
+ rf.ui.Base.extend(rf.ui.Message);
+
+ // define super class link
+ var $super = rf.ui.Message.$super;
+
+ var defaultOptions = {
+
+ };
+
+ var componentHash = {};
+ var componentIndex = 0;
+
+ var onMessage = function (event, element, data) {
+ if (!this.options.forComponentId) {
+ var index = componentHash[data.componentId];
+ if (typeof index != undefined) {
+ $(rf.getDomElement(this.id+":Content"+index)).remove();
+ }
+ var content = content = $(rf.getDomElement(this.id+":Content"));
+
+ componentIndex ++;
+ if (data.message) content.append('<li
id="'+this.id+":Content"+componentIndex+'">'+data.message+'</li>');
+ componentHash[data.componentId] = componentIndex;
+
+ } else if (this.options.forComponentId==data.componentId) {
+ rf.getDomElement(this.id+":Content").innerHTML = data.message ?
'<li>'+data.message+'</li>' : '';
+ }
+ }
+
+ $.extend(rf.ui.Message.prototype, {
+ name: "Message",
+ __bindEventHandlers: function () {
+ rf.Event.bind(window.document, rf.Event.MESSAGE_EVENT_TYPE+this.namespace, onMessage,
this);
+ }
+ });
+
+})(jQuery, window.RichFaces || (window.RichFaces={}));
\ No newline at end of file
Property changes on:
branches/RF-7654/ui/validator/ui/src/main/resources/META-INF/resources/org.richfaces/message.js
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-7654/ui/validator/ui/src/main/templates/message.template.xml
===================================================================
--- branches/RF-7654/ui/validator/ui/src/main/templates/message.template.xml
(rev 0)
+++ branches/RF-7654/ui/validator/ui/src/main/templates/message.template.xml 2010-12-17
01:09:52 UTC (rev 20630)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc. and individual contributors
+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.
+-->
+<cdk:root
xmlns="http://jboss.org/schema/richfaces/cdk/xhtml-el"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core"
+
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
+
xmlns:xi="http://www.w3.org/2001/XInclude">
+ <cc:interface>
+ <cdk:class>org.richfaces.renderkit.html.HtmlMessageRenderer</cdk:class>
+ <cdk:superclass>org.richfaces.renderkit.MessageRendererBase</cdk:superclass>
+ <cdk:component-family>javax.faces.Message</cdk:component-family>
+ <cdk:renderer-type>org.richfaces.MessageRenderer</cdk:renderer-type>
+ <cdk:resource-dependency library="org.richfaces"
name="base-component.reslib" />
+ <cdk:resource-dependency library="org.richfaces"
name="message.js" />
+ </cc:interface>
+ <cc:implementation>
+ <span id="#{clientId}" class="rf-msg
#{component.attributes['styleClass']}" cdk:passThroughWithExclusions="id
class">
+ <ul id="#{clientId}:Content" >
+ <c:forEach var="msg"
items="#{getVisibleMessages(facesContext,component)}">
+
<li><cdk:call>encodeMessage(facesContext,component,msg)</cdk:call></li>
+ </c:forEach>
+ </ul>
+ </span>
+ </cc:implementation>
+</cdk:root>
Property changes on:
branches/RF-7654/ui/validator/ui/src/main/templates/message.template.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java
===================================================================
---
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/MockTestBase.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -21,14 +21,15 @@
public abstract class MockTestBase {
@Rule
- public final Qunit qunit =
Qunit.builder().loadJsfResource("jquery.js").loadJsfResource("richfaces.js")
-
.loadJsfResource("richfaces-event.js").loadJsfResource("csv.js",
"org.richfaces").build();
+ public final Qunit qunit;
+
protected final RunParameters criteria;
protected MockFacesEnvironment facesEnvironment;
protected UIComponent component;
public MockTestBase(RunParameters criteria) {
this.criteria = criteria;
+ this.qunit = createQunitPage().build();
}
@Before
@@ -59,6 +60,11 @@
return criteria.getOptions();
}
+ protected org.jboss.test.qunit.Qunit.Builder createQunitPage() {
+ return
Qunit.builder().loadJsfResource("jquery.js").loadJsfResource("richfaces.js")
+
.loadJsfResource("richfaces-event.js").loadJsfResource("csv.js",
"org.richfaces");
+ }
+
protected abstract String getJavaScriptFunctionName();
protected static List<RunParameters[]> options(RunParameters ...criterias){
Added:
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/MessageTestBase.java
===================================================================
---
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/MessageTestBase.java
(rev 0)
+++
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/MessageTestBase.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -0,0 +1,52 @@
+package org.richfaces.javascript.client.message;
+
+import org.ajax4jsf.javascript.JSFunction;
+import org.jboss.test.qunit.Qunit;
+import org.jboss.test.qunit.Qunit.Builder;
+import org.junit.Before;
+import org.junit.Rule;
+import org.richfaces.javascript.Message;
+
+public class MessageTestBase {
+
+ @Rule
+ public final Qunit qunit;
+
+ public static final String COMPONENT = "component";
+
+ public static final String MY_MESSAGE = "myMessage";
+
+ public MessageTestBase() {
+ this.qunit = createQunitPage().build();
+ }
+
+ public void setUpMessage(){
+ qunit.runScript("new RichFaces.ui.Message(\"" + MY_MESSAGE +
"\", {forComponentId:\"" + COMPONENT + "\"})");
+ }
+
+ protected Builder createQunitPage() {
+ return
Qunit.builder().loadJsfResource("jquery.js").loadJsfResource("richfaces.js")
+
.loadJsfResource("richfaces-event.js").loadJsfResource("richfaces-base-component.js").
+ loadJsfResource("csv.js",
"org.richfaces").loadJsfResource("message.js",
"org.richfaces").content("<div id=\"" + MY_MESSAGE +
"\" ><ul id=\"" + MY_MESSAGE +
":Content\">"+getMessageContent()+"</ul></div>");
+ }
+
+
+ protected String getMessageContent() {
+ return "";
+ }
+
+ protected Object sendMessage() {
+ setUpMessage();
+ JSFunction clientSideFunction = new JSFunction("RichFaces.csv." +
getJavaScriptFunctionName(),COMPONENT,getErrorMessage());
+ return qunit.runScript(clientSideFunction.toScript());
+
+ }
+ protected String getJavaScriptFunctionName() {
+ return "sendMessage";
+ }
+
+ protected Message getErrorMessage() {
+ return new Message(2,"error","script error");
+ }
+
+}
Property changes on:
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/MessageTestBase.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/SendMessageTest.java
===================================================================
---
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/SendMessageTest.java
(rev 0)
+++
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/SendMessageTest.java 2010-12-17
01:09:52 UTC (rev 20630)
@@ -0,0 +1,50 @@
+/*
+ * $Id$
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * 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.
+ */
+
+package org.richfaces.javascript.client.message;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class SendMessageTest extends MessageTestBase {
+
+ @Test
+ public void testSend() throws Exception {
+ sendMessage();
+ HtmlPage page = qunit.getPage();
+ HtmlElement htmlElement = page.getElementById(MY_MESSAGE+":Content");
+ assertNotNull(htmlElement);
+ String text = htmlElement.asText();
+ assertTrue(text.contains(getErrorMessage().getSummary()));
+ }
+
+}
Property changes on:
branches/RF-7654/ui/validator/ui/src/test/java/org/richfaces/javascript/client/message/SendMessageTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/RF-7654/ui/validator/ui/src/test/resources/1.html
===================================================================
--- branches/RF-7654/ui/validator/ui/src/test/resources/1.html
(rev 0)
+++ branches/RF-7654/ui/validator/ui/src/test/resources/1.html 2010-12-17 01:09:52 UTC
(rev 20630)
@@ -0,0 +1,48 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html
xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
+ <script type="text/javascript"
src="jquery.js"></script>
+ <script type="text/javascript"
src="richfaces.js"></script>
+ <script type="text/javascript"
src="richfaces-event.js"></script>
+ <script type="text/javascript"
src="richfaces-base-component.js"></script>
+ <script type="text/javascript"
src="richfaces-csv.js"></script>
+ <script type="text/javascript"
src="richfaces-message.js"></script>
+ </head>
+ <body>
+ <form>
+ Global Message Component:<br />
+ <div id="myMessage1" style="border:1px dotted #000000; margin:4px;
padding:2px;">
+ <ul id="myMessage1Content"></ul>
+ <script type="text/javascript">
+ new RichFaces.ui.Message("myMessage1", {});
+ </script>
+ </div>
+ <br />
+ Message Component for component1:<br />
+ <div id="myMessage2" style="border:1px dotted #000000; margin:4px;
padding:2px;">
+ <ul id="myMessage2Content"></ul>
+ <script type="text/javascript">
+ new RichFaces.ui.Message("myMessage2",
{forComponentId:"component1"});
+ </script>
+
+ </div>
+ <br />
+ Message Component for component2:<br />
+ <div id="myMessage3" style="border:1px dotted #000000; margin:4px;
padding:2px;">
+ <ul id="myMessage3Content"></ul>
+ <script type="text/javascript">
+ new RichFaces.ui.Message("myMessage3",
{forComponentId:"component2"});
+ </script>
+
+ </div>
+ <br />
+ <input type="button" value="send message for component1" onclick
= "RichFaces.Event.fire(window.document, 'onmessage',
{componentId:'component1', message:'Message for component1'});"
/>
+ <input type="button" value="send message for component2" onclick
= "RichFaces.Event.fire(window.document, 'onmessage',
{componentId:'component2', message:'Message for component2'});"
/>
+ <br />
+ <input type="button" value="clear message for component1" onclick
= "RichFaces.Event.fire(window.document, 'onmessage',
{componentId:'component1', message:''});" />
+ <input type="button" value="clear message for component2" onclick
= "RichFaces.Event.fire(window.document, 'onmessage',
{componentId:'component2', message:''});" />
+
+ </form>
+ </body>
+</html>
Property changes on: branches/RF-7654/ui/validator/ui/src/test/resources/1.html
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/RF-7654/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml
===================================================================
---
branches/RF-7654/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml 2010-12-16
22:32:17 UTC (rev 20629)
+++
branches/RF-7654/ui/validator/ui/src/test/resources/org/richfaces/component/client-test.xhtml 2010-12-17
01:09:52 UTC (rev 20630)
@@ -10,7 +10,7 @@
<csv:validator event="keyup" />
</h:inputText>
<h:outputText id="out"
value="#{test.value}"></h:outputText>
- <h:message id="message" for="text" />
+ <csv:message id="message" for="text" />
</h:form>
</h:body>
</html>