Commit 7c2d851ad077a468106e2d2dd486d6bcc6cc8a78

Authored by bernard
1 parent b08cfa90

JavaScript updates and some more cosmetics.

@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <superclass>org.richfaces.component.UINotify</superclass> 13 <superclass>org.richfaces.component.UINotify</superclass>
14 <description> 14 <description>
15 <![CDATA[ 15 <![CDATA[
16 - ]]> 16 + ]]>
17 </description> 17 </description>
18 <renderer generate="false" override="true"> 18 <renderer generate="false" override="true">
19 <name>org.richfaces.NotifyRenderer</name> 19 <name>org.richfaces.NotifyRenderer</name>
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> 31 <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
32 </test> 32 </test>
33 --> 33 -->
34 - 34 +
35 </tag> 35 </tag>
36 &ui_component_attributes; 36 &ui_component_attributes;
37 &ajax_output_attributes; 37 &ajax_output_attributes;
@@ -50,8 +50,8 @@ @@ -50,8 +50,8 @@
50 </description> 50 </description>
51 <defaultvalue>""</defaultvalue> 51 <defaultvalue>""</defaultvalue>
52 </property> 52 </property>
53 -  
54 - 53 +
  54 +
55 <property> 55 <property>
56 <name>styleClass</name> 56 <name>styleClass</name>
57 <classname>java.lang.String</classname> 57 <classname>java.lang.String</classname>
@@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
13 <superclass>org.richfaces.component.UINotifyMessages</superclass> 13 <superclass>org.richfaces.component.UINotifyMessages</superclass>
14 <description> 14 <description>
15 <![CDATA[ 15 <![CDATA[
16 - ]]> 16 + ]]>
17 </description> 17 </description>
18 <renderer generate="false" override="true"> 18 <renderer generate="false" override="true">
19 <name>org.richfaces.NotifyMessagesRenderer</name> 19 <name>org.richfaces.NotifyMessagesRenderer</name>
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> 31 <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
32 </test> 32 </test>
33 --> 33 -->
34 - 34 +
35 </tag> 35 </tag>
36 &ui_component_attributes; 36 &ui_component_attributes;
37 &ajax_output_attributes; 37 &ajax_output_attributes;
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 -<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN" "http://labs.jboss.com/jbossrichfaces/component-config.dtd" > 2 +<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
  3 + "http://labs.jboss.com/jbossrichfaces/component-config.dtd" >
3 <components> 4 <components>
4 <component> 5 <component>
5 <name>org.richfaces.NotifyStack</name> 6 <name>org.richfaces.NotifyStack</name>
@@ -8,7 +9,7 @@ @@ -8,7 +9,7 @@
8 <superclass>org.richfaces.component.UINotifyStack</superclass> 9 <superclass>org.richfaces.component.UINotifyStack</superclass>
9 <description> 10 <description>
10 <![CDATA[ 11 <![CDATA[
11 - ]]> 12 + ]]>
12 </description> 13 </description>
13 <renderer generate="false" override="false"> 14 <renderer generate="false" override="false">
14 <name>org.richfaces.NotifyStackRenderer</name> 15 <name>org.richfaces.NotifyStackRenderer</name>
@@ -26,7 +27,7 @@ @@ -26,7 +27,7 @@
26 <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname> 27 <superclassname>org.ajax4jsf.tests.AbstractJspTestCase</superclassname>
27 </test> 28 </test>
28 --> 29 -->
29 - 30 +
30 </tag> 31 </tag>
31 &ui_component_attributes; 32 &ui_component_attributes;
32 <property> 33 <property>
  1 +/*
  2 + * JBoss, Home of Professional Open Source
  3 + * Copyright , Red Hat, Inc. and individual contributors
  4 + * by the @authors tag. See the copyright.txt in the distribution for a
  5 + * full listing of individual contributors.
  6 + *
  7 + * This is free software; you can redistribute it and/or modify it
  8 + * under the terms of the GNU Lesser General Public License as
  9 + * published by the Free Software Foundation; either version 2.1 of
  10 + * the License, or (at your option) any later version.
  11 + *
  12 + * This software is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15 + * Lesser General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Lesser General Public
  18 + * License along with this software; if not, write to the Free
  19 + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20 + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21 + */
  22 +
1 package org.richfaces.component; 23 package org.richfaces.component;
2 24
  25 +import org.richfaces.cdk.annotations.Attribute;
  26 +
3 public interface NotifyAttributes { 27 public interface NotifyAttributes {
4 28
5 - public abstract boolean isSticky(); 29 + @Attribute
  30 + boolean isSticky();
6 31
7 - public abstract void setSticky(boolean sticky); 32 + void setSticky(boolean sticky);
8 33
9 - public abstract Integer getStayTime(); 34 + @Attribute
  35 + Integer getStayTime();
10 36
11 - public abstract void setStayTime(Integer time); 37 + void setStayTime(Integer time);
12 38
13 - public abstract Integer getDelay(); 39 + @Attribute
  40 + Integer getDelay();
14 41
15 - public abstract void setDelay(Integer delay); 42 + void setDelay(Integer delay);
16 43
17 - public abstract String getStyleClass(); 44 + @Attribute
  45 + String getStyleClass();
18 46
19 - public abstract void setStyleClass(String styleClass); 47 + void setStyleClass(String styleClass);
20 48
21 - public abstract String getAppearAnimation(); 49 + @Attribute
  50 + String getAppearAnimation();
22 51
23 - public abstract void setAppearAnimation(String appearAnimation); 52 + void setAppearAnimation(String appearAnimation);
24 53
25 - public abstract String getHideAnimation(); 54 + @Attribute
  55 + String getHideAnimation();
26 56
27 - public abstract void setHideAnimation(String hideAnimation); 57 + void setHideAnimation(String hideAnimation);
28 58
29 - public abstract Integer getAnimationSpeed(); 59 + @Attribute
  60 + Integer getAnimationSpeed();
30 61
31 - public abstract void setAnimationSpeed(Integer animationSpeed); 62 + void setAnimationSpeed(Integer animationSpeed);
32 63
33 - public abstract boolean isShowHistory(); 64 + @Attribute
  65 + boolean isShowHistory();
34 66
35 - public abstract void setShowHistory(boolean showHistory); 67 + void setShowHistory(boolean showHistory);
36 68
37 - public abstract boolean isNonblocking(); 69 + @Attribute
  70 + boolean isNonblocking();
38 71
39 - public abstract void setNonblocking(boolean nonblocking); 72 + void setNonblocking(boolean nonblocking);
40 73
41 - public abstract boolean isShowShadow(); 74 + @Attribute
  75 + boolean isShowShadow();
42 76
43 - public abstract void setShowShadow(boolean showShadow); 77 + void setShowShadow(boolean showShadow);
44 78
45 - public abstract boolean isShowCloseButton(); 79 + @Attribute(defaultValue = "true")
  80 + boolean isShowCloseButton();
46 81
47 - public abstract void setShowCloseButton(boolean showCloseButton); 82 + void setShowCloseButton(boolean showCloseButton);
48 83
49 - public abstract Double getNonblockingOpacity(); 84 + @Attribute
  85 + Double getNonblockingOpacity();
50 86
51 - public abstract void setNonblockingOpacity(Double nonblockingOpacity); 87 + void setNonblockingOpacity(Double nonblockingOpacity);
52 88
53 - public abstract String getStack(); 89 + @Attribute
  90 + String getStack();
54 91
55 - public abstract void setStack(String stack); 92 + void setStack(String stack);
56 } 93 }
@@ -7,6 +7,8 @@ public abstract class UINotify extends UIComponentBase implements NotifyAttribut @@ -7,6 +7,8 @@ public abstract class UINotify extends UIComponentBase implements NotifyAttribut
7 public static final String COMPONENT_TYPE = "org.richfaces.Notify"; 7 public static final String COMPONENT_TYPE = "org.richfaces.Notify";
8 public static final String COMPONENT_FAMILY = "org.richfaces.Notify"; 8 public static final String COMPONENT_FAMILY = "org.richfaces.Notify";
9 9
  10 + public static final double DEFAULT_NONBLOCKING_OPACITY = .2;
  11 +
10 public abstract String getTitle(); 12 public abstract String getTitle();
11 13
12 public abstract void setTitle(String title); 14 public abstract void setTitle(String title);
1 package org.richfaces.component; 1 package org.richfaces.component;
2 2
3 -import javax.faces.component.UIMessages;  
4 import org.ajax4jsf.component.AjaxOutput; 3 import org.ajax4jsf.component.AjaxOutput;
5 4
  5 +import javax.faces.component.UIMessages;
  6 +
6 public abstract class UINotifyMessages extends UIMessages implements AjaxOutput, NotifyAttributes { 7 public abstract class UINotifyMessages extends UIMessages implements AjaxOutput, NotifyAttributes {
7 8
8 public static final String COMPONENT_TYPE = "org.richfaces.NotifyMessages"; 9 public static final String COMPONENT_TYPE = "org.richfaces.NotifyMessages";
  1 +/*
  2 + * JBoss, Home of Professional Open Source
  3 + * Copyright , Red Hat, Inc. and individual contributors
  4 + * by the @authors tag. See the copyright.txt in the distribution for a
  5 + * full listing of individual contributors.
  6 + *
  7 + * This is free software; you can redistribute it and/or modify it
  8 + * under the terms of the GNU Lesser General Public License as
  9 + * published by the Free Software Foundation; either version 2.1 of
  10 + * the License, or (at your option) any later version.
  11 + *
  12 + * This software is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15 + * Lesser General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Lesser General Public
  18 + * License along with this software; if not, write to the Free
  19 + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20 + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21 + */
  22 +
1 package org.richfaces.renderkit.html; 23 package org.richfaces.renderkit.html;
2 24
  25 +import org.ajax4jsf.renderkit.RendererUtils;
  26 +import org.ajax4jsf.renderkit.RendererUtils.HTML;
  27 +import org.richfaces.component.UINotify;
  28 +import org.richfaces.component.UINotifyMessages;
  29 +
  30 +import javax.faces.application.FacesMessage;
3 import javax.faces.component.UIComponent; 31 import javax.faces.component.UIComponent;
4 import javax.faces.context.FacesContext; 32 import javax.faces.context.FacesContext;
  33 +import javax.faces.context.ResponseWriter;
5 import java.io.IOException; 34 import java.io.IOException;
6 import java.util.Iterator; 35 import java.util.Iterator;
7 -import javax.faces.application.FacesMessage;  
8 -import javax.faces.context.ResponseWriter;  
9 -import org.ajax4jsf.renderkit.RendererUtils.HTML;  
10 -import org.richfaces.component.UINotify;  
11 -import org.richfaces.component.UINotifyMessages;  
12 36
13 public class NotifyMessagesRenderer extends NotifyRenderer { 37 public class NotifyMessagesRenderer extends NotifyRenderer {
14 38
@@ -17,7 +41,7 @@ public class NotifyMessagesRenderer extends NotifyRenderer { @@ -17,7 +41,7 @@ public class NotifyMessagesRenderer extends NotifyRenderer {
17 UINotifyMessages messagesComponent = (UINotifyMessages) component; 41 UINotifyMessages messagesComponent = (UINotifyMessages) component;
18 ResponseWriter writer = context.getResponseWriter(); 42 ResponseWriter writer = context.getResponseWriter();
19 writer.startElement(HTML.DIV_ELEM, null); 43 writer.startElement(HTML.DIV_ELEM, null);
20 - writer.writeAttribute(HTML.id_ATTRIBUTE, getUtils().clientId(context, component), "type"); 44 + writer.writeAttribute(HTML.id_ATTRIBUTE, RendererUtils.getInstance().clientId(context, component), "type");
21 Integer delay = messagesComponent.getDelay(); 45 Integer delay = messagesComponent.getDelay();
22 if (delay == null) { 46 if (delay == null) {
23 delay = 0; 47 delay = 0;
@@ -27,10 +51,12 @@ public class NotifyMessagesRenderer extends NotifyRenderer { @@ -27,10 +51,12 @@ public class NotifyMessagesRenderer extends NotifyRenderer {
27 interval = 0; 51 interval = 0;
28 } 52 }
29 53
30 - Iterator<FacesMessage> messages = messagesComponent.isGlobalOnly() ? context.getMessages(null) : context.getMessages(); 54 + Iterator<FacesMessage> messages = messagesComponent.isGlobalOnly()
  55 + ? context.getMessages(null) : context.getMessages();
31 while (messages.hasNext()) { 56 while (messages.hasNext()) {
32 FacesMessage msg = messages.next(); 57 FacesMessage msg = messages.next();
33 - UINotify notify = (UINotify) context.getApplication().createComponent(UINotify.COMPONENT_TYPE); 58 + UINotify notify = (UINotify) context.getApplication()
  59 + .createComponent(UINotify.COMPONENT_TYPE);
34 notify.setAnimationSpeed(messagesComponent.getAnimationSpeed()); 60 notify.setAnimationSpeed(messagesComponent.getAnimationSpeed());
35 notify.setAppearAnimation(messagesComponent.getAppearAnimation()); 61 notify.setAppearAnimation(messagesComponent.getAppearAnimation());
36 notify.setDelay(delay); 62 notify.setDelay(delay);
@@ -50,7 +76,7 @@ public class NotifyMessagesRenderer extends NotifyRenderer { @@ -50,7 +76,7 @@ public class NotifyMessagesRenderer extends NotifyRenderer {
50 notify.setText(msg.getDetail()); 76 notify.setText(msg.getDetail());
51 } 77 }
52 String styleClass = messagesComponent.getStyleClass(); 78 String styleClass = messagesComponent.getStyleClass();
53 - if(styleClass == null) { 79 + if (styleClass == null) {
54 styleClass = ""; 80 styleClass = "";
55 } 81 }
56 if (FacesMessage.SEVERITY_INFO.equals(msg.getSeverity())) { 82 if (FacesMessage.SEVERITY_INFO.equals(msg.getSeverity())) {
  1 +/*
  2 + * JBoss, Home of Professional Open Source
  3 + * Copyright , Red Hat, Inc. and individual contributors
  4 + * by the @authors tag. See the copyright.txt in the distribution for a
  5 + * full listing of individual contributors.
  6 + *
  7 + * This is free software; you can redistribute it and/or modify it
  8 + * under the terms of the GNU Lesser General Public License as
  9 + * published by the Free Software Foundation; either version 2.1 of
  10 + * the License, or (at your option) any later version.
  11 + *
  12 + * This software is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15 + * Lesser General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Lesser General Public
  18 + * License along with this software; if not, write to the Free
  19 + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20 + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21 + */
  22 +
1 package org.richfaces.renderkit.html; 23 package org.richfaces.renderkit.html;
2 24
3 -import javax.faces.component.UIComponent;  
4 -import javax.faces.context.FacesContext;  
5 -import javax.faces.context.ResponseWriter;  
6 -import java.io.IOException;  
7 -import java.util.*;  
8 import org.ajax4jsf.javascript.JSFunction; 25 import org.ajax4jsf.javascript.JSFunction;
9 import org.ajax4jsf.renderkit.HeaderResourcesRendererBase; 26 import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
10 import org.ajax4jsf.renderkit.RendererUtils.HTML; 27 import org.ajax4jsf.renderkit.RendererUtils.HTML;
@@ -12,24 +29,37 @@ import org.ajax4jsf.resource.InternetResource; @@ -12,24 +29,37 @@ import org.ajax4jsf.resource.InternetResource;
12 import org.richfaces.component.UINotify; 29 import org.richfaces.component.UINotify;
13 import org.richfaces.component.UINotifyStack; 30 import org.richfaces.component.UINotifyStack;
14 31
  32 +import javax.faces.component.UIComponent;
  33 +import javax.faces.context.FacesContext;
  34 +import javax.faces.context.ResponseWriter;
  35 +import java.io.IOException;
  36 +import java.util.Collection;
  37 +import java.util.Collections;
  38 +import java.util.HashMap;
  39 +import java.util.Map;
  40 +
15 public class NotifyRenderer extends HeaderResourcesRendererBase { 41 public class NotifyRenderer extends HeaderResourcesRendererBase {
16 42
17 - private static final Map<String, Object> defaults = new HashMap<String, Object>(); 43 + private static final Map<String, Object> DEFAULTS;
18 44
19 - {  
20 - defaults.put("pnotify_addclass", "");  
21 - defaults.put("pnotify_nonblock", false);  
22 - defaults.put("pnotify_nonblock_opacity", .2);  
23 - defaults.put("pnotify_history", true);  
24 - defaults.put("pnotify_animate_speed", "slow");  
25 - defaults.put("pnotify_opacity", 1);  
26 - defaults.put("pnotify_shadow", false);  
27 - defaults.put("pnotify_closer", true);  
28 - defaults.put("pnotify_hide", true);  
29 - defaults.put("pnotify_delay", 8000); 45 + static {
  46 + Map<String, Object> defaults = new HashMap<String, Object>();
  47 + defaults.put("styleClass", "");
  48 + defaults.put("nonblocking", false);
  49 + defaults.put("nonblockingOpacity", UINotify.DEFAULT_NONBLOCKING_OPACITY);
  50 + defaults.put("showHistory", true);
  51 + defaults.put("animationSpeed", "slow");
  52 + defaults.put("opacity", 1);
  53 + defaults.put("showShadow", false);
  54 + defaults.put("showCloseButton", true);
  55 + defaults.put("appearAnimation", "fade");
  56 + defaults.put("hideAnimation", "fade");
  57 + defaults.put("sticky", false);
  58 + defaults.put("stayTime", 8000);
30 defaults.put("delay", 0); 59 defaults.put("delay", 0);
31 - 60 + DEFAULTS = Collections.unmodifiableMap(defaults);
32 } 61 }
  62 +
33 private final InternetResource[] scripts = { 63 private final InternetResource[] scripts = {
34 getResource("/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js"), 64 getResource("/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js"),
35 getResource("/org/richfaces/renderkit/html/scripts/jquery.pnotify.js"), 65 getResource("/org/richfaces/renderkit/html/scripts/jquery.pnotify.js"),
@@ -60,29 +90,29 @@ public class NotifyRenderer extends HeaderResourcesRendererBase { @@ -60,29 +90,29 @@ public class NotifyRenderer extends HeaderResourcesRendererBase {
60 * Include only attributes that are actually set. 90 * Include only attributes that are actually set.
61 */ 91 */
62 Map<String, Object> options = new HashMap<String, Object>(); 92 Map<String, Object> options = new HashMap<String, Object>();
63 - addOptionIfSetAndNotDefault("pnotify_title", notify.getTitle(), options);  
64 - addOptionIfSetAndNotDefault("pnotify_text", notify.getText(), options);  
65 - addOptionIfSetAndNotDefault("pnotify_hide", !notify.isSticky(), options);  
66 - addOptionIfSetAndNotDefault("pnotify_delay", notify.getStayTime(), options); 93 + addOptionIfSetAndNotDefault("title", notify.getTitle(), options);
  94 + addOptionIfSetAndNotDefault("text", notify.getText(), options);
  95 + addOptionIfSetAndNotDefault("sticky", notify.isSticky(), options);
  96 + addOptionIfSetAndNotDefault("stayTime", notify.getStayTime(), options);
67 Map<String, Object> animationOptions = new HashMap<String, Object>(); 97 Map<String, Object> animationOptions = new HashMap<String, Object>();
68 - addOptionIfSetAndNotDefault("effect_in", notify.getAppearAnimation(), animationOptions);  
69 - addOptionIfSetAndNotDefault("effect_out", notify.getHideAnimation(), animationOptions);  
70 - addOptionIfSetAndNotDefault("pnotify_animation", animationOptions, options);  
71 - addOptionIfSetAndNotDefault("pnotify_animate_speed", notify.getAnimationSpeed(), options);  
72 - addOptionIfSetAndNotDefault("pnotify_nonblock", notify.isNonblocking(), options);  
73 - addOptionIfSetAndNotDefault("pnotify_nonblock_opacity", notify.getNonblockingOpacity(), options);  
74 - addOptionIfSetAndNotDefault("pnotify_history", notify.isShowHistory(), options);  
75 - addOptionIfSetAndNotDefault("pnotify_shadow", notify.isShowShadow(), options);  
76 - addOptionIfSetAndNotDefault("pnotify_closer", notify.isShowCloseButton(), options); 98 + addOptionIfSetAndNotDefault("appearAnimation", notify.getAppearAnimation(), animationOptions);
  99 + addOptionIfSetAndNotDefault("hideAnimation", notify.getHideAnimation(), animationOptions);
  100 + addOptionIfSetAndNotDefault("animation", animationOptions, options);
  101 + addOptionIfSetAndNotDefault("animationSpeed", notify.getAnimationSpeed(), options);
  102 + addOptionIfSetAndNotDefault("nonblocking", notify.isNonblocking(), options);
  103 + addOptionIfSetAndNotDefault("nonblockingOpacity", notify.getNonblockingOpacity(), options);
  104 + addOptionIfSetAndNotDefault("showHistory", notify.isShowHistory(), options);
  105 + addOptionIfSetAndNotDefault("showShadow", notify.isShowShadow(), options);
  106 + addOptionIfSetAndNotDefault("showCloseButton", notify.isShowCloseButton(), options);
77 UINotifyStack stack = getStackComponent(context, notify); 107 UINotifyStack stack = getStackComponent(context, notify);
78 if (stack != null) { 108 if (stack != null) {
79 - addOptionIfSetAndNotDefault("pnotify_stack", getUtils().clientId(context, stack), options); 109 + addOptionIfSetAndNotDefault("stack", getUtils().clientId(context, stack), options);
80 } 110 }
81 String styleClass = notify.getStyleClass(); 111 String styleClass = notify.getStyleClass();
82 if (styleClass == null) { 112 if (styleClass == null) {
83 styleClass = ""; 113 styleClass = "";
84 } 114 }
85 - addOptionIfSetAndNotDefault("pnotify_addclass", getStackStyleClass(context, notify) + " " + styleClass, options); 115 + addOptionIfSetAndNotDefault("styleClass", getStackStyleClass(context, notify) + " " + styleClass, options);
86 addOptionIfSetAndNotDefault("delay", notify.getDelay(), options); 116 addOptionIfSetAndNotDefault("delay", notify.getDelay(), options);
87 return options; 117 return options;
88 } 118 }
@@ -93,7 +123,10 @@ public class NotifyRenderer extends HeaderResourcesRendererBase { @@ -93,7 +123,10 @@ public class NotifyRenderer extends HeaderResourcesRendererBase {
93 } 123 }
94 124
95 protected void addOptionIfSetAndNotDefault(String optionName, Object value, Map<String, Object> options) { 125 protected void addOptionIfSetAndNotDefault(String optionName, Object value, Map<String, Object> options) {
96 - if (value != null && value != "" && !value.equals(defaults.get(optionName))) { 126 + if (value != null && !"".equals(value)
  127 + && !value.equals(DEFAULTS.get(optionName))
  128 + && !(value instanceof Collection && ((Collection) value).size() == 0)
  129 + && !(value instanceof Map && ((Map) value).size() == 0)) {
97 options.put(optionName, value); 130 options.put(optionName, value);
98 } 131 }
99 } 132 }
  1 +/*
  2 + * JBoss, Home of Professional Open Source
  3 + * Copyright , Red Hat, Inc. and individual contributors
  4 + * by the @authors tag. See the copyright.txt in the distribution for a
  5 + * full listing of individual contributors.
  6 + *
  7 + * This is free software; you can redistribute it and/or modify it
  8 + * under the terms of the GNU Lesser General Public License as
  9 + * published by the Free Software Foundation; either version 2.1 of
  10 + * the License, or (at your option) any later version.
  11 + *
  12 + * This software is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15 + * Lesser General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Lesser General Public
  18 + * License along with this software; if not, write to the Free
  19 + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20 + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21 + */
  22 +
1 package org.richfaces.renderkit.html; 23 package org.richfaces.renderkit.html;
2 24
  25 +import org.ajax4jsf.javascript.JSFunction;
  26 +import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
  27 +import org.ajax4jsf.renderkit.RendererUtils;
  28 +import org.ajax4jsf.resource.InternetResource;
  29 +import org.richfaces.component.UINotifyStack;
3 30
4 import javax.faces.component.UIComponent; 31 import javax.faces.component.UIComponent;
5 import javax.faces.context.FacesContext; 32 import javax.faces.context.FacesContext;
@@ -7,11 +34,6 @@ import javax.faces.context.ResponseWriter; @@ -7,11 +34,6 @@ import javax.faces.context.ResponseWriter;
7 import java.io.IOException; 34 import java.io.IOException;
8 import java.util.HashMap; 35 import java.util.HashMap;
9 import java.util.Map; 36 import java.util.Map;
10 -import org.ajax4jsf.javascript.JSFunction;  
11 -import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;  
12 -import org.ajax4jsf.renderkit.RendererUtils.HTML;  
13 -import org.ajax4jsf.resource.InternetResource;  
14 -import org.richfaces.component.UINotifyStack;  
15 37
16 public class NotifyStackRenderer extends HeaderResourcesRendererBase { 38 public class NotifyStackRenderer extends HeaderResourcesRendererBase {
17 39
@@ -25,12 +47,15 @@ public class NotifyStackRenderer extends HeaderResourcesRendererBase { @@ -25,12 +47,15 @@ public class NotifyStackRenderer extends HeaderResourcesRendererBase {
25 return; 47 return;
26 } 48 }
27 ResponseWriter writer = context.getResponseWriter(); 49 ResponseWriter writer = context.getResponseWriter();
28 - writer.startElement(HTML.SCRIPT_ELEM, null);  
29 - writer.writeText(new JSFunction("RichFaces.NotifyStack.register", getUtils().clientId(context, component), getOptions(context, (UINotifyStack) component)), null);  
30 - writer.endElement(HTML.SCRIPT_ELEM); 50 + writer.startElement(RendererUtils.HTML.SCRIPT_ELEM, null);
  51 + writer.writeText(new JSFunction("RichFaces.NotifyStack.register",
  52 + RendererUtils.getInstance().clientId(context, component),
  53 + getOptions((UINotifyStack) component)
  54 + ), null);
  55 + writer.endElement(RendererUtils.HTML.SCRIPT_ELEM);
31 } 56 }
32 57
33 - protected Map<String, Object> getOptions(FacesContext context, UINotifyStack stack) throws IOException { 58 + protected Map<String, Object> getOptions(UINotifyStack stack) throws IOException {
34 /** 59 /**
35 * Include only attributes that are actually set. 60 * Include only attributes that are actually set.
36 */ 61 */
@@ -42,7 +67,7 @@ public class NotifyStackRenderer extends HeaderResourcesRendererBase { @@ -42,7 +67,7 @@ public class NotifyStackRenderer extends HeaderResourcesRendererBase {
42 } 67 }
43 68
44 protected void addOptionIfSet(String optionName, Object value, Map<String, Object> options) { 69 protected void addOptionIfSet(String optionName, Object value, Map<String, Object> options) {
45 - if (value != null && value != "") { 70 + if (value != null && !"".equals(value)) {
46 options.put(optionName, value); 71 options.put(optionName, value);
47 } 72 }
48 } 73 }
  1 +/*
  2 + * JBoss, Home of Professional Open Source
  3 + * Copyright , Red Hat, Inc. and individual contributors
  4 + * by the @authors tag. See the copyright.txt in the distribution for a
  5 + * full listing of individual contributors.
  6 + *
  7 + * This is free software; you can redistribute it and/or modify it
  8 + * under the terms of the GNU Lesser General Public License as
  9 + * published by the Free Software Foundation; either version 2.1 of
  10 + * the License, or (at your option) any later version.
  11 + *
  12 + * This software is distributed in the hope that it will be useful,
  13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15 + * Lesser General Public License for more details.
  16 + *
  17 + * You should have received a copy of the GNU Lesser General Public
  18 + * License along with this software; if not, write to the Free
  19 + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20 + * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21 + */
  22 +
1 window.RichFaces = window.RichFaces || {}; 23 window.RichFaces = window.RichFaces || {};
2 -RichFaces.NotifyStack = (function(){ 24 +RichFaces.NotifyStack = (function() {
3 var stacks = {}; 25 var stacks = {};
4 return { 26 return {
5 - register: function(id,stack) { 27 + register: function(id, stack) {
6 var existingStack = stacks[id]; 28 var existingStack = stacks[id];
7 - if(existingStack != null) {  
8 - stack = jQuery.extend(existingStack,stack); 29 + if (existingStack != null) {
  30 + stack = jQuery.extend(existingStack, stack);
9 delete stack.addpos1; 31 delete stack.addpos1;
10 delete stack.addpos2; 32 delete stack.addpos2;
11 delete stack.animation; 33 delete stack.animation;
@@ -14,13 +36,14 @@ RichFaces.NotifyStack = (function(){ @@ -14,13 +36,14 @@ RichFaces.NotifyStack = (function(){
14 delete stack.nextpos1; 36 delete stack.nextpos1;
15 delete stack.nextpos2; 37 delete stack.nextpos2;
16 } 38 }
  39 + stack.id = id;
17 stacks[id] = stack; 40 stacks[id] = stack;
18 }, 41 },
19 getStack: function(id) { 42 getStack: function(id) {
20 var stack = stacks[id]; 43 var stack = stacks[id];
21 - if(stack == null) {  
22 - stack = {};  
23 - stacks[id] = stack; 44 + if (stack == null) {
  45 + stack = jQuery.extend({}, jQuery.pnotify.defaults.pnotify_stack);
  46 + this.register(id, stack);
24 } 47 }
25 return stack; 48 return stack;
26 } 49 }
@@ -28,16 +51,124 @@ RichFaces.NotifyStack = (function(){ @@ -28,16 +51,124 @@ RichFaces.NotifyStack = (function(){
28 })(); 51 })();
29 52
30 RichFaces.Notify = function(options) { 53 RichFaces.Notify = function(options) {
31 - if(options!=null && typeof options.pnotify_stack == "string") {  
32 - options.pnotify_stack = RichFaces.NotifyStack.getStack(options.pnotify_stack); 54 + /**
  55 + * Copies attributes from one objects to other object, but
  56 + * can change the name of target attributes.
  57 + */
  58 + function extend(target, source, translation) {
  59 + for (var attr in source) {
  60 + var targetAttr = translation[attr] != null ? translation[attr] : attr;
  61 + target[targetAttr] = source[attr];
  62 + if (attr != 'stack' && target[targetAttr] instanceof Object) {
  63 + target[targetAttr] = extend({}, target[targetAttr], translation);
  64 + }
  65 + }
  66 + return target;
  67 + }
  68 +
  69 + options = jQuery.extend({stack:'default'}, options);
  70 + if (options != null && typeof options.stack == "string") {
  71 + options.stack = RichFaces.NotifyStack.getStack(options.stack);
  72 + }
  73 + var delegateOptions = extend({}, options, {
  74 + 'title':'pnotify_title' ,
  75 + 'text': 'pnotify_text',
  76 + 'styleClass': 'pnotify_addclass',
  77 + 'nonblocking': 'pnotify_nonblock',
  78 + 'nonblockingOpacity': 'pnotify_nonblock_opacity',
  79 + 'showHistory': 'pnotify_history',
  80 + 'animation': 'pnotify_animation',
  81 + 'appearAnimation': 'effect_in',
  82 + 'hideAnimation': 'effect_out',
  83 + 'animationSpeed': 'pnotify_animate_speed',
  84 + 'opacity': 'pnotify_opacity',
  85 + 'showShadow': 'pnotify_shadow',
  86 + 'showCloseButton': 'pnotify_closer',
  87 + 'sticky': 'pnotify_hide',
  88 + 'stayTime': 'pnotify_delay',
  89 + 'stack': 'pnotify_stack'
  90 + });
  91 + if (options.sticky !== null) {
  92 + delegateOptions.pnotify_hide = !options.sticky;
33 } 93 }
34 jQuery(document).ready(function() { 94 jQuery(document).ready(function() {
35 - if(options.delay) {  
36 - setTimeout(function(){  
37 - jQuery.pnotify(options);  
38 - },options.delay); 95 + if (options.delay) {
  96 + setTimeout(function() {
  97 + jQuery.pnotify(delegateOptions);
  98 + }, options.delay);
39 } else { 99 } else {
40 - jQuery.pnotify(options); 100 + jQuery.pnotify(delegateOptions);
  101 + }
  102 + });
  103 +};
  104 +
  105 +//TODO remove this fix when it gets in to jquery.js
  106 +(function() {
  107 + var safariCompatMode;
  108 + var getCompatMode = function() {
  109 + var compatMode = document.compatMode;
  110 + if (!compatMode && jQuery.browser.safari) {
  111 + if (!safariCompatMode) {
  112 + //detect compatMode as described in http://code.google.com/p/doctype/wiki/ArticleCompatMode
  113 + var width = jQuery(document.createElement("div")).attr('style', 'position:absolute;width:0;height:0;width:1')
  114 + .css('width');
  115 + safariCompatMode = compatMode = (width == '1px' ? 'BackCompat' : 'CSS1Compat');
  116 + } else {
  117 + compatMode = safariCompatMode;
  118 + }
41 } 119 }
  120 +
  121 + return compatMode;
  122 + };
  123 +
  124 +
  125 + // Create innerHeight, innerWidth, outerHeight and outerWidth methods
  126 + jQuery.each([ "Height", "Width" ], function(i, name) {
  127 +
  128 + var tl = i ? "Left" : "Top", // top or left
  129 + br = i ? "Right" : "Bottom", // bottom or right
  130 + lower = name.toLowerCase();
  131 +
  132 + // innerHeight and innerWidth
  133 + jQuery.fn["inner" + name] = function() {
  134 + return this[0] ?
  135 + jQuery.css(this[0], lower, false, "padding") :
  136 + null;
  137 + };
  138 +
  139 + // outerHeight and outerWidth
  140 + jQuery.fn["outer" + name] = function(margin) {
  141 + return this[0] ?
  142 + jQuery.css(this[0], lower, false, margin ? "margin" : "border") :
  143 + null;
  144 + };
  145 +
  146 + var type = name.toLowerCase();
  147 +
  148 + jQuery.fn[ type ] = function(size) {
  149 + // Get window width or height
  150 + return this[0] == window ?
  151 + // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
  152 + getCompatMode() == "CSS1Compat" && document.documentElement[ "client" + name ] ||
  153 + document.body[ "client" + name ] :
  154 +
  155 + // Get document width or height
  156 + this[0] == document ?
  157 + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
  158 + Math.max(
  159 + document.documentElement["client" + name],
  160 + document.body["scroll" + name], document.documentElement["scroll" + name],
  161 + document.body["offset" + name], document.documentElement["offset" + name]
  162 + ) :
  163 +
  164 + // Get or set width or height on the element
  165 + size === undefined ?
  166 + // Get width or height on the element
  167 + (this.length ? jQuery.css(this[0], type) : null) :
  168 +
  169 + // Set the width or height on the element (default to pixels if value is unitless)
  170 + this.css(type, typeof size === "string" ? size : size + "px");
  171 + };
  172 +
42 }); 173 });
43 -} 174 +}());
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 -<f:root  
3 - xmlns:f="http://jsf.exadel.com/template"  
4 - xmlns:vcp=" http://jsf.exadel.com/vcp"  
5 - xmlns:ui=" http://jsf.exadel.com/ui"  
6 - xmlns:x=" http://jsf.exadel.com/vcp"  
7 - xmlns:u="http://jsf.exadel.com/util"  
8 - xmlns:h="http://jsf.exadel.com/header"  
9 - component="org.richfaces.component.UINotify"  
10 - baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"  
11 - class="org.richfaces.renderkit.html.NotifyRenderer"> 2 +<f:root
  3 + xmlns:f="http://jsf.exadel.com/template"
  4 + xmlns:vcp=" http://jsf.exadel.com/vcp"
  5 + xmlns:ui=" http://jsf.exadel.com/ui"
  6 + xmlns:x=" http://jsf.exadel.com/vcp"
  7 + xmlns:u="http://jsf.exadel.com/util"
  8 + xmlns:h="http://jsf.exadel.com/header"
  9 + component="org.richfaces.component.UINotify"
  10 + baseclass="org.ajax4jsf.renderkit.HeaderResourcesRendererBase"
  11 + class="org.richfaces.renderkit.html.NotifyRenderer">
12 <jsp:directive.page import="javax.faces.application.FacesMessage"/> 12 <jsp:directive.page import="javax.faces.application.FacesMessage"/>
13 13
14 <h:scripts>/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js, 14 <h:scripts>/org/richfaces/renderkit/html/scripts/jquery-1.4.2.js,
15 - /org/richfaces/renderkit/html/scripts/jquery.pnotify.js</h:scripts> 15 + /org/richfaces/renderkit/html/scripts/jquery.pnotify.js</h:scripts>
16 <h:styles>/org/richfaces/renderkit/html/css/jquery.pnotify.xcss</h:styles> 16 <h:styles>/org/richfaces/renderkit/html/css/jquery.pnotify.xcss</h:styles>
17 <f:clientid var="clientId"/> 17 <f:clientid var="clientId"/>
  18 +
18 <div id="#{clientId}"> 19 <div id="#{clientId}">
19 <jsp:scriptlet> 20 <jsp:scriptlet>
20 <![CDATA[ 21 <![CDATA[
21 - variables.setVariable("details",component.getDetails());  
22 - variables.setVariable("summary",component.getSummary());  
23 - variables.setVariable("showHistory",component.isShowHistory());  
24 - variables.setVariable("nonblocking",component.isNonblocking());  
25 - variables.setVariable("shadow",component.isShowShadow());  
26 - variables.setVariable("closeButton",component.isShowCloseButton());  
27 - variables.setVariable("nonblockingOpacity",component.getNonblockingOpacity());  
28 - variables.setVariable("appearAnimation",component.getAppearAnimation());  
29 - variables.setVariable("hideAnimation",component.getHideAnimation());  
30 - variables.setVariable("animationSpeed",component.getAnimationSpeed());  
31 - variables.setVariable("stackDirVertical",component.getStackDirVertical());  
32 - variables.setVariable("stackDirHorizontal",component.getStackDirHorizontal());  
33 - variables.setVariable("stackPush",component.getStackPush());  
34 - variables.setVariable("time",component.getStayTime()!=null ? component.getStayTime() : 0);  
35 - variables.setVariable("styleClass",component.getStyleClass()==null?"":component.getStyleClass()); 22 + variables.setVariable("details", component.getDetails());
  23 + variables.setVariable("summary", component.getSummary());
  24 + variables.setVariable("showHistory", component.isShowHistory());
  25 + variables.setVariable("nonblocking", component.isNonblocking());
  26 + variables.setVariable("shadow", component.isShowShadow());
  27 + variables.setVariable("closeButton", component.isShowCloseButton());
  28 + variables.setVariable("nonblockingOpacity", component.getNonblockingOpacity());
  29 + variables.setVariable("appearAnimation", component.getAppearAnimation());
  30 + variables.setVariable("hideAnimation", component.getHideAnimation());
  31 + variables.setVariable("animationSpeed", component.getAnimationSpeed());
  32 + variables.setVariable("stackDirVertical", component.getStackDirVertical());
  33 + variables.setVariable("stackDirHorizontal", component.getStackDirHorizontal());
  34 + variables.setVariable("stackPush", component.getStackPush());
  35 + variables.setVariable("time", component.getStayTime() != null ? component.getStayTime() : 0);
  36 + variables.setVariable("styleClass", component.getStyleClass() == null ? "" : component.getStyleClass());
36 ]]> 37 ]]>
37 </jsp:scriptlet> 38 </jsp:scriptlet>
38 <script type="text/javascript"> 39 <script type="text/javascript">
Please register or login to post a comment