Author: nbelaevski
Date: 2010-09-03 14:18:05 -0400 (Fri, 03 Sep 2010)
New Revision: 19120
Added:
branches/RF-7560/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml
branches/RF-7560/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
branches/RF-7560/ui/iteration/ui/src/main/templates/buttons.template.include
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss
branches/RF-7560/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java
Removed:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/TagHandlerUtils.java
Modified:
branches/RF-7560/
branches/RF-7560/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
branches/RF-7560/cdk/generator/src/main/script/SchemaProcessorNamespaceContext.groovy
branches/RF-7560/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java
branches/RF-7560/core/api/src/main/java/org/richfaces/application/MessageFactory.java
branches/RF-7560/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/VersionBean.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/MessageFactoryImpl.java
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
branches/RF-7560/core/impl/src/main/resources/META-INF/resources/richfaces.js
branches/RF-7560/core/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
branches/RF-7560/examples/core-demo/src/main/webapp/ajax.xhtml
branches/RF-7560/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java
branches/RF-7560/examples/input-demo/src/main/webapp/autocomplete.xhtml
branches/RF-7560/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml
branches/RF-7560/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-headers-qunit.js
branches/RF-7560/examples/output-demo/src/main/webapp/templates/template.xhtml
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/accordion/samples/simple-sample.xhtml
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
branches/RF-7560/ui/input/ui/src/main/templates/autocomplete.template.xml
branches/RF-7560/ui/input/ui/src/main/templates/inplaceInput.template.xml
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractColumn.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
branches/RF-7560/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js
branches/RF-7560/ui/iteration/ui/src/main/templates/datascroller.template.xml
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java
branches/RF-7560/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanelItem.js
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
Log:
Merged revisions
19039,19041,19045,19058,19060,19065-19066,19068-19070,19072,19074,19078,19080-19086,19089,19092,19094,19096-19097,19100,19106-19108
via svnmerge from
https://svn.jboss.org/repos/richfaces/trunk
Property changes on: branches/RF-7560
___________________________________________________________________
Name: svnmerge-integrated
- /trunk:1-19037 /branches/RFPL-754:1-18909 /branches/RFPL-434:1-19024
+ /trunk:1-19119 /branches/RFPL-754:1-18909
Modified:
branches/RF-7560/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java
===================================================================
---
branches/RF-7560/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/cdk/generator/src/main/java/org/richfaces/cdk/generate/taglib/TaglibGeneratorVisitor.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -214,10 +214,10 @@
Element attr = tag.addElement("attribute");
addDescription(attr, attribute);
attr.addElement("name").addText(name);
- attr.addElement("type").addText(attribute.getType().getName());
if (attribute.isRequired()) {
attr.addElement("required").addText("true");
}
+ attr.addElement("type").addText(attribute.getType().getName());
return attr;
}
Modified:
branches/RF-7560/cdk/generator/src/main/script/SchemaProcessorNamespaceContext.groovy
===================================================================
---
branches/RF-7560/cdk/generator/src/main/script/SchemaProcessorNamespaceContext.groovy 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/cdk/generator/src/main/script/SchemaProcessorNamespaceContext.groovy 2010-09-03
18:18:05 UTC (rev 19120)
@@ -37,7 +37,7 @@
SchemaProcessorNamespaceContext() {
biMap = HashBiMap.create();
biMap.put("http://www.w3.org/2001/XMLSchema", "xs");
-
biMap.put("http://richfaces.org/cdk/additional-attributes-info",
"cdk-schema-info");
+
biMap.put("http://jboss.org/schema/richfaces/cdk/additional-attribut...;,
"cdk-schema-info");
}
@Override
Modified: branches/RF-7560/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/api/src/main/java/org/ajax4jsf/javascript/JSEncoder.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -31,13 +31,14 @@
// private char APOSTROPHE[] = { '\\', '\'' };
private static final char[] ENCODE_HEX = "0123456789ABCDEF".toCharArray();
- private static final char[] ENCODE_APOS = "\\'".toCharArray();
private static final char[] ENCODE_QUOT = "\\\"".toCharArray();
private static final char[] ENCODE_LF = "\\n".toCharArray();
+ private static final char[] ENCODE_BC = "\\b".toCharArray();
private static final char[] ENCODE_FF = "\\f".toCharArray();
private static final char[] ENCODE_CR = "\\r".toCharArray();
private static final char[] ENCODE_TAB = "\\t".toCharArray();
private static final char[] ENCODE_BS = "\\\\".toCharArray();
+ private static final char[] ENCODE_FS = "\\/".toCharArray();
// private static final char ENCODE_ESC[] = "\\e".toCharArray();
@@ -47,32 +48,34 @@
public JSEncoder() {}
/**
- * Return true or false wether this encoding can encode the specified
+ * Return true or false whether this encoding/format can encode the specified
* character or not.
* <p>
* This method will return true for the following character range: <br />
* <code>
- * <nobr>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]</nobr>
+ * <nobr>\b | \f | \t | \r | \n | " | \ | / | [#x20-#xD7FF] |
[#xE000-#xFFFD]</nobr>
* </code>
* </p>
*
* @see <a
href="http://www.w3.org/TR/REC-xml#charsets">W3C XML 1.0
</a>
+ * @see <a
href="http://json.org/">JSON.org</a>
*/
public boolean compile(char c) {
- if ((c == 0x09) || // [\t]
- (c == 0x0a) || // [\n]
- (c == 0x0d) || // [\r](c == 0x22) || // ["]
- (c == 0x22) || // ["]
- (c == 0x27) || // [']
- (c == 0x5c) || // [\]
- (c == 0x03) || // [esc]
- (c == ']') || // ] - to avoid conflicts
in CDATA
- (c == '<') || // - escape HTML markup
characters
- (c == '>') || // - HTML
- (c == '&') || // - HTML
- (c == '-') || // - HTML comments
- (c < 0x20) || // See
<
http://www.w3.org/TR/REC-xml#charsets>
- ((c > 0xd7ff) && (c < 0xe000)) ||
(c > 0xfffd) || (c > 0xff)) {
+ if ((c == '\b') ||
+ (c == '\f') |
+ (c == '\t') ||
+ (c == '\n') ||
+ (c == '\r') ||
+ (c == '"') ||
+ (c == '\\') ||
+ (c == '/') ||
+ (c == ']') || // ] - to avoid
conflicts in CDATA
+ (c == '<') || // - escape HTML
markup characters
+ (c == '>') || // - HTML
+ (c == '&') || // - HTML
+ (c == '-') || // - HTML comments
+ (c < 0x20) || // See
<
http://www.w3.org/TR/REC-xml#charsets>
+ ((c > 0xd7ff) && (c < 0xe000))
|| (c > 0xfffd) || (c > 0xff)) {
return false;
}
@@ -85,39 +88,36 @@
*/
public char[] encode(char c) {
switch (c) {
- case 0x03 :
- return ENCODE_FF; // (>) [>]
+ case '\b' :
+ return ENCODE_BC;
+
+ case '\f' :
+ return ENCODE_FF;
- case 0x09 :
- return ENCODE_TAB; // (>) [>]
+ case '\t' :
+ return ENCODE_TAB;
- case 0x0a :
- return ENCODE_LF; // (>) [>]
+ case '\n' :
+ return ENCODE_LF;
- case 0x0d :
- return ENCODE_CR; // (>) [>]
+ case '\r' :
+ return ENCODE_CR;
- case 0x22 :
- return ENCODE_QUOT; // (") ["]
+ case '"' :
+ return ENCODE_QUOT;
- case 0x27 :
- return ENCODE_APOS; // (') [']
+ case '\\' :
+ return ENCODE_BS;
- case 0x5c :
- return ENCODE_BS; // (<) [<]
-
+ case '/' :
+ return ENCODE_FS;
+
default : {
- if (c > 0xff) {
- char[] ret = {
- '\\', 'u', ENCODE_HEX[c >> 0xc & 0xf],
ENCODE_HEX[c >> 0x8 & 0xf], ENCODE_HEX[c >> 0x4 & 0xf],
- ENCODE_HEX[c & 0xf]
- };
+ char[] ret = {
+ '\\', 'u', ENCODE_HEX[c >> 0xc & 0xf],
ENCODE_HEX[c >> 0x8 & 0xf], ENCODE_HEX[c >> 0x4 & 0xf],
+ ENCODE_HEX[c & 0xf]
+ };
- return ret;
- }
-
- char[] ret = {'\\', 'x', ENCODE_HEX[c >> 0x4 &
0xf], ENCODE_HEX[c & 0xf]};
-
return ret;
}
}
Modified:
branches/RF-7560/core/api/src/main/java/org/richfaces/application/MessageFactory.java
===================================================================
---
branches/RF-7560/core/api/src/main/java/org/richfaces/application/MessageFactory.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/api/src/main/java/org/richfaces/application/MessageFactory.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -35,4 +35,6 @@
public FacesMessage createMessage(FacesContext facesContext, Severity severity,
Enum<?> messageKey, Object... args);
+ public String getMessageText(FacesContext facesContext, Enum<?> messageKey,
Object... args);
+
}
Modified:
branches/RF-7560/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java
===================================================================
---
branches/RF-7560/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/api/src/test/java/org/ajax4jsf/javascript/ScriptUtilsTest.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -123,9 +123,9 @@
* Test method for {@link
org.ajax4jsf.javascript.ScriptUtils#toScript(java.lang.Object)}.
*/
public void testStringToScript() {
- Object obj = "foo";
+ Object obj = "f \b\r\t\f\n\"'\\/ oo";
- assertEquals("\"foo\"", ScriptUtils.toScript(obj));
+ assertEquals("\"f \\b\\r\\t\\f\\n\\\"'\\\\\\/ oo\"",
ScriptUtils.toScript(obj));
}
/**
@@ -260,8 +260,8 @@
public void testAddEncoded() {
StringBuilder buff = new StringBuilder();
- ScriptUtils.addEncoded(buff, "foo\"\'");
- assertEquals("foo\\\"\\\'", buff.toString());
+ ScriptUtils.addEncoded(buff, "foo");
+ assertEquals("foo", buff.toString());
}
/**
Modified: branches/RF-7560/core/impl/src/main/java/org/richfaces/VersionBean.java
===================================================================
--- branches/RF-7560/core/impl/src/main/java/org/richfaces/VersionBean.java 2010-09-03
17:34:35 UTC (rev 19119)
+++ branches/RF-7560/core/impl/src/main/java/org/richfaces/VersionBean.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -22,16 +22,20 @@
package org.richfaces;
import java.io.IOException;
+import java.io.InputStream;
import java.net.JarURLConnection;
+import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.text.MessageFormat;
import java.util.jar.Attributes;
+import java.util.jar.JarFile;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
+import org.ajax4jsf.resource.util.URLToStreamHelper;
import org.richfaces.log.Logger;
import org.richfaces.log.RichfacesLogger;
@@ -45,9 +49,6 @@
public static final Version VERSION = new Version();
- private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
-
-
/**
* Class for incapsulate version info.
*
@@ -56,6 +57,8 @@
*/
public static class Version {
+ private static final Logger LOGGER = RichfacesLogger.APPLICATION.getLogger();
+
private static final String UNKNOWN = "";
private String implementationVendor = UNKNOWN;
@@ -125,6 +128,30 @@
if (codeSource != null) {
URL url = codeSource.getLocation();
if (url != null) {
+ InputStream manifestStream = null;
+ try {
+ manifestStream = URLToStreamHelper.urlToStream(new URL(url,
JarFile.MANIFEST_NAME));
+ return new Manifest(manifestStream);
+ } catch (MalformedURLException e1) {
+ //that's ok - just log in debug
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(e1.getMessage(), e1);
+ }
+ } catch (IOException e) {
+ //that's ok - just log in debug
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(e.getMessage(), e);
+ }
+ } finally {
+ if (manifestStream != null) {
+ try {
+ manifestStream.close();
+ } catch (IOException e) {
+ LOGGER.error(MessageFormat.format("Error closing
stream: {0}", e.getMessage()), e);
+ }
+ }
+ }
+
JarInputStream jis = null;
try {
URLConnection urlConnection = url.openConnection();
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/MessageFactoryImpl.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/MessageFactoryImpl.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/application/MessageFactoryImpl.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -40,6 +40,53 @@
*/
public class MessageFactoryImpl implements MessageFactory {
+ protected static interface Factory<T> {
+
+ public T create(ResourceBundle bundle, Enum<?> messageKey, Object... args)
throws MissingResourceException;
+
+ }
+
+ private static final Factory<FacesMessage> MESSAGE_FACTORY = new
Factory<FacesMessage>() {
+
+ public FacesMessage create(ResourceBundle bundle, Enum<?> messageKey,
Object... args)
+ throws MissingResourceException {
+
+ String messageId = messageKey.toString();
+
+ String summary = null;
+ String detail = null;
+
+ try {
+ summary = bundle.getString(messageId);
+ detail = bundle.getString(messageId + "_detail");
+ } catch (MissingResourceException e) {
+ // do nothing
+ }
+
+ if (summary != null) {
+ String formattedSummary = MessageFormat.format(summary, args);
+ String formattedDetail = null;
+
+ if (detail != null) {
+ formattedDetail = MessageFormat.format(detail, args);
+ }
+
+ return new FacesMessage(formattedSummary, formattedDetail);
+ }
+
+ return null;
+ }
+ };
+
+ private static final Factory<String> LABEL_FACTORY = new
Factory<String>() {
+
+ public String create(ResourceBundle bundle, Enum<?> messageKey, Object...
args) throws MissingResourceException {
+ String pattern = bundle.getString(messageKey.toString());
+ return MessageFormat.format(pattern, args);
+ }
+
+ };
+
private BundleLoader bundleLoader;
public MessageFactoryImpl(BundleLoader bundleLoader) {
@@ -73,26 +120,46 @@
throw new NullPointerException("messageKey");
}
- FacesMessage result = null;
+ FacesMessage result = detectLocalesAndCreate(facesContext, MESSAGE_FACTORY,
messageKey, args);
- Locale locale = detectLocale(facesContext);
+ if (result != null) {
+ result.setSeverity(severity);
+ }
+
+ return result;
+ }
+
+ public String getMessageText(FacesContext facesContext, Enum<?> messageKey,
Object... args) {
+ String text = detectLocalesAndCreate(facesContext, LABEL_FACTORY, messageKey,
args);
+ if (text == null) {
+ text = "???" + messageKey + "???";
+ }
+
+ return text;
+ }
+
+ protected <T> T detectLocalesAndCreate(FacesContext context, Factory<T>
factory, Enum<?> messageKey, Object... args) {
+
+ T result = null;
+
+ Locale locale = detectLocale(context);
if (locale != null) {
- result = createMessage(facesContext, severity, locale, messageKey, args);
+ result = create(context, factory, locale, messageKey, args);
}
if (result == null) {
Locale defaultLocale = Locale.getDefault();
if (!defaultLocale.equals(locale)) {
- result = createMessage(facesContext, severity, defaultLocale, messageKey,
args);
+ result = create(context, factory, defaultLocale, messageKey, args);
}
}
-
+
return result;
}
-
- protected FacesMessage createMessage(FacesContext context, Severity severity, Locale
locale, Enum<?> messageKey,
+
+ protected <T> T create(FacesContext context, Factory<T> factory, Locale
locale, Enum<?> messageKey,
Object... args) {
MessageBundle messageBundle =
messageKey.getClass().getAnnotation(MessageBundle.class);
@@ -101,41 +168,25 @@
return null;
}
- String messageId = messageKey.toString();
+ T result = null;
- String summary = null;
- String detail = null;
-
try {
ResourceBundle bundle = bundleLoader.getApplicationBundle(context,
messageKey, locale);
- summary = bundle.getString(messageId);
- detail = bundle.getString(messageId + "_detail");
+ result = factory.create(bundle, messageKey, args);
} catch (MissingResourceException e) {
// do nothing
}
- if (summary == null) {
+ if (result == null) {
try {
ResourceBundle bundle = bundleLoader.getBundle(messageKey, locale);
- summary = bundle.getString(messageId);
- detail = bundle.getString(messageId + "_detail");
+ result = factory.create(bundle, messageKey, args);
} catch (MissingResourceException e) {
// do nothing
}
}
- if (summary == null) {
- return null;
- }
-
- String formattedSummary = MessageFormat.format(summary, args);
- String formattedDetail = null;
-
- if (detail != null) {
- formattedDetail = MessageFormat.format(detail, args);
- }
-
- return new FacesMessage(severity, formattedSummary, formattedDetail);
+ return result;
}
}
Modified:
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java
===================================================================
---
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/impl/src/main/java/org/richfaces/renderkit/util/CoreAjaxRendererUtils.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -42,7 +42,9 @@
import org.richfaces.log.RichfacesLogger;
import org.richfaces.renderkit.HtmlConstants;
+import com.google.common.base.Strings;
+
/**
* @author shura
* <p/>
@@ -243,6 +245,10 @@
Set<String> result = new
LinkedHashSet<String>(values.length);
for (String value : values) {
+ if (Strings.isNullOrEmpty(value)) {
+ continue;
+ }
+
result.add(value);
}
@@ -250,7 +256,9 @@
} else {
Set<String> areasSet = new LinkedHashSet<String>(5);
- areasSet.add(areasString);
+ if (!Strings.isNullOrEmpty(areasString)) {
+ areasSet.add(areasString);
+ }
return areasSet;
}
Modified: branches/RF-7560/core/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
---
branches/RF-7560/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/impl/src/main/resources/META-INF/resources/richfaces.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -128,7 +128,7 @@
//there is the same pattern in server-side code:
//org.ajax4jsf.javascript.ScriptUtils.escapeCSSMetachars(String)
- var CSS_METACHARS_PATTERN = /([#;&,.+*~':"!^$[\]()=>|\/])/g;
+ var CSS_METACHARS_PATTERN = /([#;&,.+*~':"!^$\[\]()=>|\/])/g;
/**
* Escapes CSS meta-characters in string according to
Modified:
branches/RF-7560/core/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
===================================================================
---
branches/RF-7560/core/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/core/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -43,6 +43,8 @@
import org.easymock.classextension.EasyMock;
import org.jboss.test.faces.AbstractFacesTest;
import org.jboss.test.faces.htmlunit.LocalWebClient;
+import org.richfaces.application.DependencyInjectionServiceImpl;
+import org.richfaces.application.DependencyInjector;
import org.richfaces.application.Module;
import org.richfaces.application.ServiceTracker;
import org.richfaces.application.ServicesFactory;
@@ -247,6 +249,7 @@
injector.setInstance(ResourceCodec.class,mockedCodec);
injector.setInstance(org.richfaces.cache.Cache.class,mockCache);
injector.setInstance(Uptime.class, new Uptime());
+ injector.setInstance(DependencyInjector.class, new
DependencyInjectionServiceImpl());
}
}));
Modified: branches/RF-7560/examples/core-demo/src/main/webapp/ajax.xhtml
===================================================================
--- branches/RF-7560/examples/core-demo/src/main/webapp/ajax.xhtml 2010-09-03 17:34:35 UTC
(rev 19119)
+++ branches/RF-7560/examples/core-demo/src/main/webapp/ajax.xhtml 2010-09-03 18:18:05 UTC
(rev 19120)
@@ -88,7 +88,7 @@
<a:ajax bypassUpdates="true" />
</h:commandLink>
- bypassUpdates="#{true}"
+ bypassUpdates="#{'#'}{true}"
<h:inputText>
<a:ajax bypassUpdates="#{true}" event="keyup" />
</h:inputText>
Modified:
branches/RF-7560/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java
===================================================================
---
branches/RF-7560/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -22,6 +22,7 @@
package org.richfaces.demo;
import java.io.Serializable;
+import java.util.Arrays;
import java.util.Locale;
import javax.faces.bean.ManagedBean;
@@ -30,6 +31,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.richfaces.component.UIAutocomplete;
+
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
@@ -60,7 +63,17 @@
return input.getName().toLowerCase(Locale.US).startsWith(countryNamePrefix);
}
}
+
+ private String mode = "lazyClient";
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
@ManagedProperty(value = "#{countriesBean}")
private CountriesBean countriesBean;
@@ -69,7 +82,13 @@
}
public Object autocomplete(FacesContext facesContext, UIComponent component, String
value) {
- return Collections2.filter(countriesBean.getCountries(), new
CountryNamePredicate(value));
+ // for tests when value does not starts with prefix
+ /*String str = value;
+ if (str.charAt(0)=='i') {
+ str = str.substring(1);
+ }*/
+ String v = mode.equals("lazyClient") || mode.equals("client")
? "" : value;
+ return Collections2.filter(countriesBean.getCountries(), new
CountryNamePredicate(v.toLowerCase()));
}
}
Modified: branches/RF-7560/examples/input-demo/src/main/webapp/autocomplete.xhtml
===================================================================
--- branches/RF-7560/examples/input-demo/src/main/webapp/autocomplete.xhtml 2010-09-03
17:34:35 UTC (rev 19119)
+++ branches/RF-7560/examples/input-demo/src/main/webapp/autocomplete.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -13,11 +13,17 @@
<h:body style="margin: 30px;">
<h:form id="form">
+ <h:selectOneMenu value="#{autoCompleteBean.mode}"
onchange="submit()">
+ <f:selectItem itemValue="lazyClient"/>
+ <f:selectItem itemValue="client"/>
+ <f:selectItem itemValue="cachedAjax"/>
+ <f:selectItem itemValue="ajax"/>
+ </h:selectOneMenu>
<div style="height: 300px; width: 300px; overflow: auto;">Text
block text block text block text block text block text block text
block text block
- <input:autocomplete mode="" minChars="2"
autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country"
fetchValue="#{country.name}" showButton="true">
+ <input:autocomplete clientFilter="if(subString.length>1)
if(value.indexOf(subString)!=-1) return true;"
mode="#{autoCompleteBean.mode}" minChars="2"
autocompleteMethod="#{autoCompleteBean.autocomplete}" var="country"
fetchValue="#{country.name}" showButton="true">
#{country.name} #{country.iso} #{country.domain}
</input:autocomplete>
Modified: branches/RF-7560/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
branches/RF-7560/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/WEB-INF/faces-config.xml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -34,6 +34,10 @@
<from-outcome>accordion</from-outcome>
<to-view-id>/examples/accordion.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>collapsiblePanel</from-outcome>
+ <to-view-id>/examples/collapsiblePanel.xhtml</to-view-id>
+ </navigation-case>
<!-- QUnit -->
<navigation-case>
@@ -52,5 +56,9 @@
<from-outcome>qunit/accordionHeaders</from-outcome>
<to-view-id>/qunit/accordionHeaders.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>qunit/collapsiblePanel</from-outcome>
+ <to-view-id>/qunit/collapsiblePanel.xhtml</to-view-id>
+ </navigation-case>
</navigation-rule>
</faces-config>
Copied:
branches/RF-7560/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml
(from rev 19108,
trunk/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml)
===================================================================
--- branches/RF-7560/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml
(rev 0)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/examples/collapsiblePanel.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,35 @@
+<!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"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:pn="http://richfaces.org/output">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="title">Collapsible Panel QUnit</ui:define>
+ <ui:define name="body_head">Collapsible Panel
QUnit</ui:define>
+
+ <ui:define name="body">
+ <p>Page</p>
+
+ <h:form id="f">
+ <pn:collapsiblePanel id="panel">
+ <f:facet name="headerExpanded" >
+ header exanded
+ </f:facet>
+ <f:facet name="headerCollapsed" >
+ header collapsed
+ </f:facet>
+
+ Hello!!!
+
+ </pn:collapsiblePanel>
+
+ </h:form>
+ </ui:define>
+</ui:composition>
+</body>
+</html>
+
Modified:
branches/RF-7560/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml
===================================================================
---
branches/RF-7560/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -26,22 +26,43 @@
<pn:accordionItem header="label 1">
<f:facet name="headerInactive">headerInactive
1</f:facet>
<f:facet name="headerActive">headerActive
1</f:facet>
- <f:facet name="headerDisable">headerDisable
1</f:facet>
+ <f:facet name="header">headerDisable
1</f:facet>
content 1
</pn:accordionItem>
<pn:accordionItem header="label 2"
disabled="true">
<f:facet name="headerInactive">headerInactive
2</f:facet>
- <f:facet name="headerActive">headerActive
2</f:facet>
+ <f:facet name="header">headerActive
2</f:facet>
<f:facet name="headerDisable">headerDisable
2</f:facet>
content 2
</pn:accordionItem>
<pn:accordionItem header="label 3">
- <f:facet name="headerInactive">headerInactive
3</f:facet>
+ <f:facet name="header">headerInactive
3</f:facet>
<f:facet name="headerActive">headerActive
3</f:facet>
<f:facet name="headerDisable">headerDisable
3</f:facet>
content 3
</pn:accordionItem>
</pn:accordion>
+
+ <h:outputLink>
+ <pn:toggleControl targetPanel="panel"
targetItem="@first" event="click"/>
+ |< first
+ </h:outputLink>
+ |
+ <h:outputLink>
+ <pn:toggleControl targetPanel="panel"
targetItem="@prev" event="click"/>
+ <- prev
+ </h:outputLink>
+ |
+ <h:outputLink>
+ <pn:toggleControl targetPanel="panel"
targetItem="@next" event="click"/>
+ next ->
+ </h:outputLink>
+ |
+ <h:outputLink>
+ <pn:toggleControl targetPanel="panel"
targetItem="@last" event="click"/>
+ last >|
+ </h:outputLink>
+
</h:form>
<p>Result</p>
Copied: branches/RF-7560/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml
(from rev 19108, trunk/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml)
===================================================================
--- branches/RF-7560/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml
(rev 0)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/qunit/collapsiblePanel.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,51 @@
+<!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"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:pn="http://richfaces.org/output">
+
+<body>
+<ui:composition template="/templates/template.xhtml">
+
+ <ui:define name="scripts">
+ <h:outputScript name="qunit/qunit.js" />
+ <h:outputScript name="qunit/richfaces-qunit.js" />
+
+ <h:outputStylesheet name="qunit/qunit.css" />
+ </ui:define>
+
+ <ui:define name="title">Collapsible Panel QUnit</ui:define>
+ <ui:define name="body_head">Collapsible Panel
QUnit</ui:define>
+
+ <ui:define name="body">
+ <p>Page</p>
+
+ <h:form id="f">
+ <pn:collapsiblePanel id="panel"
switchType="client">
+ <f:facet name="headerExpanded" >
+ header exanded
+ </f:facet>
+ <f:facet name="headerCollapsed" >
+ header collapsed
+ </f:facet>
+
+ Hello!!!
+
+ </pn:collapsiblePanel>
+
+ </h:form>
+
+ <p>Result</p>
+ <div>
+ <ol id="qunit-tests"></ol>
+
+ <div id="testDiv" style="margin-top:10px; border:1px solid
#a0a0a0">Main Test Div</div>
+
+ </div>
+ <h:outputScript name="tests/richfaces-collapsible-panel-qunit.js"
/>
+ </ui:define>
+</ui:composition>
+</body>
+</html>
+
Modified:
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-headers-qunit.js
===================================================================
---
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-headers-qunit.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-accordion-headers-qunit.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -25,6 +25,34 @@
var ACCORDION_ID = "f:panel";
+ function testFirst(items) {
+ ok(items[0].__header("act").is(":visible"), "1 item:
active visible");
+ ok(!items[0].__header("inact").is(":visible"), "1 item:
inactive unvisible");
+ ok(!items[0].__header("dis").is(":visible"), "1 item:
disabled unvisible");
+
+ ok(!items[1].__header("act").is(":visible"), "2 item:
active visible");
+ ok(!items[1].__header("inact").is(":visible"), "2 item:
inactive unvisible");
+ ok(items[1].__header("dis").is(":visible"), "2 item:
disabled unvisible");
+
+ ok(!items[2].__header("act").is(":visible"), "3 item:
active unvisible");
+ ok(items[2].__header("inact").is(":visible"), "3 item:
inactive visible");
+ ok(!items[2].__header("dis").is(":visible"), "3 item:
disabled unvisible");
+ }
+
+ function testLast(items) {
+ ok(!items[0].__header("act").is(":visible"), "1 item:
active unvisible");
+ ok(items[0].__header("inact").is(":visible"), "1 item:
inactive visible");
+ ok(!items[0].__header("dis").is(":visible"), "1 item:
disabled unvisible");
+
+ ok(!items[1].__header("act").is(":visible"), "2 item:
active visible");
+ ok(!items[1].__header("inact").is(":visible"), "2 item:
inactive unvisible");
+ ok(items[1].__header("dis").is(":visible"), "2 item:
disabled unvisible");
+
+ ok(items[2].__header("act").is(":visible"), "3 item:
active visible");
+ ok(!items[2].__header("inact").is(":visible"), "3 item:
inactive unvisible");
+ ok(!items[2].__header("dis").is(":visible"), "3 item:
disabled unvisible");
+ }
+
test("RichFaces.ui.Accordion change headers", function () {
var c = RichFaces.$(ACCORDION_ID);
@@ -34,31 +62,38 @@
equals(c.getItems().length, 3, "getItems().length");
var items = c.getItems();
- ok( items[0].__header("active" ).is(":visible"), "1
item: active visible");
- ok(!items[0].__header("inactive").is(":visible"), "1
item: inactive unvisible");
- ok(!items[0].__header("disable" ).is(":visible"), "1
item: disabled unvisible");
+ testFirst(items);
- ok(!items[1].__header("active" ).is(":visible"), "2
item: active unvisible");
- ok(!items[1].__header("inactive").is(":visible"), "2
item: inactive unvisible");
- ok( items[1].__header("disable" ).is(":visible"), "2
item: disabled visible");
+ c.switchToItem(items[2].getName());
+ testLast(items);
- ok(!items[2].__header("active" ).is(":visible"), "3
item: active unvisible");
- ok( items[2].__header("inactive").is(":visible"), "3
item: inactive visible");
- ok(!items[2].__header("disable" ).is(":visible"), "3
item: disabled unvisible");
+ c.switchToItem("@first");
+ testFirst(items);
- c.switchToItem(items[2].getName());
- ok(!items[0].__header("active" ).is(":visible"), "1
item: active unvisible");
- ok( items[0].__header("inactive").is(":visible"), "1
item: inactive visible");
- ok(!items[0].__header("disable" ).is(":visible"), "1
item: disabled unvisible");
+ c.switchToItem("@last");
+ testLast(items);
- ok(!items[1].__header("active" ).is(":visible"), "2
item: active unvisible");
- ok(!items[1].__header("inactive").is(":visible"), "2
item: inactive unvisible");
- ok( items[1].__header("disable" ).is(":visible"), "2
item: disabled visible");
+ c.switchToItem("@prev");
+ testFirst(items);
- ok( items[2].__header("active" ).is(":visible"), "3
item: active visible");
- ok(!items[2].__header("inactive").is(":visible"), "3
item: inactive unvisible");
- ok(!items[2].__header("disable" ).is(":visible"), "3
item: disabled unvisible");
+ c.switchToItem("@next");
+ testLast(items);
+ });
+ test("RichFaces.ui.Accordion change disabled headers", function () {
+ var c = RichFaces.$(ACCORDION_ID);
+
+ ok(c instanceof RichFaces.ui.Accordion, "inctance of
RichFaces.ui.Accordion");
+ equals(c.id, ACCORDION_ID, "id");
+
+ equals(c.getItems().length, 3, "getItems().length");
+
+ var items = c.getItems();
+
c.switchToItem(items[0].getName());
+ testFirst(items);
+
+ c.switchToItem(items[1].getName());
+ testFirst(items);
});
});
Copied:
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js
(from rev 19108,
trunk/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js)
===================================================================
---
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js
(rev 0)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/resources/tests/richfaces-collapsible-panel-qunit.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+
+RichFaces.QUnit.run(function() {
+ module("richfaces-collapsible-panel");
+
+ var COLLAPSIBLE_PANEL_ID = "f:panel";
+
+ function handler (msg, returnValue) {
+ return function () {
+ ok(true, msg);
+
+ if (returnValue != undefined) {
+ return returnValue;
+ }
+ };
+ }
+
+ test("RichFaces.ui.CollapsiblePanel test constructor", function () {
+ var c = RichFaces.$(COLLAPSIBLE_PANEL_ID);
+
+ ok(c instanceof RichFaces.ui.CollapsiblePanel, "inctance of
RichFaces.ui.CollapsiblePanel");
+ equals(c.id, COLLAPSIBLE_PANEL_ID, "id");
+ // TODO other params
+
+ });
+
+ test("RichFaces.ui.CollapsiblePanel test public api", function () {
+ var c = RichFaces.$(COLLAPSIBLE_PANEL_ID);
+
+ var PUBLIC_API = ["switchPanel"];
+
+ for (var i in PUBLIC_API) {
+ var funcName = PUBLIC_API[i];
+ ok(c[funcName], funcName + " present in component");
+ equals(typeof c[funcName], "function", funcName + "is
function");
+ }
+ });
+
+ test("RichFaces.ui.CollapsiblePanel.Events", function () {
+ var componentId = COLLAPSIBLE_PANEL_ID;
+ var c = RichFaces.$(componentId);
+
+ expect(4);
+
+ var beforeswitchHandler = function (event, comp, data) {
+ ok(true, "beforeswitch handler invouked");
+
+ same(data.id, componentId, "component id");
+ same(data.isExpanded, "false", "panel collapsed");
+
+ return true;
+ };
+
+ var beforeswitchHandlerWrapper = RichFaces.Event.bindById(componentId,
"beforeswitch", beforeswitchHandler);
+
+ var switchHandler = handler("switch handler invouked", undefined);
+ var switchHandlerWrapper = RichFaces.Event.bindById(componentId,
"switch", switchHandler);
+
+ c.switchPanel();
+
+ RichFaces.Event.unbindById(componentId, "beforeswitch",
beforeswitchHandlerWrapper);
+ RichFaces.Event.unbindById(componentId, "switch",
switchHandlerWrapper);
+
+ c.switchPanel();
+ });
+
+ test("RichFaces.ui.CollapsiblePanel.Events test cancelable", function () {
+ var c = RichFaces.$(COLLAPSIBLE_PANEL_ID);
+
+ expect(2);
+ var beforeswitch1 = RichFaces.Event.bindById(COLLAPSIBLE_PANEL_ID,
"beforeswitch", function () {
+ ok(true, "beforeswitch handler invouked");
+
+ return false;
+ });
+
+ var beforeswitch2 = RichFaces.Event.bindById(COLLAPSIBLE_PANEL_ID,
"beforeswitch", function () {
+ ok(true, "beforeswitch handler invouked");
+
+ return true;
+ });
+
+ var switchHandler = RichFaces.Event.bindById(COLLAPSIBLE_PANEL_ID,
"switch", function () {
+ ok(false, "switch handler should't been invouked");
+ });
+
+ c.switchPanel();
+
+ RichFaces.Event.unbindById(COLLAPSIBLE_PANEL_ID, "beforeswitch",
beforeswitch1);
+ RichFaces.Event.unbindById(COLLAPSIBLE_PANEL_ID, "beforeswitch",
beforeswitch2);
+ RichFaces.Event.unbindById(COLLAPSIBLE_PANEL_ID, "switch",
switchHandler);
+
+ c.switchPanel();
+ });
+});
Modified: branches/RF-7560/examples/output-demo/src/main/webapp/templates/template.xhtml
===================================================================
---
branches/RF-7560/examples/output-demo/src/main/webapp/templates/template.xhtml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/output-demo/src/main/webapp/templates/template.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -11,9 +11,161 @@
<meta http-equiv="content-type" content="text/xhtml;
charset=UTF-8" />
+ <style type="text/css">
+ * {
+ font-family: verdana
+ }
+
+ .rftp_toptab {
+ display: table-cell;
+ border: 1px solid #A6A6A6;
+ padding: 0px 0px 3px 0px;
+ vertical-align: bottom;
+ background: url(tab_bg.gif) top repeat-x #DAE7F5;
+ }
+
+ .rftp_active_top {
+ border-bottom: 0px;
+ font-weight: bold;
+ padding: 3px 0px 0px 0px;
+ vertical-align: top;
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ }
+
+ .rftp_active2_top {
+ border-bottom: 0px;
+ font-weight: bold;
+ padding: 3px 0px 0px 0px;
+ vertical-align: top;
+ background: url(acttab2_bg.gif) top repeat-x #FFFFFF;
+ }
+
+ .rftp_toptab_tabline_vis {
+ border: 1px solid #a6a6a6;
+ background: url(tabline_bg.gif) top repeat-x #EEF4FB;
+ border-bottom: 0px;
+ padding-top: 2px;
+ overflow: hidden;
+ height: 23px;
+ white-space: nowrap;
+ position: relative;
+ }
+
+ .rftp_toptab_tabline_dis {
+ border-bottom: 0px;
+ padding-top: 2px;
+ overflow: hidden;
+ height: 25px;
+ white-space: nowrap;
+ position: relative;
+ }
+
+ .rftp_toptab_tabs {
+ display: table;
+ border: 0px;
+ width: 100%;
+ height: 100%;
+ }
+
+ .rftp_toptab_spacer {
+ display: table-cell;
+ border-bottom: 1px solid #A6A6A6;
+ }
+
+ .rftp_horizonttab_tabspacer_width {
+ padding-left: 1px;
+ }
+
+ .rftp_icon {
+ display: table-cell;
+ vertical-align: middle;
+ padding: 0px 5px 0px 5px;
+ }
+
+ .rftp_close {
+ display: table-cell;
+ vertical-align: middle;
+ padding: 0px 3px 0px 15px;
+ }
+
+ .rftp_label {
+ display: table-cell;
+ vertical-align: middle;
+ font-family: verdana;
+ font-size: 11px;
+ }
+
+ .rftp_toptab_scroll_left {
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ position: absolute;
+ top: 1px;
+ left: 1px;
+ width: 15px;
+ height: 250px;
+ border: 1px solid #a6a6a6;
+ font-weight: bold;
+ text-align: center;
+ font-family: verdana;
+ font-size: 11px;
+ padding-top: 6px;
+ }
+
+ .rftp_toptab_scroll_right {
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ position: absolute;
+ top: 1px;
+ right: 17px;
+ width: 15px;
+ height: 250px;
+ border: 1px solid #a6a6a6;
+ font-weight: bold;
+ text-align: center;
+ font-family: verdana;
+ font-size: 11px;
+ padding-top: 6px;
+ }
+
+ .rftp_toptab_tabslist {
+ background: url(acttab_bg.gif) top repeat-x #C9DBEF;
+ position: absolute;
+ top: 1px;
+ right: 1px;
+ width: 15px;
+ height: 250px;
+ border: 1px solid #a6a6a6;
+ font-weight: bold;
+ text-align: center;
+ font-family: verdana;
+ font-size: 14px;
+ padding-top: 2px;
+ }
+
+ .rftp_toptab_border {
+ border: 1px solid #A6A6A6;
+ border-top: 0px;
+ height: 2px;
+ background: #C9DBEF;
+ }
+
+ .rftp_toptab_content {
+ border: 1px solid #A6A6A6;
+ border-top: 0px;
+ font-family: verdana;
+ font-size: 11px;
+ padding: 10px;
+ background: #ffffff;
+ }
+
+ .rftp_hidden {
+ display: none
+ }
+ </style>
+
</h:head>
<h:body>
+
+
<ui:insert name="scripts" ></ui:insert>
<table width="100%">
<thead>
@@ -46,6 +198,12 @@
<li><h:commandLink
value="accordion" action="accordion" /></li>
</ul>
</li>
+ <li>
+ <p>Collapsible Panel</p>
+ <ul>
+ <li><h:commandLink value="Collapsible
Panel" action="collapsiblePanel" /></li>
+ </ul>
+ </li>
</ul>
<p>QUnit</p>
<ul>
@@ -53,6 +211,7 @@
<li><h:commandLink value="togglePanelItem"
action="qunit/togglePanelItem" /></li>
<li><h:commandLink value="accordion"
action="qunit/accordion" /></li>
<li><h:commandLink
value="accordionHeaders" action="qunit/accordionHeaders"
/></li>
+ <li><h:commandLink
value="collapsiblePanel" action="qunit/collapsiblePanel"
/></li>
</ul>
</h:form>
</td>
Modified:
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/accordion/samples/simple-sample.xhtml
===================================================================
---
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/accordion/samples/simple-sample.xhtml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/accordion/samples/simple-sample.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -9,7 +9,7 @@
.rf-ac{
width: 500px;
}
-.rf-aci-c {
+.rf-ac-itm-c {
height: 220px;
}
</style>
Modified:
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml
===================================================================
---
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/examples/richfaces-showcase/src/main/webapp/richfaces/togglePanel/samples/simple-sample.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -6,7 +6,7 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<style>
-.rf-tgp-i {
+.rf-tgp-itm {
border: 1px solid #{richSkin.panelBorderColor};
padding:5px;
}
Copied: branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event (from rev 19108,
trunk/ui/common/ui/src/main/java/org/richfaces/event)
Deleted:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java 2010-09-03
08:56:24 UTC (rev 19108)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -1,197 +0,0 @@
-/*
- * 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.
- */
-
-package org.richfaces.event;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.el.MethodNotFoundException;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * <p><strong><span
- *
class="changed_modified_2_0">MethodExpressionEventListener</span></strong>
- * is a {@link FacesListener} that wraps a {@link
- * MethodExpression}. When it receives a {@link FacesEvent}, it
- * executes a method on an object identified by the {@link
- * MethodExpression}.</p>
- *
- * @author akolonitsky
- * @version 1.0
- *
- */
-public abstract class MethodExpressionEventListener implements FacesListener, StateHolder
{
-
- private static final Class<?>[] EVENT_LISTENER_ZERO_ARG_SIG = new Class[] { };
-
- private static final Object[] NO_PARAMS = new Object[0];
-
- // ------------------------------------------------------ Instance Variables
-
- private MethodExpression methodExpressionOneArg = null;
- private MethodExpression methodExpressionZeroArg = null;
-
- private boolean isTransient;
-
- protected MethodExpressionEventListener() {
- }
-
- /**
- * <p><span class="changed_modified_2_0">Construct</span>
a {@link
- * FacesListener} that contains a {@link
- * MethodExpression}.<span
- * class="changed_added_2_0">To accomodate method expression targets
- * that take no arguments instead of taking a {@link
- * FacesEvent} argument</span>, the implementation of this
- * class must take the argument <code>methodExpressionOneArg</code>,
- * extract its expression string, and create another
- * <code>MethodExpression</code> whose expected param types match
- * those of a zero argument method. The usage requirements for both
- * of these <code>MethodExpression</code> instances are described in
- * {@link #processEvent}.</span></p>
- *
- * @param methodExpressionOneArg a <code>MethodExpression</code>
- * that points to a method that returns <code>void</code> and takes
- * a single argument of type {@link FacesEvent}.
- */
- protected MethodExpressionEventListener(MethodExpression methodExpressionOneArg) {
-
- super();
- this.methodExpressionOneArg = methodExpressionOneArg;
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- this.methodExpressionZeroArg =
context.getApplication().getExpressionFactory().createMethodExpression(
- elContext, methodExpressionOneArg.getExpressionString(), Void.class,
EVENT_LISTENER_ZERO_ARG_SIG);
- }
-
- /**
- * <p>Construct a {@link FacesListener} that contains a {@link
MethodExpression}.</p>
- *
- * @param methodExprOneArg
- * @param methodExprZeroArg
- */
- protected MethodExpressionEventListener(MethodExpression methodExprOneArg,
MethodExpression methodExprZeroArg) {
-
- super();
- this.methodExpressionOneArg = methodExprOneArg;
- this.methodExpressionZeroArg = methodExprZeroArg;
- }
-
- // ------------------------------------------------------- Event Method
-
- /**
- * <p><span class="changed_modified_2_0">Call</span>
through to the
- * {@link MethodExpression} passed in our constructor. <span
- * class="changed_added_2_0">First, try to invoke the
- * <code>MethodExpression</code> passed to the constructor of this
- * instance, passing the argument {@link FacesEvent} as the
- * argument. If a {@link MethodNotFoundException} is thrown, call
- * to the zero argument <code>MethodExpression</code> derived from
- * the <code>MethodExpression</code> passed to the constructor of
- * this instance. If that fails for any reason, throw an {@link
- * AbortProcessingException}, including the cause of the
- * failure.</span></p>
- *
- * @throws NullPointerException {@inheritDoc}
- * @throws AbortProcessingException {@inheritDoc}
- */
- public void processEvent(FacesEvent event) throws AbortProcessingException {
-
- if (event == null) {
- throw new NullPointerException();
- }
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- // PENDING: The corresponding code in MethodExpressionActionListener
- // has an elaborate message capture, logging, and rethrowing block.
- // Why not here?
- try {
- methodExpressionOneArg.invoke(elContext, new Object[] {event});
- } catch (MethodNotFoundException mnf) {
- if (null != methodExpressionZeroArg) {
-
- try {
- // try to invoke a no-arg version
- methodExpressionZeroArg.invoke(elContext, NO_PARAMS);
- } catch (ELException e) {
- throw new AbortProcessingException(e.getMessage(), e.getCause());
- }
- }
- } catch (ELException e) {
- throw new AbortProcessingException(e.getMessage(), e.getCause());
- }
- }
-
-
- // ------------------------------------------------ Methods from StateHolder
-
-
- /**
- * <p class="changed_modified_2_0">Both {@link MethodExpression}
- * instances described in the constructor must be saved.</p>
- */
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
-
- return new Object[] {
- UIComponentBase.saveAttachedState(context, methodExpressionOneArg),
- UIComponentBase.saveAttachedState(context, methodExpressionZeroArg)
- };
- }
-
-
- /**
- * <p class="changed_modified_2_0">Both {@link MethodExpression}
- * instances described in the constructor must be restored.</p>
- */
- public void restoreState(FacesContext context, Object state) {
-
- if (context == null) {
- throw new NullPointerException();
- }
- if (state == null) {
- return;
- }
-
- methodExpressionOneArg = (MethodExpression) UIComponentBase
- .restoreAttachedState(context, ((Object[]) state)[0]);
- methodExpressionZeroArg = (MethodExpression) UIComponentBase
- .restoreAttachedState(context, ((Object[]) state)[1]);
- }
-
-
- public boolean isTransient() {
- return isTransient;
- }
-
- public void setTransient(boolean newTransientValue) {
- isTransient = newTransientValue;
- }
-}
Copied:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
(from rev 19108,
trunk/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java)
===================================================================
---
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java
(rev 0)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/event/MethodExpressionEventListener.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,197 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.event;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.MethodExpression;
+import javax.el.MethodNotFoundException;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * <p><strong><span
+ *
class="changed_modified_2_0">MethodExpressionEventListener</span></strong>
+ * is a {@link FacesListener} that wraps a {@link
+ * MethodExpression}. When it receives a {@link FacesEvent}, it
+ * executes a method on an object identified by the {@link
+ * MethodExpression}.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ *
+ */
+public abstract class MethodExpressionEventListener implements FacesListener, StateHolder
{
+
+ private static final Class<?>[] EVENT_LISTENER_ZERO_ARG_SIG = new Class[] { };
+
+ private static final Object[] NO_PARAMS = new Object[0];
+
+ // ------------------------------------------------------ Instance Variables
+
+ private MethodExpression methodExpressionOneArg = null;
+ private MethodExpression methodExpressionZeroArg = null;
+
+ private boolean isTransient;
+
+ protected MethodExpressionEventListener() {
+ }
+
+ /**
+ * <p><span class="changed_modified_2_0">Construct</span>
a {@link
+ * FacesListener} that contains a {@link
+ * MethodExpression}.<span
+ * class="changed_added_2_0">To accomodate method expression targets
+ * that take no arguments instead of taking a {@link
+ * FacesEvent} argument</span>, the implementation of this
+ * class must take the argument <code>methodExpressionOneArg</code>,
+ * extract its expression string, and create another
+ * <code>MethodExpression</code> whose expected param types match
+ * those of a zero argument method. The usage requirements for both
+ * of these <code>MethodExpression</code> instances are described in
+ * {@link #processEvent}.</span></p>
+ *
+ * @param methodExpressionOneArg a <code>MethodExpression</code>
+ * that points to a method that returns <code>void</code> and takes
+ * a single argument of type {@link FacesEvent}.
+ */
+ protected MethodExpressionEventListener(MethodExpression methodExpressionOneArg) {
+
+ super();
+ this.methodExpressionOneArg = methodExpressionOneArg;
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ this.methodExpressionZeroArg =
context.getApplication().getExpressionFactory().createMethodExpression(
+ elContext, methodExpressionOneArg.getExpressionString(), Void.class,
EVENT_LISTENER_ZERO_ARG_SIG);
+ }
+
+ /**
+ * <p>Construct a {@link FacesListener} that contains a {@link
MethodExpression}.</p>
+ *
+ * @param methodExprOneArg
+ * @param methodExprZeroArg
+ */
+ protected MethodExpressionEventListener(MethodExpression methodExprOneArg,
MethodExpression methodExprZeroArg) {
+
+ super();
+ this.methodExpressionOneArg = methodExprOneArg;
+ this.methodExpressionZeroArg = methodExprZeroArg;
+ }
+
+ // ------------------------------------------------------- Event Method
+
+ /**
+ * <p><span class="changed_modified_2_0">Call</span>
through to the
+ * {@link MethodExpression} passed in our constructor. <span
+ * class="changed_added_2_0">First, try to invoke the
+ * <code>MethodExpression</code> passed to the constructor of this
+ * instance, passing the argument {@link FacesEvent} as the
+ * argument. If a {@link MethodNotFoundException} is thrown, call
+ * to the zero argument <code>MethodExpression</code> derived from
+ * the <code>MethodExpression</code> passed to the constructor of
+ * this instance. If that fails for any reason, throw an {@link
+ * AbortProcessingException}, including the cause of the
+ * failure.</span></p>
+ *
+ * @throws NullPointerException {@inheritDoc}
+ * @throws AbortProcessingException {@inheritDoc}
+ */
+ public void processEvent(FacesEvent event) throws AbortProcessingException {
+
+ if (event == null) {
+ throw new NullPointerException();
+ }
+ FacesContext context = FacesContext.getCurrentInstance();
+ ELContext elContext = context.getELContext();
+ // PENDING: The corresponding code in MethodExpressionActionListener
+ // has an elaborate message capture, logging, and rethrowing block.
+ // Why not here?
+ try {
+ methodExpressionOneArg.invoke(elContext, new Object[] {event});
+ } catch (MethodNotFoundException mnf) {
+ if (null != methodExpressionZeroArg) {
+
+ try {
+ // try to invoke a no-arg version
+ methodExpressionZeroArg.invoke(elContext, NO_PARAMS);
+ } catch (ELException e) {
+ throw new AbortProcessingException(e.getMessage(), e.getCause());
+ }
+ }
+ } catch (ELException e) {
+ throw new AbortProcessingException(e.getMessage(), e.getCause());
+ }
+ }
+
+
+ // ------------------------------------------------ Methods from StateHolder
+
+
+ /**
+ * <p class="changed_modified_2_0">Both {@link MethodExpression}
+ * instances described in the constructor must be saved.</p>
+ */
+ public Object saveState(FacesContext context) {
+ if (context == null) {
+ throw new NullPointerException();
+ }
+
+ return new Object[] {
+ UIComponentBase.saveAttachedState(context, methodExpressionOneArg),
+ UIComponentBase.saveAttachedState(context, methodExpressionZeroArg)
+ };
+ }
+
+
+ /**
+ * <p class="changed_modified_2_0">Both {@link MethodExpression}
+ * instances described in the constructor must be restored.</p>
+ */
+ public void restoreState(FacesContext context, Object state) {
+
+ if (context == null) {
+ throw new NullPointerException();
+ }
+ if (state == null) {
+ return;
+ }
+
+ methodExpressionOneArg = (MethodExpression) UIComponentBase
+ .restoreAttachedState(context, ((Object[]) state)[0]);
+ methodExpressionZeroArg = (MethodExpression) UIComponentBase
+ .restoreAttachedState(context, ((Object[]) state)[1]);
+ }
+
+
+ public boolean isTransient() {
+ return isTransient;
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ isTransient = newTransientValue;
+ }
+}
Modified:
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java
===================================================================
---
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/common/ui/src/main/java/org/richfaces/renderkit/util/AjaxRendererUtils.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -40,6 +40,8 @@
import org.ajax4jsf.javascript.JSReference;
import org.richfaces.renderkit.AjaxEventOptions;
import org.richfaces.renderkit.HtmlConstants;
+
+import com.google.common.base.Strings;
/**
* @author shura
* <p/>
@@ -586,6 +588,10 @@
Set<String> result = new
LinkedHashSet<String>(values.length);
for (String value : values) {
+ if (Strings.isNullOrEmpty(value)) {
+ continue;
+ }
+
result.add(value);
}
@@ -593,7 +599,9 @@
} else {
Set<String> areasSet = new LinkedHashSet<String>(5);
- areasSet.add(areasString);
+ if (!Strings.isNullOrEmpty(areasString)) {
+ areasSet.add(areasString);
+ }
return areasSet;
}
Deleted:
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/TagHandlerUtils.java
===================================================================
---
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/TagHandlerUtils.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/TagHandlerUtils.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -1,67 +0,0 @@
-/*
- * 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.view.facelets.html;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.view.AttachedObjectHandler;
-
-/**
- * @author Nick Belaevski
- *
- */
-final class TagHandlerUtils {
-
- // TODO - is that implementation dependency?
- private static final String JAVAX_FACES_RETARGETABLE_HANDLERS =
"javax.faces.RetargetableHandlers";
-
- private TagHandlerUtils() {
- //utility class constructor
- }
-
- static List<AttachedObjectHandler>
getOrCreateRetargetableHandlersList(UIComponent component) {
- Map<String, Object> attrs = component.getAttributes();
- @SuppressWarnings({
- "unchecked"}) List<AttachedObjectHandler> list =
- (List<AttachedObjectHandler>)
attrs.get(JAVAX_FACES_RETARGETABLE_HANDLERS);
-
- if (list == null) {
- list = new ArrayList<AttachedObjectHandler>();
- attrs.put(JAVAX_FACES_RETARGETABLE_HANDLERS, list);
- }
-
- return list;
- }
-
- static <T> Class<? extends T> loadClass(String className, Class<T>
type)
- throws ClassNotFoundException, ClassCastException {
-
- ClassLoader ccl = Thread.currentThread().getContextClassLoader();
- Class<?> loadedClass = Class.forName(className, false, ccl);
-
- return loadedClass.asSubclass(type);
- }
-
-}
Modified:
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java
===================================================================
---
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/component/AbstractAutocomplete.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -195,6 +195,9 @@
@Attribute(events = @EventName("beforedomupdate"))
public abstract String getOnbeforedomupdate();
+
+ @Attribute
+ public abstract String getClientFilter();
@Override
public Converter getConverter() {
Modified:
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
---
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -46,6 +46,7 @@
import javax.servlet.jsp.jstl.sql.Result;
import org.ajax4jsf.context.AjaxContext;
+import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.util.InputUtils;
import org.richfaces.component.AbstractAutocomplete;
@@ -71,6 +72,19 @@
})
public abstract class AutocompleteRendererBase extends InputRendererBase implements
MetaComponentRenderer {
+ public JSFunctionDefinition getClientFilterFunction(UIComponent component) {
+ AbstractAutocomplete autocomplete = (AbstractAutocomplete) component;
+ String clientFilter =
(String)autocomplete.getAttributes().get("clientFilter");
+ if (clientFilter != null && clientFilter.length() != 0) {
+ JSFunctionDefinition clientFilterFunction = new
JSFunctionDefinition("subString");
+ clientFilterFunction.addParameter("value");
+ clientFilterFunction.addToBody(clientFilter);
+ return clientFilterFunction;
+ }
+
+ return null;
+ }
+
public String getScriptOptions(UIComponent component) {
Map<String, Object> attributes = component.getAttributes();
Map<String, Object> options = new HashMap<String, Object>();
@@ -78,7 +92,6 @@
utils.addToScriptHash(options, "buttonId", component.getClientId() +
"Button");
utils.addToScriptHash(options, "selectedItemClass",
attributes.get("selectedItemClass"));
utils.addToScriptHash(options, "minChars",
attributes.get("minChars"), "1");
- utils.addToScriptHash(options, "mode",
attributes.get("mode"), "ajax");
utils.addToScriptHash(options, "filterFunction",
attributes.get("filterFunction"));
utils.addToScriptHash(options, "autofill",
attributes.get("autofill"), "true");
utils.addToScriptHash(options, "disabled",
attributes.get("disabled"), "false");
@@ -89,11 +102,16 @@
utils.addToScriptHash(options, "onerror",
attributes.get("onerror"));
utils.addToScriptHash(options, "onbeforedomupdate",
attributes.get("onbeforedomupdate"));
utils.addToScriptHash(options, "onchange",
attributes.get("onchange"));
- if (attributes.get("mode") != null) {
- if (attributes.get("mode").equals("ajax")){
+ utils.addToScriptHash(options, "filterFunction",
getClientFilterFunction(component));
+ String mode = (String)attributes.get("mode");
+ if (mode != null) {
+ if (mode.equals("ajax")){
utils.addToScriptHash(options, "isCachedAjax", false,
"true");
- } else if (attributes.get("mode").equals("client")) {
+ } else if (mode.equals("client") ||
mode.equals("lazyClient")) {
utils.addToScriptHash(options, "ajaxMode", false,
"true");
+ if (mode.equals("lazyClient")) {
+ utils.addToScriptHash(options, "lazyClientMode", true,
"false");
+ }
}
}
StringBuilder builder = new StringBuilder();
@@ -217,13 +235,11 @@
if (mode!= null && mode.equals("client")) {
List<Object> fetchValues = new ArrayList<Object>();
this.encodeItems(facesContext, component, fetchValues);
- } else if (mode!= null && mode.equals("lazyClient")){
+ } else {
strategy.encodeItemsContainerBegin(facesContext, component);
+ // TODO: is it needed
+ //strategy.encodeFakeItem(facesContext, component);
strategy.encodeItemsContainerEnd(facesContext, component);
- } else{
- strategy.encodeItemsContainerBegin(facesContext, component);
- strategy.encodeFakeItem(facesContext, component);
- strategy.encodeItemsContainerEnd(facesContext, component);
}
}
@@ -250,7 +266,7 @@
writer.writeText(item, null);
}
}
-
+ strategy.encodeItemEnd(facesContext, comboBox);
}
private AutocompleteEncodeStrategy getStrategy(UIComponent component) {
Modified:
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
---
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -1,14 +1,23 @@
(function ($, rf) {
rf.utils = rf.utils || {};
- rf.utils.Cache = function (key, items, values) {
+ rf.utils.Cache = function (key, items, values, useCache) {
this.key = key.toLowerCase();
this.cache = {}
this.cache[this.key] = items || [];
- this.values = typeof values != "function" ? values || this.cache[this.key] :
values(items);
- this.useCache = checkValuesPrefix.call(this);
+ this.originalValues = typeof values == "function" ? values(items) : values ||
this.cache[this.key];
+ this.values = processValues(this.originalValues);
+ this.useCache = useCache || checkValuesPrefix.call(this);
};
+ var processValues = function (values) {
+ var processedValues = [];
+ for (var i = 0; i<values.length; i++) {
+ processedValues.push(values[i].toLowerCase());
+ }
+ return processedValues;
+ }
+
var checkValuesPrefix = function () {
var result = true;
for (var i = 0; i<this.values.length; i++) {
@@ -20,7 +29,7 @@
return result;
}
- var getItems = function (key) {
+ var getItems = function (key, filterFunction) {
key = key.toLowerCase();
var newCache = [];
@@ -31,12 +40,17 @@
if (this.cache[key]) {
newCache = this.cache[key];
} else {
+ var useCustomFilterFunction = typeof filterFunction == "function";
var itemsCache = this.cache[this.key];
for (var i = 0; i<this.values.length; i++) {
- var value = this.values[i].toLowerCase();
- var p = value.indexOf(key);
- if (p == 0) {
+ var value = this.values[i];
+ if (useCustomFilterFunction && filterFunction(key, value)) {
newCache.push(itemsCache[i]);
+ } else {
+ var p = value.indexOf(key);
+ if (p == 0) {
+ newCache.push(itemsCache[i]);
+ }
}
}
@@ -52,7 +66,7 @@
};
var getItemValue = function (item) {
- return this.values[this.cache[this.key].index(item)];
+ return this.originalValues[this.cache[this.key].index(item)];
};
var isCached = function (key) {
@@ -107,9 +121,11 @@
minChars:1,
selectFirst:true,
ajaxMode:true,
+ lazyClientMode:false,
isCachedAjax:true,
- tokens: ",",
- attachToBody:true
+ tokens: "",
+ attachToBody:true,
+ filterFunction: undefined
};
var ID = {
@@ -150,9 +166,7 @@
if (element) {
if (event.type=="mouseover") {
var index = this.items.index(element);
- if (index!=this.index) {
- selectItem.call(this, index);
- }
+ selectItem.call(this, event, index);
} else {
this.__onChangeValue(event, getSelectedItemValue.call(this));
rf.Selection.setCaretTo(rf.getDomElement(this.fieldId));
@@ -164,7 +178,7 @@
var updateItemsList = function (value, fetchValues) {
this.items =
$(rf.getDomElement(this.id+ID.ITEMS)).find("."+this.options.itemClass);
if (this.items.length>0) {
- this.cache = new rf.utils.Cache(value, this.items, fetchValues || getData);
+ this.cache = new rf.utils.Cache((this.options.ajaxMode ? value : ""),
this.items, fetchValues || getData, !this.options.ajaxMode);
}
};
@@ -194,18 +208,25 @@
}
};
- var callAjax = function(event, value) {
+ var callAjax = function(event, value, callback) {
clearItems.call(this);
rf.getDomElement(this.id+ID.VALUE).value = value;
var _this = this;
+ var _event = event;
var ajaxSuccess = function (event) {
updateItemsList.call(_this, _this.value, event.componentData &&
event.componentData[_this.id]);
- if (_this.isVisible && _this.options.selectFirst) {
- selectItem.call(_this, 0);
+ if (_this.options.lazyClientMode && _this.value.length!=0) {
+ updateItemsFromCache.call(_this, _this.value);
}
+ if (_this.focused && _this.items.length!=0 && callback) {
+ callback.call(_this, _event);
+ }
+ if (!callback && _this.isVisible && _this.options.selectFirst) {
+ selectItem.call(_this, _event, 0);
+ }
}
var ajaxError = function (event) {
@@ -219,8 +240,8 @@
rf.ajax(this.id, event, {parameters: params, error: ajaxError, complete:ajaxSuccess});
};
- var selectItem = function(index, isOffset, noAutoFill) {
- if (this.items.length==0) return;
+ var selectItem = function(event, index, isOffset) {
+ if (this.items.length==0 || (!isOffset && this.index == index)) return;
if (this.index!=-1) {
this.items.eq(this.index).removeClass(this.options.selectedItemClass);
@@ -233,11 +254,11 @@
if (isOffset) {
this.index += index;
- if ( this.index<0 ) {
- this.index = this.items.length - 1;
- } else if (this.index >= this.items.length) {
- this.index = 0;
- }
+ if ( this.index<0 ) {
+ this.index = this.items.length - 1;
+ } else if (this.index >= this.items.length) {
+ this.index = 0;
+ }
} else {
if (index<0) {
index = 0;
@@ -249,14 +270,21 @@
var item = this.items.eq(this.index);
item.addClass(this.options.selectedItemClass);
scrollToSelectedItem.call(this);
- !noAutoFill && autoFill.call(this, this.value,
getSelectedItemValue.call(this));
+ if (event &&
+ event.which != rf.KEYS.BACKSPACE &&
+ event.which != rf.KEYS.DEL &&
+ event.which != rf.KEYS.LEFT &&
+ event.which != rf.KEYS.RIGHT) {
+ autoFill.call(this, this.value, getSelectedItemValue.call(this));
+ }
};
var updateItemsFromCache = function (value) {
- var newItems = this.cache.getItems(value);
+ var newItems = this.cache.getItems(value, this.options.filterFunction);
this.items = $(newItems);
//TODO: works only with simple markup, not with <tr>
- $(rf.getDomElement(this.id+ID.ITEMS)).empty().append(newItems);
+ $(rf.getDomElement(this.id+ID.ITEMS)).empty().append(this.items);
+ window.console && console.log &&
console.log("updateItemsFromCache");
};
var clearItems = function () {
@@ -264,31 +292,34 @@
this.items = [];
};
- var onChangeValue = function (event, value) {
- selectItem.call(this);
- this.index = -1;
+ var onChangeValue = function (event, value, callback) {
+ selectItem.call(this, event);
// value is undefined if called from AutocompleteBase onChange
var subValue = (typeof value == "undefined") ? this.__getSubValue() : value;
var oldValue = this.value;
this.value = subValue;
- if (this.cache && this.cache.isCached(subValue)) {
- updateItemsFromCache.call(this, subValue);
- if (this.options.selectFirst) {
- if (event.which == rf.KEYS.RETURN || event.type == "click") {
- this.setInputValue(subValue);
- } else {
- selectItem.call(this, 0, false, event.which == rf.KEYS.BACKSPACE || event.which ==
rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT);
- }
+ if ((this.options.isCachedAjax || !this.options.ajaxMode) &&
+ this.cache && this.cache.isCached(subValue)) {
+ if (oldValue!=subValue) {
+ updateItemsFromCache.call(this, subValue);
}
+ if (this.items.length!=0 && callback) {
+ callback.call(this, event);
+ }
+ if (event.which == rf.KEYS.RETURN || event.type == "click") {
+ this.setInputValue(subValue);
+ } else if (this.options.selectFirst) {
+ selectItem.call(this, event, 0);
+ }
} else {
if (event.which == rf.KEYS.RETURN || event.type == "click") {
this.setInputValue(subValue);
}
if (subValue.length>=this.options.minChars) {
- if (this.options.ajaxMode && oldValue!=subValue) {
- this.options.ajaxMode && callAjax.call(this, event, subValue);
+ if ((this.options.ajaxMode || this.options.lazyClientMode) &&
oldValue!=subValue) {
+ callAjax.call(this, event, subValue, callback);
}
} else {
if (this.options.ajaxMode) {
@@ -365,9 +396,11 @@
*/
__updateState: function (event) {
var subValue = this.__getSubValue();
- // called from onShow method, not actually value changed
- if (this.items.length==0 && subValue.length>=this.options.minChars
&& this.isFirstAjax) {
- this.options.ajaxMode && callAjax.call(this, event, subValue);
+ // called from AutocompleteBase when not actually value changed
+ if (this.items.length==0 && this.isFirstAjax) {
+ if ((this.options.ajaxMode && subValue.length>=this.options.minChars) ||
this.options.lazyClientMode) {
+ callAjax.call(this, event, subValue);
+ }
}
return;
},
@@ -383,16 +416,16 @@
/*
* Override abstract protected methods
*/
- __onKeyUp: function () {
- selectItem.call(this, -1, true);
+ __onKeyUp: function (event) {
+ selectItem.call(this, event, -1, true);
},
- __onKeyDown: function () {
- selectItem.call(this, 1, true);
+ __onKeyDown: function (event) {
+ selectItem.call(this, event, 1, true);
},
- __onPageUp: function () {
+ __onPageUp: function (event) {
},
- __onPageDown: function () {
+ __onPageDown: function (event) {
},
__onBeforeShow: function (event) {
@@ -404,14 +437,12 @@
//rf.getDomElement(this.fieldId).focus();
},
__onShow: function (event) {
- if (event.which != rf.KEYS.BACKSPACE && this.items &&
this.items.length>0) {
- if (this.index!=0 && this.options.selectFirst) {
- selectItem.call(this, 0);
- }
+ if (this.options.selectFirst) {
+ selectItem.call(this, event, 0);
}
},
- __onHide: function () {
- selectItem.call(this);
+ __onHide: function (event) {
+ selectItem.call(this, event);
},
/*
* Destructor
Modified:
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
===================================================================
---
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -107,6 +107,7 @@
};
var onFocus = function (event) {
+ this.focused = true;
};
var onBlur = function (event) {
@@ -116,6 +117,7 @@
} else if (this.isVisible && !this.isMouseDown) {
var _this = this;
this.timeoutId = window.setTimeout(function(){_this.hide();}, 200);
+ this.focused=false;
}
};
@@ -128,15 +130,11 @@
//TODO: is it needed to chesk keys?
//TODO: we need to set value when autoFill used when LEFT or RIGHT was pressed
if (event.which == rf.KEYS.LEFT || event.which == rf.KEYS.RIGHT || flag) {
- if (flag || this.isVisible) {
- this.__onChangeValue(event);
- }
if (flag) {
+ this.__onChangeValue(event, undefined, (!this.isVisible ? this.show : undefined));
this.currentValue = this.getInputValue();
- /*if(value && value.length>=this.options.minChars){
- onShow.call(this, event);
- }*/ // TODO: AMarkhel: is this check needed??? for what?
- onShow.call(this, event);
+ } else if (this.isVisible) {
+ this.__onChangeValue(event);
}
}
};
Modified: branches/RF-7560/ui/input/ui/src/main/templates/autocomplete.template.xml
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/templates/autocomplete.template.xml 2010-09-03
17:34:35 UTC (rev 19119)
+++ branches/RF-7560/ui/input/ui/src/main/templates/autocomplete.template.xml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -29,7 +29,7 @@
onmouseout="#{component.attributes['onmouseout']}"
onkeyup="#{component.attributes['onkeyup']}"
onkeydown="#{component.attributes['onkeydown']}"
- onkeypress="#{component.attributes['onkeypress']}"
id="#{clientId}Input" value="#{component.attributes['value']}"
disabled="#{disabled}" name="#{clientId}" type="text"
class="rf-au-font rf-au-input" />
+ onkeypress="#{component.attributes['onkeypress']}"
id="#{clientId}Input" value="#{component.attributes['value']}"
disabled="#{disabled}" name="#{clientId}" type="text"
class="rf-au-font rf-au-input" autocomplete="off"/>
<c:if
test="#{component.attributes['showButton']}">
<c:if
test="#{component.attributes['disabled']}">
<div id="#{clientId}Button"
class="rf-au-button">
Modified: branches/RF-7560/ui/input/ui/src/main/templates/inplaceInput.template.xml
===================================================================
--- branches/RF-7560/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-09-03
17:34:35 UTC (rev 19119)
+++ branches/RF-7560/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -1,5 +1,28 @@
<?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:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
@@ -25,7 +48,7 @@
</span>
<input id="#{clientId}:focus" type="image"
style="position: absolute; top: 0px; left: 0px; outline-style: none;"
class="rf-ii-none"/>
<span id="#{clientId}:edit" class="#{getEditStyleClass(component,
inplaceState)}">
- <input id="#{clientId}:input" autocomplete="off"
name="#{clientId}:input"
+ <input id="#{clientId}:input" autocomplete="off"
name="#{clientId}"
type="text" value="#{getInputValue(facesContext, component)}"
class="rf-ii-f" style="width:
#{component.attributes['inputWidth']};"
cdk:passThrough="tabIndex">
<cdk:call expression="renderInputHandlers(facesContext,
component);"/>
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractColumn.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractColumn.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractColumn.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -50,7 +50,6 @@
public static final String COMPONENT_FAMILY = "org.richfaces.Column";
-
@Attribute
public abstract boolean isBreakRowBefore();
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/component/AbstractDataScroller.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -70,6 +70,10 @@
public static final String LAST_FACET_NAME = "last";
+ public static final String NEXT_FACET_NAME = "next";
+
+ public static final String PREVIOUS_FACET_NAME = "previous";
+
public static final String FAST_FORWARD_FACET_NAME = "fastforward";
public static final String FAST_REWIND_FACET_NAME = "fastrewind";
@@ -84,16 +88,9 @@
private Integer page;
- protected enum PropertyKeys {
- boundaryControls, fastControls, fastStep, forComponent, inactiveStyle,
selectStyle, inactiveStyleClass, selectStyleClass, scrollerListener, lastPageMode,
maxPages, pageIndexVar, pagesVar, renderIfSinglePage, style, styleClass, stepControls
- }
-
@Attribute
public abstract String getLastPageMode();
- @Attribute(defaultValue="0")
- public abstract int getFastStep();
-
@Attribute
public abstract String getForComponent();
@@ -106,6 +103,12 @@
@Attribute(defaultValue="show")
public abstract String getFastControls();
+ @Attribute(defaultValue="show")
+ public abstract String getStepControls();
+
+ @Attribute(defaultValue="1")
+ public abstract int getFastStep();
+
public void addScrollerListener(DataScrollerListener listener) {
addFacesListener(listener);
}
@@ -165,10 +168,6 @@
return DataScrollerUtils.findDataTable(this);
}
- private int getFastStepOrDefault() {
- return (Integer) getStateHelper().eval(PropertyKeys.fastStep, 1);
- }
-
public int getPageForFacet(String facetName) {
if (facetName == null) {
throw new NullPointerException();
@@ -181,10 +180,14 @@
newPage = 1;
} else if (LAST_FACET_NAME.equals(facetName)) {
newPage = pageCount > 0 ? pageCount : 1;
+ } else if (PREVIOUS_FACET_NAME.equals(facetName)) {
+ newPage = getPage() - 1;
+ } else if (NEXT_FACET_NAME.equals(facetName)) {
+ newPage = getPage() + 1;
} else if (FAST_FORWARD_FACET_NAME.equals(facetName)) {
- newPage = getPage() + getFastStepOrDefault();
+ newPage = getPage() + getFastStep();
} else if (FAST_REWIND_FACET_NAME.equals(facetName)) {
- newPage = getPage() - getFastStepOrDefault();
+ newPage = getPage() - getFastStep();
} else {
try {
newPage = Integer.parseInt(facetName.toString());
@@ -236,7 +239,15 @@
public UIComponent getLast() {
return getFacetByKey(LAST_FACET_NAME);
}
+
+ public UIComponent getNext() {
+ return getFacetByKey(NEXT_FACET_NAME);
+ }
+ public UIComponent getPrevious() {
+ return getFacetByKey(PREVIOUS_FACET_NAME);
+ }
+
public UIComponent getFastForward() {
return getFacetByKey(FAST_FORWARD_FACET_NAME);
}
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ColumnGroupRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -52,7 +52,10 @@
Iterator<UIComponent> components = row.columns();
while(components.hasNext()){
- encodeColumn(facesContext, writer, (UIColumn)components.next(),rowHolder);
+ UIColumn column = (UIColumn)components.next();
+ if(column.isRendered()) {
+ encodeColumn(facesContext, writer, column,rowHolder);
+ }
}
encodeRowEnd(writer);
}
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/ControlsState.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -35,7 +35,15 @@
private boolean lastRendered = true;
private boolean lastEnabled = true;
+
+ private boolean nextRendered = true;
+
+ private boolean nextEnabled = true;
+ private boolean previousRendered = true;
+
+ private boolean previousEnabled = true;
+
private boolean fastRewindRendered = true;
private boolean fastRewindEnabled = true;
@@ -109,8 +117,40 @@
public void setFastForwardEnabled(boolean fastForwardEnabled) {
this.fastForwardEnabled = fastForwardEnabled;
}
+
+ public boolean getNextRendered() {
+ return nextRendered;
+ }
- public boolean isControlsSeparatorRendered() {
+ public void setNextRendered(boolean nextRendered) {
+ this.nextRendered = nextRendered;
+ }
+
+ public boolean getNextEnabled() {
+ return nextEnabled;
+ }
+
+ public void setNextEnabled(boolean nextEnabled) {
+ this.nextEnabled = nextEnabled;
+ }
+
+ public boolean getPreviousRendered() {
+ return previousRendered;
+ }
+
+ public void setPreviousRendered(boolean previousRendered) {
+ this.previousRendered = previousRendered;
+ }
+
+ public boolean getPreviousEnabled() {
+ return previousEnabled;
+ }
+
+ public void setPreviousEnabled(boolean previousEnabled) {
+ this.previousEnabled = previousEnabled;
+ }
+
+ public boolean getControlsSeparatorRendered() {
return controlsSeparatorRendered;
}
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataScrollerBaseRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -84,10 +84,10 @@
boolean useFirst = true;
boolean useLast = true;
-
+
boolean useBackFast = true;
boolean useForwFast = true;
-
+
ControlsState controlsState = new ControlsState();
if (pageIndex <= minPageIdx) {
@@ -107,6 +107,7 @@
}
String boundaryControls = (String)
component.getAttributes().get("boundaryControls");
+ String stepControls = (String)
component.getAttributes().get("stepControls");
String fastControls = (String)
component.getAttributes().get("fastControls");
boolean isAuto = "auto".equals(boundaryControls);
@@ -122,7 +123,21 @@
controlsState.setFirstRendered(false);
controlsState.setLastRendered(false);
}
+
+ isAuto = "auto".equals(stepControls);
+ if (isAuto || "show".equals(stepControls)) {
+ if (isAuto) {
+ controlsState.setPreviousRendered(useFirst);
+ controlsState.setNextRendered(useLast);
+ }
+ controlsState.setPreviousEnabled(useFirst);
+ controlsState.setNextEnabled(useLast);
+ } else {
+ controlsState.setPreviousRendered(false);
+ controlsState.setNextRendered(false);
+ }
+
isAuto = "auto".equals(fastControls);
if (isAuto || "show".equals(fastControls)) {
if (isAuto) {
@@ -250,9 +265,17 @@
left.put(clientId + "_ds_fr",
AbstractDataScroller.FAST_REWIND_FACET_NAME);
}
+ if (controlsState.getPreviousRendered() &&
controlsState.getPreviousEnabled()) {
+ left.put(clientId + "_ds_prev",
AbstractDataScroller.PREVIOUS_FACET_NAME);
+ }
+
if (controlsState.getFastForwardRendered() &&
controlsState.getFastForwardEnabled()) {
right.put(clientId + "_ds_ff",
AbstractDataScroller.FAST_FORWARD_FACET_NAME);
}
+
+ if (controlsState.getNextRendered() && controlsState.getNextEnabled()) {
+ right.put(clientId + "_ds_next",
AbstractDataScroller.NEXT_FACET_NAME);
+ }
if (controlsState.getLastRendered() && controlsState.getLastEnabled()) {
right.put(clientId + "_ds_l",
AbstractDataScroller.LAST_FACET_NAME);
@@ -303,6 +326,10 @@
definition.addToBody(buffer);
return definition;
}
+
+ public void encodeFacet(FacesContext context, UIComponent component) throws
IOException {
+ component.encodeAll(context);
+ }
public boolean getRendersChildren() {
return true;
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/DataTableRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -147,72 +147,73 @@
RowHolder rowHolder = (RowHolder) holder;
Row row = rowHolder.getRow();
- AbstractDataTable dataTable = (AbstractDataTable)row;
-
- boolean partialUpdate = rowHolder.isUpdatePartial();
+ AbstractDataTable dataTable = (AbstractDataTable) row;
+
+ boolean partialUpdate = rowHolder.isUpdatePartial();
boolean parentTbodyStart = rowHolder.isEncodeParentTBody();
boolean tbodyStart = parentTbodyStart;
-
+
rowHolder.setRowStart(true);
Iterator<UIComponent> components = row.columns();
while (components.hasNext()) {
-
UIComponent child = components.next();
- if(child instanceof Row) {
- boolean isSubtable = (child instanceof AbstractSubTable);
- //new row -> close </tr>
- if (rowHolder.getProcessCell() != 0) {
- encodeRowEnd(writer);
+ if (child.isRendered()) {
+ if (child instanceof Row) {
+ boolean isSubtable = (child instanceof AbstractSubTable);
+ // new row -> close </tr>
+ if (rowHolder.getProcessCell() != 0) {
+ encodeRowEnd(writer);
- if(isSubtable) {
- encodeTableBodyEnd(writer);
- tbodyStart = false;
-
- if (partialUpdate) {
- partialEnd(facesContext);
+ if (isSubtable) {
+ encodeTableBodyEnd(writer);
+ tbodyStart = false;
+
+ if (partialUpdate) {
+ partialEnd(facesContext);
+ }
}
}
- }
-
- rowHolder.nextCell();
-
- if(isSubtable && partialUpdate){
- String id = dataTable.getRelativeClientId(facesContext) +
":"+ child.getId() +":c";
- partialStart(facesContext, id);
- }
-
- child.encodeAll(facesContext);
-
- if (isSubtable && partialUpdate) {
- partialEnd(facesContext);
- }
-
- } else if(child instanceof UIColumn) {
-
- if(!parentTbodyStart && !tbodyStart) {
- if (partialUpdate) {
- partialStart(facesContext,
dataTable.getRelativeClientId(facesContext) + ":tb");
+
+ rowHolder.nextCell();
+
+ if (isSubtable && partialUpdate) {
+ String id = dataTable.getRelativeClientId(facesContext) +
":" + child.getId() + ":c";
+ partialStart(facesContext, id);
}
-
- encodeTableBodyStart(writer, facesContext, dataTable);
- rowHolder.setRowStart(true);
- tbodyStart = true;
- }
-
- encodeColumn(facesContext, writer, (UIColumn)child, rowHolder);
-
- if(!components.hasNext()) {
- encodeRowEnd(writer);
-
- if(!parentTbodyStart && tbodyStart) {
- encodeTableBodyEnd(writer);
- tbodyStart = false;
-
- if(partialUpdate) {
- partialEnd(facesContext);
+
+ child.encodeAll(facesContext);
+
+ if (isSubtable && partialUpdate) {
+ partialEnd(facesContext);
+ }
+
+ } else if (child instanceof UIColumn) {
+
+ if (!parentTbodyStart && !tbodyStart) {
+ if (partialUpdate) {
+ partialStart(facesContext,
dataTable.getRelativeClientId(facesContext) + ":tb");
}
+
+ encodeTableBodyStart(writer, facesContext, dataTable);
+ rowHolder.setRowStart(true);
+ tbodyStart = true;
}
+
+ encodeColumn(facesContext, writer, (UIColumn) child, rowHolder);
+
+ if (!components.hasNext()) {
+ encodeRowEnd(writer);
+
+ if (!parentTbodyStart && tbodyStart) {
+ encodeTableBodyEnd(writer);
+ tbodyStart = false;
+
+ if (partialUpdate) {
+ partialEnd(facesContext);
+ }
+ }
+ }
}
}
}
Modified:
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/java/org/richfaces/renderkit/SubTableRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -193,18 +193,19 @@
while (components.hasNext()) {
UIComponent component = components.next();
-
- if(component instanceof UIColumn) {
- encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
-
- } else if (component instanceof AbstractSubTable) {
- if(component.isRendered()) {
- encodeRowEnd(writer);
+ if(component.isRendered()) {
+ if(component instanceof UIColumn ) {
+ encodeColumn(facesContext, writer, (UIColumn)component , rowHolder);
+
+ } else if (component instanceof AbstractSubTable) {
+ if(component.isRendered()) {
+ encodeRowEnd(writer);
+ }
+
+ component.encodeAll(facesContext);
+ rowHolder.setRowStart(true);
}
-
- component.encodeAll(facesContext);
- rowHolder.setRowStart(true);
- }
+ }
}
encodeRowEnd(writer);
Modified:
branches/RF-7560/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/resources/META-INF/resources/org.richfaces/datascroller.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -132,13 +132,21 @@
RichFaces.Event.fireById(this.id, this.getScrollEventName(), {'page' :
page});
}
},
-
+
+ fastForward: function() {
+ this.switchToPage("fastforward");
+ },
+
+ fastRewind: function() {
+ this.switchToPage("fastrewind");
+ },
+
next: function() {
- this.switchToPage("fastforward");
+ this.switchToPage("next");
},
previous: function() {
- this.switchToPage("fastrewind");
+ this.switchToPage("previous");
},
first: function() {
Copied: branches/RF-7560/ui/iteration/ui/src/main/templates/buttons.template.include (from
rev 19108, trunk/ui/iteration/ui/src/main/templates/buttons.template.include)
===================================================================
--- branches/RF-7560/ui/iteration/ui/src/main/templates/buttons.template.include
(rev 0)
+++
branches/RF-7560/ui/iteration/ui/src/main/templates/buttons.template.include 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,51 @@
+<!--
+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.
+-->
+
+<c:choose
xmlns:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
xmlns:cdk="http://jboss.org/schema/richfaces/cdk/core">
+ <c:when test="#{isEnabled}">
+ <a id="#{id}" class="#{enabledStyles}"
href="javascript:void(0);" >
+ <c:choose>
+ <c:when test="#{facet != null}">
+ <cdk:call expression="encodeFacet(facesContext, facet);"/>
+ </c:when>
+ <c:otherwise>
+ #{defaultText}
+ </c:otherwise>
+ </c:choose>
+ </a>
+ </c:when>
+ <c:otherwise>
+ <span id="#{id}" class="#{disabledStyles}">
+ <c:choose>
+ <c:when test="#{facet != null}">
+ <cdk:call expression="encodeFacet(facesContext, facet);"/>
+ </c:when>
+ <c:otherwise>
+ #{defaultText}
+ </c:otherwise>
+ </c:choose>
+ </span>
+ </c:otherwise>
+</c:choose>
Modified: branches/RF-7560/ui/iteration/ui/src/main/templates/datascroller.template.xml
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/main/templates/datascroller.template.xml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/main/templates/datascroller.template.xml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -1,8 +1,32 @@
<?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:c="http://jboss.org/schema/richfaces/cdk/jstl/core"
xmlns:cc="http://jboss.org/schema/richfaces/cdk/jsf/composite"
-
xmlns:javaee="http://java.sun.com/xml/ns/javaee">
+
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:xi="http://www.w3.org/2001/XInclude">
<cc:interface>
<cdk:class>org.richfaces.renderkit.html.DataScrollerRenderer</cdk:class>
@@ -12,81 +36,79 @@
</cc:interface>
<cc:implementation>
-
<cdk:object type="org.richfaces.renderkit.ControlsState"
name="controlsState"
value="#{getControlsState(facesContext,component)}" />
<span id="#{clientId}" class="rf-ds"><!-- Now decor is
disabled !!! -->
+
<c:if test="#{controlsState.firstRendered}">
- <c:choose>
- <c:when test="#{controlsState.firstEnabled}">
- <a id="#{clientId}_ds_f" class="rf-ds-btn rf-ds-l"
href="javascript:void(0)" >
- ««
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_f" class="rf-ds-btn rf-ds-l
rf-ds-dis">
- ««
- </span>
- </c:otherwise>
- </c:choose>
+ <cdk:object type="boolean" name="isEnabled"
value="#{controlsState.firstEnabled}"/>
+ <cdk:object type="UIComponent" name="facet"
value="#{component.getFacet('first')}"/>
+ <cdk:object type="String" name="enabledStyles"
value="rf-ds-btn rf-ds-l"/>
+ <cdk:object type="String" name="disabledStyles"
value="rf-ds-btn rf-ds-l rf-ds-dis"/>
+ <cdk:object type="String" name="id"
value="#{clientId}_ds_f"/>
+ <cdk:object type="String" name="defaultText"
value="««««"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
</c:if>
-
<c:if test="#{controlsState.fastRewindRendered}">
- <c:choose>
- <c:when test="#{controlsState.fastRewindEnabled}">
- <a id="#{clientId}_ds_fr" class="rf-ds-btn rf-ds-l"
href="javascript:void(0)">
- «
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_fr" class="rf-ds-btn rf-ds-l
rf-ds-dis">
- «
- </span>
- </c:otherwise>
- </c:choose>
+ <cdk:object type="boolean" name="isEnabled"
value="#{controlsState.fastRewindEnabled}"/>
+ <cdk:object type="UIComponent" name="facet"
value="#{component.getFacet('fastRewind')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-l"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-l rf-ds-dis"/>
+ <cdk:object type="java.lang.String" name="id"
value="#{clientId}_ds_fr"/>
+ <cdk:object type="java.lang.String" name="defaultText"
value="««"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
</c:if>
+
+ <c:if test="#{controlsState.previousRendered}">
+ <cdk:object name="isEnabled"
value="#{controlsState.previousEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('previous')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-l"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-l rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_prev"/>
+ <cdk:object name="defaultText" value="«"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
+ </c:if>
- <cdk:object type="java.util.Map" name="digitals"
value="#{renderPager(responseWriter, facesContext, component)}" />
-
- <c:if test="#{controlsState.fastForwardRendered}">
- <c:choose>
- <c:when test="#{controlsState.fastForwardEnabled}">
- <a id="#{clientId}_ds_ff" class="rf-ds-btn rf-ds-r"
href="javascript:void(0);">
- »
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_ff" class="rf-ds-btn rf-ds-r
rf-ds-dis">
- »
- </span>
- </c:otherwise>
- </c:choose>
+ <cdk:object type="java.util.Map" name="digitals"
value="#{renderPager(responseWriter, facesContext, component)}" />
+
+ <c:if test="#{controlsState.nextRendered}">
+ <cdk:object name="isEnabled"
value="#{controlsState.nextEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('next')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-r"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-r rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_next"/>
+ <cdk:object name="defaultText" value="»"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
</c:if>
+ <c:if test="#{controlsState.fastForwardRendered}">
+ <cdk:object name="isEnabled"
value="#{controlsState.fastForwardEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('fastForward')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-r"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-r rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_ff"/>
+ <cdk:object name="defaultText"
value="»»"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
+ </c:if>
+
<c:if test="#{controlsState.lastRendered}">
- <c:choose>
- <c:when test="#{controlsState.lastEnabled}">
- <a id="#{clientId}_ds_l" class="rf-ds-btn rf-ds-r"
href="javascript:void(0);">
- »»
- </a>
- </c:when>
- <c:otherwise>
- <span id="#{clientId}_ds_l" class="rf-ds-btn rf-ds-r
rf-ds-dis">
- »»
- </span>
- </c:otherwise>
- </c:choose>
- </c:if>
-
+ <cdk:object name="isEnabled"
value="#{controlsState.lastEnabled}"/>
+ <cdk:object name="facet"
value="#{component.getFacet('last')}"/>
+ <cdk:object type="java.lang.String" name="enabledStyles"
value="rf-ds-btn rf-ds-r"/>
+ <cdk:object type="java.lang.String" name="disabledStyles"
value="rf-ds-btn rf-ds-r rf-ds-dis"/>
+ <cdk:object name="id" value="#{clientId}_ds_l"/>
+ <cdk:object name="defaultText"
value="»»»»"/>
+ <xi:include xpointer="xpointer(/*)"
href="buttons.template.include" />
+ </c:if>
+
<cdk:object type="java.util.Map" name="buttons"
value="#{getControls(facesContext, component, controlsState)}" />
<script type="text/javascript">
<cdk:call expression="buildScript(responseWriter, facesContext, component,
buttons, digitals);"/>
</script>
</span>
-
-
+
</cc:implementation>
</cdk:root>
\ No newline at end of file
Modified:
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerBean.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -17,7 +17,6 @@
content.add("3 page content");
content.add("4 page content");
content.add("5 page content");
- content.add("6 page content");
}
public List<String> getContent() {
Modified:
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/test/java/org/richfaces/renderkit/DataScrollerRenderTest.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -46,7 +46,7 @@
assertEquals("span", span.getNodeName());
assertEquals("rf-ds",
span.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
- // first/fastRewind buttons with arrows
+ // first/fastRewind/previous buttons with arrows
HtmlElement first = getFirstButton(page, scrollerId);
assertEquals("span", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
@@ -55,11 +55,15 @@
assertEquals("span", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ HtmlElement previous = getPreviousButton(page, scrollerId);
+ assertEquals("span", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
// currently selected digital button
- HtmlElement dc = getDigitalButton(page, scrollerId, 1);
- assertEquals("span", dc.getNodeName());
- assertEquals("rf-ds-dtl rf-ds-cur",
dc.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
-
+ HtmlElement dc1 = getDigitalButton(page, scrollerId, 1);
+ assertEquals("span", dc1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
dc1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
// digital buttons
HtmlElement d2 = getDigitalButton(page, scrollerId, 2);
assertEquals("a", d2.getNodeName());
@@ -81,12 +85,12 @@
assertEquals("rf-ds-dtl",
d5.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
assertEquals("javascript:void(0);",
d5.getAttribute(HtmlConstants.HREF_ATTR));
- HtmlElement d6 = getDigitalButton(page, scrollerId, 6);
- assertEquals("a", d6.getNodeName());
- assertEquals("rf-ds-dtl",
d6.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
- assertEquals("javascript:void(0);",
d6.getAttribute(HtmlConstants.HREF_ATTR));
+ // next/fastForward/last buttons with arrows
+ HtmlElement next = getNextButton(page, scrollerId);
+ assertEquals("a", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+ assertEquals("javascript:void(0);",
next.getAttribute(HTML.HREF_ATTR));
- // last/fastForward buttons with arrows
HtmlElement fastForward = getFastForwardButton(page, scrollerId);
assertEquals("a", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
@@ -133,6 +137,102 @@
}
@Test
+ public void testOutDataScrollerNextPreviousButtons() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ String firstScrollerId = "scroller1";
+
+ //dataScroller inside dataTable 'footer' facet
+ String secondScrollerId = "richTable:scroller2";
+
+ for(int i = 2; i <= 5; i++) {
+ HtmlElement next = getNextButton(page, firstScrollerId);
+
+ next.click();
+
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller inside dataTable has switched
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkLastPageButtons(page, firstScrollerId, secondScrollerId);
+
+ //scroll back
+ for(int i = 4; i >= 1; i--) {
+ HtmlElement previous = getPreviousButton(page, firstScrollerId);
+ previous.click();
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller inside dataTable has switched
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkFirstPageButtons(page, firstScrollerId, secondScrollerId);
+ }
+
+ @Test
+ public void testInnerDataScrollerNextPreviousButtons() throws Exception {
+ HtmlPage page = environment.getPage("/test.jsf");
+ String firstScrollerId = "scroller1";
+
+ //dataScroller inside dataTable 'footer' facet
+ String secondScrollerId = "richTable:scroller2";
+
+ for(int i = 2; i <= 5; i++) {
+ HtmlElement next = getNextButton(page, secondScrollerId);
+ next.click();
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller outside dataTable has switched
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkLastPageButtons(page, firstScrollerId, secondScrollerId);
+
+ //scroll back
+ for(int i = 4; i >= 1; i--) {
+ HtmlElement previous = getPreviousButton(page, secondScrollerId);
+ previous.click();
+
+ HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
+ assertEquals("span", currentDigital2.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital2.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // if scroller inside dataTable has switched
+ HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
+ assertEquals("span", currentDigital1.getNodeName());
+ assertEquals("rf-ds-dtl rf-ds-cur",
currentDigital1.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ // check if page has switched
+ assertEquals(i + " page content", getCurrentPageContent(page, i));
+ }
+
+ checkFirstPageButtons(page, firstScrollerId, secondScrollerId);
+ }
+
+ @Test
public void testOutDataScrollerFastButtons() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
String firstScrollerId = "scroller1";
@@ -140,7 +240,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 3; i <= 5; i = i + 2) {
HtmlElement ff = getFastForwardButton(page, firstScrollerId);
ff.click();
@@ -161,7 +261,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 3; i >= 1; i = i - 2) {
HtmlElement fr = getFastRewindButton(page, firstScrollerId);
fr.click();
HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
@@ -189,7 +289,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 3; i <= 5; i = i + 2) {
HtmlElement ff = getFastForwardButton(page, secondScrollerId);
ff.click();
HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
@@ -208,7 +308,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 3; i >= 1; i = i - 2) {
HtmlElement fr = getFastRewindButton(page, secondScrollerId);
fr.click();
@@ -227,7 +327,7 @@
checkFirstPageButtons(page, firstScrollerId, secondScrollerId);
}
-
+
@Test
public void testOutDataScrollerDigitalButtons() throws Exception {
HtmlPage page = environment.getPage("/test.jsf");
@@ -236,7 +336,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 2; i <= 5; i++) {
HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
currentDigital1.click();
@@ -256,7 +356,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 4; i >= 1; i--) {
HtmlElement currentDigital1 = getDigitalButton(page, firstScrollerId, i);
currentDigital1.click();
@@ -284,7 +384,7 @@
//dataScroller inside dataTable 'footer' facet
String secondScrollerId = "richTable:scroller2";
- for(int i = 2; i <= 6; i++) {
+ for(int i = 2; i <= 5; i++) {
HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
currentDigital2.click();
@@ -304,7 +404,7 @@
checkLastPageButtons(page, firstScrollerId, secondScrollerId);
//scroll back
- for(int i = 5; i >= 1; i--) {
+ for(int i = 4; i >= 1; i--) {
HtmlElement currentDigital2 = getDigitalButton(page, secondScrollerId, i);
currentDigital2.click();
@@ -333,25 +433,35 @@
private void checkFirstPageButtons(HtmlPage page, String firstScrollerId, String
secondScrollerId) throws Exception {
HtmlElement fastForward = getFastForwardButton(page, firstScrollerId);
HtmlElement last = getLastButton(page, firstScrollerId);
+ HtmlElement next = getNextButton(page, firstScrollerId);
+ //check right buttons
assertEquals("a", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
assertEquals("a", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("a", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
fastForward = getFastForwardButton(page, secondScrollerId);
last = getFastForwardButton(page, secondScrollerId);
-
+ next = getNextButton(page, secondScrollerId);
+
assertEquals("a", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
assertEquals("a", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r",
last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("a", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
//check if left buttons is disabled
HtmlElement fastRewind = getFastRewindButton(page, firstScrollerId);
HtmlElement first = getFirstButton(page, firstScrollerId);
+ HtmlElement previous = getPreviousButton(page, firstScrollerId);
assertEquals("span", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
@@ -359,20 +469,28 @@
assertEquals("span", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("span", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
fastRewind = getFastRewindButton(page, secondScrollerId);
first = getFirstButton(page, secondScrollerId);
+ next = getNextButton(page, secondScrollerId);
assertEquals("span", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
assertEquals("span", first.getNodeName());
- assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
first.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+ assertEquals("span", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l rf-ds-dis",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
}
private void checkLastPageButtons(HtmlPage page, String firstScrollerId, String
secondScrollerId) throws Exception {
//check if right buttons is disabled
HtmlElement fastForward = getFastForwardButton(page, firstScrollerId);
HtmlElement last = getLastButton(page, firstScrollerId);
+ HtmlElement next = getNextButton(page, firstScrollerId);
assertEquals("span", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
@@ -380,8 +498,13 @@
assertEquals("span", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("span", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
+
fastForward = getFastForwardButton(page, secondScrollerId);
last = getFastForwardButton(page, secondScrollerId);
+ next = getNextButton(page, secondScrollerId);
assertEquals("span", fastForward.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
fastForward.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
@@ -389,9 +512,13 @@
assertEquals("span", last.getNodeName());
assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
last.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("span", next.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-r rf-ds-dis",
next.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
//check if left buttons is enabled
HtmlElement fastRewind = getFastRewindButton(page, firstScrollerId);
HtmlElement first = getFirstButton(page, firstScrollerId);
+ HtmlElement previous = getPreviousButton(page, firstScrollerId);
assertEquals("a", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
@@ -399,14 +526,21 @@
assertEquals("a", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+ assertEquals("a", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
+
fastRewind = getFastRewindButton(page, secondScrollerId);
first = getFirstButton(page, secondScrollerId);
+ previous = getPreviousButton(page, secondScrollerId);
assertEquals("a", fastRewind.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
fastRewind.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
assertEquals("a", first.getNodeName());
assertEquals("rf-ds-btn rf-ds-l",
first.getAttribute(HtmlConstants.CLASS_ATTRIBUTE).trim());
+
+ assertEquals("a", previous.getNodeName());
+ assertEquals("rf-ds-btn rf-ds-l",
previous.getAttribute(HTML.CLASS_ATTRIBUTE).trim());
}
private String getCurrentPageContent(HtmlPage page, int i) throws Exception {
@@ -416,6 +550,14 @@
return text.getNodeValue();
}
+ private HtmlElement getPreviousButton(HtmlPage page, String scrollerId) {
+ return page.getFirstByXPath("//*[@id = 'form:" + scrollerId
+"_ds_prev']");
+ }
+
+ private HtmlElement getNextButton(HtmlPage page, String scrollerId) {
+ return page.getFirstByXPath("//*[@id = 'form:" + scrollerId
+"_ds_next']");
+ }
+
private HtmlElement getFastRewindButton(HtmlPage page, String scrollerId) {
return page.getFirstByXPath("//*[@id = 'form:" + scrollerId
+"_ds_fr']");
}
Modified:
branches/RF-7560/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml
===================================================================
---
branches/RF-7560/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/iteration/ui/src/test/resources/org/richfaces/renderkit/dataTableTest.xhtml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -13,7 +13,7 @@
<h:body>
<h:form id="form">
- <it:dataScroller id="scroller1" for="richTable"
page="#{dataScrollerBean.pageNumber}"
maxPages="6"></it:dataScroller>
+ <it:dataScroller fastStep="2" id="scroller1"
for="richTable" page="#{dataScrollerBean.pageNumber}"
maxPages="5"></it:dataScroller>
<it:dataTable id="richTable" rowKeyVar="rowKey"
var="content" value="#{dataScrollerBean.content}"
rows="1">
<it:column>
<h:panelGroup id="pageContent">
@@ -21,7 +21,7 @@
</h:panelGroup>
</it:column>
<f:facet name="footer">
- <it:dataScroller id="scroller2" for="richTable"
page="#{dataScrollerBean.pageNumber}"
maxPages="6"></it:dataScroller>
+ <it:dataScroller fastStep="2" id="scroller2"
for="richTable" page="#{dataScrollerBean.pageNumber}"
maxPages="5"></it:dataScroller>
</f:facet>
</it:dataTable>
</h:form>
Copied:
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java
(from rev 19108,
trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java)
===================================================================
---
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java
(rev 0)
+++
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandEvent.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class ChangeExpandEvent extends FacesEvent {
+
+ private final Boolean isExpanded;
+
+
+ // ------------------------------------------------------------ Constructors
+
+ /**
+ * <p>Construct a new event object from the specified source component,
+ * old value, and new value.</p>
+ *
+ * <p>The default {@link javax.faces.event.PhaseId} for this event is {@link
+ * javax.faces.event.PhaseId#ANY_PHASE}.</p>
+ *
+ * @param component Source {@link UIComponent} for this event
+ * @param isExpanded
+ *
+ * @throws IllegalArgumentException if <code>component</code> is
+ * <code>null</code>
+ */
+ public ChangeExpandEvent(UIComponent component, Boolean isExpanded) {
+ super(component);
+ this.isExpanded = isExpanded;
+ }
+
+
+ // -------------------------------------------------------------- Properties
+
+ public Boolean getExpanded() {
+ return isExpanded;
+ }
+
+ // ------------------------------------------------- Event Broadcast Methods
+
+
+ @Override
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof ChangeExpandListener;
+ }
+
+ /**
+ * @throws javax.faces.event.AbortProcessingException {@inheritDoc}
+ */
+ @Override
+ public void processListener(FacesListener listener) {
+ ((ChangeExpandListener) listener).processChangeExpand(this);
+ }
+}
+
Copied:
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java
(from rev 19108,
trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java)
===================================================================
---
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java
(rev 0)
+++
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandListener.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * <p>A listener interface for receiving {@link ChangeExpandEvent}s. A class
+ * that is interested in receiving such events implements this interface, and
+ * then registers itself with the source {@link javax.faces.component.UIComponent} of
interest, by
+ * calling <code>addChangeExpandListener()</code>.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ * @since 2010-08-27
+ *
+ */
+public interface ChangeExpandListener extends FacesListener {
+
+
+ /**
+ * <p>Invoked when {@link ChangeExpandEvent} occurs.</p>
+ *
+ * @param event The {@link ChangeExpandEvent} that has occurred
+ *
+ * @throws AbortProcessingException Signal the JavaServer Faces
+ * implementation that no further processing on the current event
+ * should be performed
+ */
+ public void processChangeExpand(ChangeExpandEvent event)
+ throws AbortProcessingException;
+
+}
Copied:
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java
(from rev 19108,
trunk/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java)
===================================================================
---
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java
(rev 0)
+++
branches/RF-7560/ui/output/api/src/main/java/org/richfaces/event/ChangeExpandSource.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.event;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public interface ChangeExpandSource {
+
+ /**
+ * <p>Add a new {@link org.richfaces.event.ChangeExpandListener} to the set of
listeners
+ * interested in being notified when {@link org.richfaces.event.ChangeExpandEvent}s
occur.</p>
+ *
+ * @param listener The {@link org.richfaces.event.ChangeExpandListener} to be added
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ void addChangeExpandListener(ChangeExpandListener listener);
+
+ /**
+ * <p>Return the set of registered {@link
org.richfaces.event.ChangeExpandListener}s for this instance.
+ * If there are no registered listeners, a zero-length array is returned.</p>
+ */
+ ChangeExpandListener[] getChangeExpandListeners();
+
+ /**
+ * <p>Remove an existing {@link org.richfaces.event.ChangeExpandListener} (if
any) from the
+ * set of listeners interested in being notified when
+ * {@link org.richfaces.event.ChangeExpandEvent}s occur.</p>
+ *
+ * @param listener The {@link org.richfaces.event.ChangeExpandListener} to be
removed
+ * @throws NullPointerException if <code>listener</code>
+ * is <code>null</code>
+ */
+ void removeChangeExpandListener(ChangeExpandListener listener);
+
+}
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.event.ChangeExpandEvent;
+import org.richfaces.event.ChangeExpandListener;
+import org.richfaces.event.ChangeExpandSource;
+import org.richfaces.event.ItemChangeEvent;
+
+import javax.el.MethodExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public abstract class AbstractCollapsiblePanel extends UITogglePanel implements
ChangeExpandSource {
+
+ public static final String COMPONENT_TYPE =
"org.richfaces.CollapsiblePanel";
+
+ public static final String COMPONENT_FAMILY =
"org.richfaces.CollapsiblePanel";
+
+ public enum States {
+ expanded("exp"),
+ collapsed("colps");
+
+ private final String abbreviation;
+
+ States(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String abbreviation() {
+ return abbreviation;
+ }
+ }
+
+ protected AbstractCollapsiblePanel() {
+ setRendererType("org.richfaces.CollapsiblePanel");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ @Override
+ public String getActiveItem() {
+ String ai = super.getActiveItem();
+ return ai == null ? "true" : ai;
+ }
+
+ @Override
+ protected boolean isActiveItem(UIComponent kid) {
+ return isExpanded();
+ }
+
+ @Override
+ protected boolean isActiveItem(UIComponent kid, String value) {
+ return isExpanded();
+ }
+
+
+ public boolean isExpanded() {
+ return Boolean.parseBoolean(getActiveItem());
+ }
+
+ public void setExpanded(boolean isExpanded) {
+ setActiveItem(String.valueOf(isExpanded));
+ }
+
+ public abstract String getHeader();
+
+ public abstract MethodExpression getChangeExpandListener();
+
+ @Override
+ public void queueEvent(FacesEvent facesEvent) {
+ ChangeExpandEvent event = null;
+ if ((facesEvent instanceof ItemChangeEvent) && (facesEvent.getComponent()
== this)) {
+ event = new ChangeExpandEvent(this, Boolean.valueOf(((ItemChangeEvent)
facesEvent).getNewItem()));
+
+ setEventPhase(event);
+ }
+
+ super.queueEvent(event != null ? event : facesEvent);
+ }
+
+ // ------------------------------------------------ Event Processing Methods
+
+ public void addChangeExpandListener(ChangeExpandListener listener) {
+ addFacesListener(listener);
+ }
+
+ public ChangeExpandListener[] getChangeExpandListeners() {
+ return (ChangeExpandListener[]) getFacesListeners(ChangeExpandListener.class);
+ }
+
+ public void removeChangeExpandListener(ChangeExpandListener listener) {
+ removeFacesListener(listener);
+ }
+}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractDivPanel.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -27,7 +27,6 @@
/**
* @author akolonitsky
* @version 1.0
- * @since -4712-01-01
*
*/
public abstract class AbstractDivPanel extends UIOutput {
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -60,6 +60,14 @@
public static final String COMPONENT_FAMILY = "org.richfaces.TogglePanel";
+ public static final String META_NAME_FIRST = "@first";
+ public static final String META_NAME_PREV = "@prev";
+ public static final String META_NAME_NEXT = "@next";
+ public static final String META_NAME_LAST = "@last";
+
+ // TODO What is MessageId ?
+ public static final String UPDATE_MESSAGE_ID =
"javax.faces.component.UIInput.UPDATE";
+
private String submittedActiveItem = null;
private enum PropertyKeys {
@@ -372,7 +380,7 @@
String previous = (String) getValue();
setValue(activeItem);
setSubmittedActiveItem(null);
- if (!previous.equalsIgnoreCase(activeItem)) {
+ if (previous != null && !previous.equalsIgnoreCase(activeItem)) {
queueEvent(new ItemChangeEvent(this, previous, activeItem));
}
}
@@ -380,18 +388,23 @@
@Override
public void queueEvent(FacesEvent event) {
if ((event instanceof ItemChangeEvent) && (event.getComponent() == this))
{
- if (isImmediate()) {
- event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
- } else if (isBypassUpdates()) {
- event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
- } else {
- event.setPhaseId(PhaseId.INVOKE_APPLICATION);
- }
+ setEventPhase(event);
}
super.queueEvent(event);
}
+ protected void setEventPhase(FacesEvent event) {
+ if (isImmediate()) {
+ event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
+ } else if (isBypassUpdates()) {
+ event.setPhaseId(PhaseId.PROCESS_VALIDATIONS);
+ } else {
+ event.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ }
+ }
+
+
@Override
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
@@ -425,7 +438,7 @@
return isActiveItem(kid, getActiveItemValue());
}
- protected static boolean isActiveItem(UIComponent kid, String value) {
+ protected boolean isActiveItem(UIComponent kid, String value) {
if (kid == null || value == null) {
return false;
}
@@ -469,13 +482,13 @@
}
public AbstractTogglePanelItem getItem(String name) {
- if ("(a)first".equals(name)) {
+ if (META_NAME_FIRST.equals(name)) {
return getFirstItem();
- } else if ("(a)prev".equals(name)) {
+ } else if (META_NAME_PREV.equals(name)) {
return getPrevItem();
- } else if ("(a)next".equals(name)) {
+ } else if (META_NAME_NEXT.equals(name)) {
return getNextItem();
- } else if ("(a)last".equals(name)) {
+ } else if (META_NAME_LAST.equals(name)) {
return getLastItem();
} else {
return getItemByIndex(getChildIndex(name));
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -28,6 +28,7 @@
import javax.faces.context.FacesContext;
import javax.faces.render.Renderer;
import java.io.IOException;
+import java.util.Map;
/**
* @author akolonitsky
@@ -94,8 +95,9 @@
}
protected static void hidePanelItem(UIComponent item) {
- //TODO nick - attributes shouldn't be overwritten
- item.getAttributes().put(HtmlConstants.STYLE_ATTRIBUTE,
"display:none");
+ Map<String,Object> attrs = item.getAttributes();
+ Object style = attrs.get(RendererUtils.HTML.STYLE_ATTRIBUTE);
+ attrs.put(RendererUtils.HTML.STYLE_ATTRIBUTE, "display:none; " +
style);
}
public abstract String getName();
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -22,6 +22,8 @@
package org.richfaces.component;
+import org.richfaces.renderkit.html.DivPanelRenderer;
+
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import java.io.IOException;
@@ -36,6 +38,22 @@
public static final String COMPONENT_FAMILY =
"org.richfaces.TogglePanelTitledItem";
+ public enum HeaderStates {
+ active("act"),
+ inactive("inact"),
+ disable("dis");
+
+ private final String abbreviation;
+
+ HeaderStates(String abbreviation) {
+ this.abbreviation = abbreviation;
+ }
+
+ public String abbreviation() {
+ return abbreviation;
+ }
+ }
+
protected AbstractTogglePanelTitledItem() {
setRendererType("org.richfaces.TogglePanelTitledItem");
}
@@ -61,14 +79,32 @@
}
encodeBegin(context);
- if (getRendersChildren()) {
- encodeChildren(context);
- } else if (this.getChildCount() > 0) {
- for (UIComponent kid : getChildren()) {
- kid.encodeAll(context);
+ if (!isDisabled()) {
+ if (getRendersChildren()) {
+ encodeChildren(context);
+ } else if (this.getChildCount() > 0) {
+ for (UIComponent kid : getChildren()) {
+ kid.encodeAll(context);
+ }
}
}
-
+
encodeEnd(context);
}
+
+ public UIComponent getHeaderFacet(Enum<?> state) {
+ return getHeaderFacet(this, state);
+ }
+
+ public static UIComponent getHeaderFacet(UIComponent component, Enum<?> state)
{
+ UIComponent headerFacet = null;
+ if (state != null) {
+ headerFacet = component.getFacet("header" +
DivPanelRenderer.capitalize(state.toString()));
+ }
+
+ if (headerFacet == null) {
+ headerFacet = component.getFacet("header");
+ }
+ return headerFacet;
+ }
}
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UICollapsiblePanel.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.component;
+
+import javax.el.MethodExpression;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class UICollapsiblePanel extends AbstractCollapsiblePanel {
+
+ public enum PropertyKeys {
+ header,
+ changeExpandListener
+ }
+
+ public String getHeader() {
+ return (String) getStateHelper().eval(PropertyKeys.header);
+ }
+
+ public void setHeader(String header) {
+ getStateHelper().put(PropertyKeys.header, header);
+ }
+
+ public MethodExpression getChangeExpandListener() {
+ return (MethodExpression)
getStateHelper().get(PropertyKeys.changeExpandListener);
+ }
+
+ public void setChangeExpandListener(MethodExpression changeExpandListener) {
+ getStateHelper().put(PropertyKeys.changeExpandListener, changeExpandListener);
+ }
+}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -36,7 +36,7 @@
}
public String getName() {
- return (String) getStateHelper().eval(PropertyKeys.name);
+ return (String) getStateHelper().eval(PropertyKeys.name, getId());
}
public void setName(String name) {
@@ -50,6 +50,4 @@
public void setSwitchType(SwitchType switchType) {
getStateHelper().put(PropertyKeys.switchType, switchType);
}
-
-
}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -56,7 +56,7 @@
}
public String getTargetItem() {
- return (String) getStateHelper().eval(PropertyKeys.targetItem);
+ return (String) getStateHelper().eval(PropertyKeys.targetItem,
AbstractTogglePanel.META_NAME_NEXT);
}
public void setTargetItem(String target) {
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlCollapsiblePanel.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,245 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.component.html;
+
+import org.richfaces.component.UICollapsiblePanel;
+import javax.faces.component.behavior.ClientBehaviorHolder;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class HtmlCollapsiblePanel extends UICollapsiblePanel implements
ClientBehaviorHolder {
+
+ public static final String COMPONENT_TYPE =
"org.richfaces.CollapsiblePanel";
+
+ public static final String COMPONENT_FAMILY =
"org.richfaces.CollapsiblePanel";
+
+ private static final Collection<String> EVENT_NAMES =
Collections.unmodifiableCollection(Arrays.asList(
+ "switch",
+ "beforeswitch",
+ "click",
+ "dblclick",
+ "mousedown",
+ "mousemove",
+ "mouseout",
+ "mouseover",
+ "mouseup"
+ ));
+
+
+ public enum PropertyKeys {
+ bodyClass,
+ headerClass,
+ headerControlClass,
+ oncomplete,
+ onbeforedomupdate,
+ onswitch,
+ onbeforeswitch,
+ lang,
+ title,
+ style,
+ styleClass,
+ dir,
+ onclick,
+ ondblclick,
+ onmousedown,
+ onmousemove,
+ onmouseout,
+ onmouseover,
+ onmouseup
+ }
+
+ public HtmlCollapsiblePanel() {
+ setRendererType("org.richfaces.CollapsiblePanel");
+ }
+
+ @Override
+ public String getFamily() {
+ return COMPONENT_FAMILY;
+ }
+
+ public String getBodyClass() {
+ return (String) getStateHelper().eval(PropertyKeys.bodyClass);
+ }
+
+ public void setBodyClass(String bodyClass) {
+ getStateHelper().put(PropertyKeys.bodyClass, bodyClass);
+ }
+
+ public String getHeaderClass() {
+ return (String) getStateHelper().eval(PropertyKeys.headerClass);
+ }
+
+ public void setHeaderClass(String headerClass) {
+ getStateHelper().put(PropertyKeys.headerClass, headerClass);
+ }
+
+ public String getHeaderControlClass() {
+ return (String) getStateHelper().eval(PropertyKeys.headerControlClass);
+ }
+
+ public void setHeaderControlClass(String headerControlClass) {
+ getStateHelper().put(PropertyKeys.headerControlClass, headerControlClass);
+ }
+
+ public String getOncomplete() {
+ return (String) getStateHelper().eval(PropertyKeys.oncomplete);
+ }
+
+ public void setOncomplete(String oncomplete) {
+ getStateHelper().put(PropertyKeys.oncomplete, oncomplete);
+ }
+
+ public String getOnbeforedomupdate() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforedomupdate);
+ }
+
+ public void setOnbeforedomupdate(String onbeforedomupdate) {
+ getStateHelper().put(PropertyKeys.onbeforedomupdate, onbeforedomupdate);
+ }
+
+ public String getOnswitch() {
+ return (String) getStateHelper().eval(PropertyKeys.onswitch);
+ }
+
+ public void setOnswitch(String onswitch) {
+ getStateHelper().put(PropertyKeys.onswitch, onswitch);
+ }
+
+ public String getOnbeforeswitch() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforeswitch);
+ }
+
+ public void setOnbeforeswitch(String onbeforeswitch) {
+ getStateHelper().put(PropertyKeys.onbeforeswitch, onbeforeswitch);
+ }
+
+ public String getLang() {
+ return (String) getStateHelper().eval(PropertyKeys.lang);
+ }
+
+ public void setLang(String lang) {
+ getStateHelper().put(PropertyKeys.lang, lang);
+ }
+
+ public String getTitle() {
+ return (String) getStateHelper().eval(PropertyKeys.title);
+ }
+
+ public void setTitle(String title) {
+ getStateHelper().put(PropertyKeys.title, title);
+ }
+
+ public String getStyle() {
+ return (String) getStateHelper().eval(PropertyKeys.style);
+ }
+
+ public void setStyle(String style) {
+ getStateHelper().put(PropertyKeys.style, style);
+ }
+
+ public String getStyleClass() {
+ return (String) getStateHelper().eval(PropertyKeys.styleClass);
+ }
+
+ public void setStyleClass(String styleClass) {
+ getStateHelper().put(PropertyKeys.styleClass, styleClass);
+ }
+
+ public String getDir() {
+ return (String) getStateHelper().eval(PropertyKeys.dir);
+ }
+
+ public void setDir(String dir) {
+ getStateHelper().put(PropertyKeys.dir, dir);
+ }
+
+ public String getOnclick() {
+ return (String) getStateHelper().eval(PropertyKeys.onclick);
+ }
+
+ public void setOnclick(String onclick) {
+ getStateHelper().put(PropertyKeys.onclick, onclick);
+ }
+
+ public String getOndblclick() {
+ return (String) getStateHelper().eval(PropertyKeys.ondblclick);
+ }
+
+ public void setOndblclick(String ondblclick) {
+ getStateHelper().put(PropertyKeys.ondblclick, ondblclick);
+ }
+
+ public String getOnmousedown() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousedown);
+ }
+
+ public void setOnmousedown(String onmousedown) {
+ getStateHelper().put(PropertyKeys.onmousedown, onmousedown);
+ }
+
+ public String getOnmousemove() {
+ return (String) getStateHelper().eval(PropertyKeys.onmousemove);
+ }
+
+ public void setOnmousemove(String onmousemove) {
+ getStateHelper().put(PropertyKeys.onmousemove, onmousemove);
+ }
+
+ public String getOnmouseout() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseout);
+ }
+
+ public void setOnmouseout(String onmouseout) {
+ getStateHelper().put(PropertyKeys.onmouseout, onmouseout);
+ }
+
+ public String getOnmouseover() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseover);
+ }
+
+ public void setOnmouseover(String onmouseover) {
+ getStateHelper().put(PropertyKeys.onmouseover, onmouseover);
+ }
+
+ public String getOnmouseup() {
+ return (String) getStateHelper().eval(PropertyKeys.onmouseup);
+ }
+
+ public void setOnmouseup(String onmouseup) {
+ getStateHelper().put(PropertyKeys.onmouseup, onmouseup);
+ }
+
+
+
+ @Override
+ public Collection<String> getEventNames() {
+ return EVENT_NAMES;
+ }
+}
+
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.event;
+
+import javax.el.MethodExpression;
+import javax.faces.event.AbortProcessingException;
+
+/**
+ * <p><strong><span
+ *
class="changed_modified_2_0">MethodExpressionChangeExpandListener</span></strong>
+ * is a {@link ChangeExpandListener} that wraps a {@link
+ * MethodExpression}. When it receives a {@link ChangeExpandEvent}, it
+ * executes a method on an object identified by the {@link
+ * MethodExpression}.</p>
+ *
+ * @author akolonitsky
+ * @version 1.0
+ *
+ */
+public class MethodExpressionChangeExpandListener extends MethodExpressionEventListener
implements ChangeExpandListener {
+
+ public MethodExpressionChangeExpandListener() {
+ super();
+ }
+
+ public MethodExpressionChangeExpandListener(MethodExpression methodExprOneArg) {
+ super(methodExprOneArg);
+ }
+
+ public MethodExpressionChangeExpandListener(MethodExpression methodExprOneArg,
MethodExpression methodExprZeroArg) {
+ super(methodExprOneArg, methodExprZeroArg);
+ }
+
+ // ------------------------------------------------------- Listener Method
+
+ public void processChangeExpand(ChangeExpandEvent changeExpandEvent) throws
AbortProcessingException {
+ processEvent(changeExpandEvent);
+ }
+}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -22,13 +22,7 @@
package org.richfaces.event;
-import javax.el.ELContext;
-import javax.el.ELException;
import javax.el.MethodExpression;
-import javax.el.MethodNotFoundException;
-import javax.faces.component.StateHolder;
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
/**
@@ -44,158 +38,23 @@
* @since -4712-01-01
*
*/
-//TODO nick - good candidate for utility class
-public class MethodExpressionItemChangeListener implements ItemChangeListener,
StateHolder {
+public class MethodExpressionItemChangeListener extends MethodExpressionEventListener
implements ItemChangeListener {
- private static final Class<?>[] ITEM_CHANGE_LISTENER_ZERO_ARG_SIG = new Class[]
{};
-
- private static final Object[] NO_PARAMS = new Object[0];
-
- // ------------------------------------------------------ Instance Variables
-
- private MethodExpression methodExpressionOneArg = null;
- private MethodExpression methodExpressionZeroArg = null;
-
- private boolean isTransient;
-
public MethodExpressionItemChangeListener() {
}
- /**
- * <p><span class="changed_modified_2_0">Construct</span>
a {@link
- * ItemChangeListener} that contains a {@link
- * MethodExpression}.<span
- * class="changed_added_2_0">To accomodate method expression targets
- * that take no arguments instead of taking a {@link
- * ItemChangeEvent} argument</span>, the implementation of this
- * class must take the argument <code>methodExpressionOneArg</code>,
- * extract its expression string, and create another
- * <code>MethodExpression</code> whose expected param types match
- * those of a zero argument method. The usage requirements for both
- * of these <code>MethodExpression</code> instances are described in
- * {@link #processItemChange}.</p>
- *
- * @param methodExpressionOneArg a <code>MethodExpression</code>
- * that points to a method that returns <code>void</code> and takes
- * a single argument of type {@link ItemChangeEvent}.
- */
- public MethodExpressionItemChangeListener(MethodExpression methodExpressionOneArg) {
-
- super();
- this.methodExpressionOneArg = methodExpressionOneArg;
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- this.methodExpressionZeroArg = context.getApplication().
- getExpressionFactory().createMethodExpression(elContext,
- methodExpressionOneArg.getExpressionString(), Void.class,
- ITEM_CHANGE_LISTENER_ZERO_ARG_SIG);
+ public MethodExpressionItemChangeListener(MethodExpression methodExprOneArg) {
+ super(methodExprOneArg);
}
- /**
- * <p>Construct a {@link ItemChangeListener} that contains a {@link
MethodExpression}.</p>
- *
- * @param methodExpressionOneArg
- * @param methodExpressionZeroArg
- */
- public MethodExpressionItemChangeListener(MethodExpression methodExpressionOneArg,
- MethodExpression methodExpressionZeroArg) {
-
- super();
- this.methodExpressionOneArg = methodExpressionOneArg;
- this.methodExpressionZeroArg = methodExpressionZeroArg;
+ public MethodExpressionItemChangeListener(MethodExpression methodExprOneArg,
MethodExpression methodExprZeroArg) {
+ super(methodExprOneArg, methodExprZeroArg);
}
- // ------------------------------------------------------- Event Method
+ // ------------------------------------------------------- Listener Method
- /**
- * <p><span class="changed_modified_2_0">Call</span>
through to the
- * {@link MethodExpression} passed in our constructor. <span
- * class="changed_added_2_0">First, try to invoke the
- * <code>MethodExpression</code> passed to the constructor of this
- * instance, passing the argument {@link ItemChangeEvent} as the
- * argument. If a {@link MethodNotFoundException} is thrown, call
- * to the zero argument <code>MethodExpression</code> derived from
- * the <code>MethodExpression</code> passed to the constructor of
- * this instance. If that fails for any reason, throw an {@link
- * AbortProcessingException}, including the cause of the
- * failure.</span></p>
- *
- * @throws NullPointerException {@inheritDoc}
- * @throws AbortProcessingException {@inheritDoc}
- */
public void processItemChange(ItemChangeEvent itemChangeEvent) throws
AbortProcessingException {
-
- if (itemChangeEvent == null) {
- throw new NullPointerException();
- }
- FacesContext context = FacesContext.getCurrentInstance();
- ELContext elContext = context.getELContext();
- // PENDING: The corresponding code in MethodExpressionActionListener
- // has an elaborate message capture, logging, and rethrowing block.
- // Why not here?
- try {
- methodExpressionOneArg.invoke(elContext, new Object[] {itemChangeEvent});
- } catch (MethodNotFoundException mnf) {
- if (null != methodExpressionZeroArg) {
-
- try {
- // try to invoke a no-arg version
- methodExpressionZeroArg.invoke(elContext, NO_PARAMS);
- } catch (ELException e) {
- throw new AbortProcessingException(e.getMessage(), e.getCause());
- }
- }
- } catch (ELException e) {
- throw new AbortProcessingException(e.getMessage(), e.getCause());
- }
+ processEvent(itemChangeEvent);
}
-
-
- // ------------------------------------------------ Methods from StateHolder
-
-
- /**
- * <p class="changed_modified_2_0">Both {@link MethodExpression}
- * instances described in the constructor must be saved.</p>
- */
- public Object saveState(FacesContext context) {
- if (context == null) {
- throw new NullPointerException();
- }
-
- return new Object[] {
- UIComponentBase.saveAttachedState(context, methodExpressionOneArg),
- UIComponentBase.saveAttachedState(context, methodExpressionZeroArg)
- };
- }
-
-
- /**
- * <p class="changed_modified_2_0">Both {@link MethodExpression}
- * instances described in the constructor must be restored.</p>
- */
- public void restoreState(FacesContext context, Object state) {
- if (context == null) {
- throw new NullPointerException();
- }
-
- if (state == null) {
- return;
- }
-
- methodExpressionOneArg = (MethodExpression) UIComponentBase
- .restoreAttachedState(context, ((Object[]) state)[0]);
- methodExpressionZeroArg = (MethodExpression) UIComponentBase
- .restoreAttachedState(context, ((Object[]) state)[1]);
- }
-
-
- public boolean isTransient() {
- return isTransient;
- }
-
- public void setTransient(boolean newTransientValue) {
- isTransient = newTransientValue;
- }
}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -23,9 +23,9 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.javascript.JSObject;
-import org.richfaces.component.AbstractTogglePanelItem;
import org.richfaces.component.AbstractTogglePanelTitledItem;
import org.richfaces.renderkit.HtmlConstants;
+import org.richfaces.renderkit.RenderKitUtils;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -33,16 +33,22 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import java.io.IOException;
+import java.util.Map;
+import static org.richfaces.component.AbstractTogglePanelTitledItem.HeaderStates;
+import static org.richfaces.component.html.HtmlAccordionItem.PropertyKeys;
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.renderkit.RenderKitUtils.renderPassThroughAttributes;
+
/**
*
- * <div id="clientId" class="rf-aci">
- * <div id="clientId:header" class="rf-aci-h">
- * <div class="rf-aci-h-inactive">Level 1</div>
- * <div class="rf-aci-h-active" >Level 1</div>
- * <div class="rf-aci-h-disabled">Level 1</div>
+ * <div id="clientId" class="rf-ac-itm">
+ * <div id="clientId:header" class="rf-ac-itm-hdr">
+ * <div class="rf-ac-itm-hdr-inact">Level 1</div>
+ * <div class="rf-ac-itm-hdr-act" >Level 1</div>
+ * <div class="rf-ac-itm-hdr-dis">Level 1</div>
* </div>
- * <div id="clientId:content" class="rf-aci-c">
+ * <div id="clientId:content" class="rf-ac-itm-cnt">
* Content will be here.
* </div>
* </div>
@@ -50,7 +56,7 @@
* @author akolonitsky
* @since 2010-08-05
*/
-@ResourceDependencies({ // TODO review
+@ResourceDependencies({
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js"),
@@ -61,6 +67,14 @@
})
public class AccordionItemRenderer extends TogglePanelItemRenderer {
+ private static final RenderKitUtils.Attributes HEADER_ATTRIBUTES =
RenderKitUtils.attributes()
+ .generic("style", PropertyKeys.headerStyle.toString())
+ .generic("onclick", PropertyKeys.onheaderclick.toString(),
"headerclick")
+ .generic("ondblclick", PropertyKeys.onheaderdblclick.toString(),
"headerdblclick")
+ .generic("onmousedown", PropertyKeys.onheadermousedown.toString(),
"headermousedown")
+ .generic("onmousemove", PropertyKeys.onheadermousemove.toString(),
"headermousemove")
+ .generic("onmouseup", PropertyKeys.onheadermouseup.toString(),
"headermouseup");
+
@Override
protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
super.doEncodeBegin(writer, context, component);
@@ -72,35 +86,36 @@
@Override
protected String getStyleClass(UIComponent component) {
- return "rf-aci " + attributeAsString(component,
"styleClass");
+ return concatClasses("rf-ac-itm", attributeAsString(component,
"styleClass"));
}
@Override
protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent
component) throws IOException {
encodeContentEnd(component, writer);
- super.doEncodeEnd(writer, context, component); //To change body of overridden
methods use File | Settings | File Templates.
+ super.doEncodeEnd(writer, context, component);
}
@Override
protected void writeJavaScript(ResponseWriter writer, FacesContext context,
UIComponent component) throws IOException {
- // todo how to call method from parent of parent class?
-
Object script = getScriptObject(context, component);
- if (script != null) {
- writer.startElement(HtmlConstants.SCRIPT_ELEM, component);
- writer.writeAttribute(HtmlConstants.TYPE_ATTR, "text/javascript",
"type");
- writer.writeText(script, null);
- writer.endElement(HtmlConstants.SCRIPT_ELEM);
+ if (script == null) {
+ return;
}
+
+ writer.startElement(RendererUtils.HTML.SCRIPT_ELEM, component);
+ writer.writeAttribute(RendererUtils.HTML.TYPE_ATTR, "text/javascript",
"type");
+ writer.writeText(script, null);
+ writer.endElement(RendererUtils.HTML.SCRIPT_ELEM);
}
private void encodeContentBegin(UIComponent component, ResponseWriter writer) throws
IOException {
writer.startElement("div", component);
- writer.writeAttribute("class", "rf-aci-c " +
attributeAsString(component, "contentClass"), null);
+ writer.writeAttribute("class", concatClasses("rf-ac-itm-cnt",
attributeAsString(component, "contentClass")), null);
writer.writeAttribute("id", component.getClientId() +
":content", null);
- if (!((AbstractTogglePanelItem) component).isActive()) {
+ AbstractTogglePanelTitledItem item = (AbstractTogglePanelTitledItem) component;
+ if (!item.isActive() || item.isDisabled()) {
writer.writeAttribute("style", "display: none", null);
}
}
@@ -109,24 +124,25 @@
responseWriter.endElement("div");
}
- private void encodeHeader(FacesContext facesContext, UIComponent component,
ResponseWriter responseWriter) throws IOException {
+ private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter
writer) throws IOException {
- responseWriter.startElement("div", component);
- responseWriter.writeAttribute("class", "rf-aci-h " +
attributeAsString(component, "contentClass"), null);
- responseWriter.writeAttribute("id", component.getClientId() +
":header", null);
+ writer.startElement("div", component);
+ writer.writeAttribute("class", concatClasses("rf-ac-itm-hdr",
attributeAsString(component, PropertyKeys.headerClass)), null);
+ writer.writeAttribute("id", component.getClientId() +
":header", null);
+ renderPassThroughAttributes(context, component, HEADER_ATTRIBUTES);
AbstractTogglePanelTitledItem titledItem = (AbstractTogglePanelTitledItem)
component;
boolean isActive = titledItem.isActive();
boolean isDisabled = titledItem.isDisabled();
- encodeHeader(facesContext, component, responseWriter, "inactive",
!isActive && !isDisabled);
- encodeHeader(facesContext, component, responseWriter, "active",
isActive && !isDisabled);
- encodeHeader(facesContext, component, responseWriter, "disable",
isDisabled);
+ encodeHeader(context, titledItem, writer, HeaderStates.inactive, !isActive
&& !isDisabled);
+ encodeHeader(context, titledItem, writer, HeaderStates.active, isActive
&& !isDisabled);
+ encodeHeader(context, titledItem, writer, HeaderStates.disable, isDisabled);
- responseWriter.endElement("div");
+ writer.endElement("div");
}
- private void encodeHeader(FacesContext facesContext, UIComponent component,
ResponseWriter writer,
- String state, Boolean isDisplay) throws IOException {
+ private void encodeHeader(FacesContext facesContext, AbstractTogglePanelTitledItem
component, ResponseWriter writer,
+ HeaderStates state, Boolean isDisplay) throws IOException
{
writer.startElement("div", component);
@@ -134,11 +150,10 @@
writer.writeAttribute("style", "display : none", null);
}
- String name = "headerClass" + capitalize(state);
- writer.writeAttribute("class", "rf-aci-h-" + state + "
" + attributeAsString(component, name), name);
+ String name = "headerClass" + capitalize(state.toString());
+ writer.writeAttribute("class", concatClasses("rf-ac-itm-hdr-"
+ state.abbreviation(), attributeAsString(component, name)), null);
-
- UIComponent headerFacet = component.getFacet("header" +
capitalize(state));
+ UIComponent headerFacet = component.getHeaderFacet(state);
if (headerFacet != null && headerFacet.isRendered()) {
headerFacet.encodeAll(facesContext);
} else {
@@ -158,6 +173,14 @@
}
@Override
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context,
UIComponent component) {
+ Map<String, Object> res = super.getScriptObjectOptions(context,
component);
+ res.put("disabled", ((AbstractTogglePanelTitledItem)
component).isDisabled());
+
+ return res;
+ }
+
+ @Override
protected Class<? extends UIComponent> getComponentClass() {
return AbstractTogglePanelTitledItem.class;
}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -39,9 +39,8 @@
/**
* @author akolonitsky
- * @since 2010-08-05
*/
-@ResourceDependencies( { // TODO review
+@ResourceDependencies( {
@ResourceDependency(library = "javax.faces", name = "jsf.js"),
@ResourceDependency(name = "jquery.js"),
@ResourceDependency(name = "richfaces.js"),
@@ -69,7 +68,7 @@
@Override
protected String getStyleClass(UIComponent component) {
- return "rf-ac " + attributeAsString(component,
"styleClass");
+ return HtmlUtil.concatClasses("rf-ac", attributeAsString(component,
"styleClass"));
}
@Override
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,240 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.renderkit.html;
+
+import org.ajax4jsf.javascript.JSObject;
+import org.richfaces.component.AbstractCollapsiblePanel;
+import org.richfaces.component.AbstractTogglePanel;
+import org.richfaces.component.AbstractTogglePanelTitledItem;
+
+import javax.faces.application.ResourceDependencies;
+import javax.faces.application.ResourceDependency;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.richfaces.component.AbstractCollapsiblePanel.States.*;
+import static org.richfaces.component.util.HtmlUtil.concatClasses;
+import static org.richfaces.component.util.HtmlUtil.concatStyles;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+@ResourceDependencies( {
+ @ResourceDependency(library = "javax.faces", name = "jsf.js"),
+ @ResourceDependency(name = "jquery.js"),
+ @ResourceDependency(name = "richfaces.js"),
+ @ResourceDependency(name = "richfaces-event.js"),
+ @ResourceDependency(name = "richfaces-base-component.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"TogglePanel.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"TogglePanelItem.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"CollapsiblePanel.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"CollapsiblePanelItem.js"),
+ @ResourceDependency(library = "org.richfaces", name =
"collapsiblePanel.ecss") })
+public class CollapsiblePanelRenderer extends TogglePanelRenderer {
+
+ public static final String SWITCH = "switch";
+ public static final String BEFORE_SWITCH = "beforeswitch";
+
+ @Override
+ protected void doDecode(FacesContext context, UIComponent component) {
+ AbstractTogglePanel panel = (AbstractTogglePanel) component;
+
+ Map<String, String> requestMap =
+ context.getExternalContext().getRequestParameterMap();
+
+ // Don't overwrite the value unless you have to!
+ String newValue = requestMap.get(getValueRequestParamName(context, component));
+ if (newValue != null) {
+ panel.setSubmittedActiveItem(newValue);
+ }
+
+ String compClientId = component.getClientId(context);
+ String clientId = requestMap.get(compClientId);
+ if (clientId != null && clientId.equals(compClientId)) {
+ String itemClientId = clientId + (Boolean.parseBoolean(newValue) ?
":content" : ":empty");
+ context.getPartialViewContext().getRenderIds().add(itemClientId);
+
+ //TODO nick - this should be done on encode, not on decode
+ addOnCompleteParam(newValue, panel.getClientId());
+ }
+ }
+
+ @Override
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent
comp) throws IOException {
+ super.doEncodeBegin(writer, context, comp);
+
+ encodeHeader(context, comp, writer);
+ }
+
+ @Override
+ protected String getStyleClass(UIComponent component) {
+ return concatClasses("rf-cp", super.getStyleClass(component));
+ }
+
+ @Override
+ protected JSObject getScriptObject(FacesContext context, UIComponent component) {
+ return new JSObject("RichFaces.ui.CollapsiblePanel",
+ component.getClientId(), getScriptObjectOptions(context, component));
+ }
+
+ @Override
+ protected Map<String, Object> getScriptObjectOptions(FacesContext context,
UIComponent component) {
+ AbstractTogglePanel panel = (AbstractTogglePanel) component;
+
+ Map<String, Object> options = new HashMap<String, Object>();
+ options.put("activeItem", panel.getActiveItem());
+ options.put("ajax", getAjaxOptions(context, panel));
+ options.put("switchMode", panel.getSwitchType());
+
+ TogglePanelRenderer.addEventOption(context, panel, options, SWITCH);
+ TogglePanelRenderer.addEventOption(context, panel, options, BEFORE_SWITCH);
+
+ return options;
+ }
+
+ private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter
writer) throws IOException {
+ writer.startElement("div", component);
+ writer.writeAttribute("id", component.getClientId(context) +
":header", null);
+ writer.writeAttribute("class", concatClasses("rf-cp-hdr",
attributeAsString(component, "headerClass")), null);
+
+ AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
+ encodeHeader(context, component, writer, expanded, panel.isExpanded());
+ encodeHeader(context, component, writer, collapsed, !panel.isExpanded());
+
+ writer.endElement("div");
+ }
+
+ private void encodeHeader(FacesContext context, UIComponent component, ResponseWriter
responseWriter, AbstractCollapsiblePanel.States state, boolean isVisible) throws
IOException {
+ responseWriter.startElement("div", component);
+ responseWriter.writeAttribute("class", "rf-cp-hdr-" +
state.abbreviation(), null);
+ responseWriter.writeAttribute("style",
concatStyles(styleElement("display", isVisible ? "" :
"none"), attributeAsString(component, "headerClass")), null);
+
+ UIComponent header = AbstractTogglePanelTitledItem.getHeaderFacet(component,
state);
+ if (header != null && header.isRendered()) {
+ header.encodeAll(context);
+ } else {
+ String headerText = (String)
component.getAttributes().get("header");
+ if (headerText != null && !headerText.isEmpty()) {
+ responseWriter.writeText(headerText, null);
+ }
+ }
+
+ responseWriter.endElement("div");
+ }
+
+ @Override
+ protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component)
+ throws IOException {
+
+ AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
+
+ encodeContentChild(writer, context, component, panel);
+ encodeEmptyChild(writer, context, component, panel);
+ }
+
+ private void encodeContentChild(ResponseWriter writer, FacesContext context,
UIComponent component, AbstractCollapsiblePanel panel) throws IOException {
+ if (panel.isExpanded()) {
+ encodeContent(writer, context, component, true);
+ } else {
+ switch (panel.getSwitchType()) {
+ case client:
+ encodeContent(writer, context, component, false);
+ break;
+
+ case ajax:
+ context.getResponseWriter().write(getPlaceHolder(panel.getClientId()
+ ":content"));
+ break;
+
+ case server:
+ // Do nothing.
+ break;
+
+ default:
+ throw new IllegalStateException("Unknown switch type : " +
panel.getSwitchType());
+ }
+ }
+ }
+
+ private void encodeEmptyChild(ResponseWriter writer, FacesContext context,
UIComponent component, AbstractCollapsiblePanel panel) throws IOException {
+ if (!panel.isExpanded()) {
+ encodeEmptyDiv(writer, context, component, true);
+ } else {
+ switch (panel.getSwitchType()) {
+ case client:
+ encodeEmptyDiv(writer, context, component, false);
+ break;
+
+ case ajax:
+ context.getResponseWriter().write(getPlaceHolder(panel.getClientId()
+ ":empty"));
+ break;
+
+ case server:
+ // Do nothing.
+ break;
+
+ default:
+ throw new IllegalStateException("Unknown switch type : " +
panel.getSwitchType());
+ }
+ }
+ }
+
+ private String getPlaceHolder(String id) {
+ return "<div id=\"" + id + "\" style=\"display:
none\" ></div>";
+ }
+
+ private void encodeContent(ResponseWriter writer, FacesContext context, UIComponent
component, boolean visible) throws IOException {
+ writer.startElement("div", component);
+ writer.writeAttribute("id", component.getClientId() +
":content", null);
+ writer.writeAttribute("class", concatClasses("rf-cp-b",
attributeAsString(component, "bodyClass")), null);
+ writer.writeAttribute("style", concatStyles(visible ? "" :
"none", attributeAsString(component, "style")), null);
+
+ renderChildren(context, component);
+
+ writer.endElement("div");
+ }
+
+ private void encodeEmptyDiv(ResponseWriter writer, FacesContext context, UIComponent
component, boolean visible) throws IOException {
+ writer.startElement("div", component);
+ writer.writeAttribute("id", component.getClientId() +
":empty", null);
+ writer.writeAttribute("class", "rf-cp-empty", null);
+ writer.writeAttribute("style", styleElement("display",
visible ? "" : "none"), null);
+ writer.endElement("div");
+ }
+
+ @Override
+ protected List<JSObject> getChildrenScriptObjects(FacesContext context,
UIComponent component) {
+ return null;
+ }
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return AbstractCollapsiblePanel.class;
+ }
+}
+
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -62,12 +62,18 @@
return "";
}
+ return styleElement(attr, value);
+ }
+
+ protected static String styleElement(Object name, Object value) {
return new StringBuilder()
- .append(attr).append(':').append(value).toString();
+ .append(name).append(':').append(value).toString();
}
+
protected static String attributeAsString(UIComponent comp, Enum attr) {
return attributeAsString(comp, attr.toString());
}
+
protected static String attributeAsString(UIComponent comp, String attr) {
Object o = comp.getAttributes().get(attr);
return o == null ? "" : o.toString();
@@ -80,7 +86,7 @@
* @return Capitalized string.
* @throws IllegalArgumentException String is <kk>null</kk> or empty.
*/
- protected static String capitalize(final String string) {
+ public static String capitalize(final String string) {
return Character.toUpperCase(string.charAt(0)) + string.substring(1);
}
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelItemRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -54,7 +54,7 @@
@Override
protected String getStyleClass(UIComponent component) {
- return HtmlUtil.concatClasses("rf-tgp-i", attributeAsString(component,
"styleClass"));
+ return HtmlUtil.concatClasses("rf-tgp-itm",
attributeAsString(component, "styleClass"));
}
@Override
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -60,7 +60,7 @@
@ResourceDependency(library = "org.richfaces", name =
"TogglePanel.js") })
public class TogglePanelRenderer extends DivPanelRenderer {
- private static final String VALUE_POSTFIX = "-value";
+ public static final String VALUE_POSTFIX = "-value";
private static final String ON = "on";
private static final String ITEM_CHANGE = "itemchange";
@@ -74,7 +74,7 @@
context.getExternalContext().getRequestParameterMap();
// Don't overwrite the value unless you have to!
- String newValue = requestMap.get(getActiveItemRequestParamName(context,
component));
+ String newValue = requestMap.get(getValueRequestParamName(context, component));
if (newValue != null) {
panel.setSubmittedActiveItem(newValue);
}
@@ -92,7 +92,7 @@
}
}
- private static void addOnCompleteParam(String newValue, String panelId) {
+ protected static void addOnCompleteParam(String newValue, String panelId) {
StringBuilder onComplete = new StringBuilder();
onComplete.append("RichFaces.$('").append(panelId)
.append("').onCompleteHandler('").append(newValue).append("');");
@@ -100,7 +100,7 @@
AjaxContext.getCurrentInstance().appendOncomplete(onComplete.toString());
}
- private static String getActiveItemRequestParamName(FacesContext context, UIComponent
component) {
+ public static String getValueRequestParamName(FacesContext context, UIComponent
component) {
return component.getClientId(context) + VALUE_POSTFIX;
}
@@ -111,12 +111,12 @@
super.doEncodeBegin(writer, context, comp);
AbstractTogglePanel panel = (AbstractTogglePanel) comp;
- writer.startElement(HtmlConstants.INPUT_ELEM, comp);
- writer.writeAttribute(HtmlConstants.TYPE_ATTR, HtmlConstants.INPUT_TYPE_HIDDEN,
null);
- writer.writeAttribute(HtmlConstants.VALUE_ATTRIBUTE, panel.getActiveItem(),
"activeItem");
- writer.writeAttribute(HtmlConstants.ID_ATTRIBUTE,
getActiveItemRequestParamName(context, comp), null);
- writer.writeAttribute(HtmlConstants.NAME_ATTRIBUTE,
getActiveItemRequestParamName(context, comp), null);
- writer.endElement(HtmlConstants.INPUT_ELEM);
+ writer.startElement(HTML.INPUT_ELEM, comp);
+ writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
+ writer.writeAttribute(HTML.VALUE_ATTRIBUTE, panel.getActiveItem(),
"activeItem");
+ writer.writeAttribute(HTML.ID_ATTRIBUTE, getValueRequestParamName(context, comp),
null);
+ writer.writeAttribute(HTML.NAME_ATTRIBUTE, getValueRequestParamName(context,
comp), null);
+ writer.endElement(HTML.INPUT_ELEM);
}
@Override
@@ -127,7 +127,7 @@
@Override
protected void doEncodeChildren(ResponseWriter writer, FacesContext context,
UIComponent component)
throws IOException {
-
+
renderChildren(context, component);
}
@@ -141,7 +141,7 @@
protected Map<String, Object> getScriptObjectOptions(FacesContext context,
UIComponent component) {
AbstractTogglePanel panel = (AbstractTogglePanel) component;
- Map<String, Object> options = new HashMap<String, Object>(5);
+ Map<String, Object> options = new HashMap<String, Object>();
options.put("activeItem", panel.getActiveItem());
options.put("cycledSwitching", panel.isCycledSwitching());
options.put("items", getChildrenScriptObjects(context, panel));
@@ -155,11 +155,11 @@
public static void addEventOption(FacesContext context, UIComponent component,
Map<String, Object> options,
String eventName) {
-
+
HandlersChain handlersChain = new HandlersChain(context, component);
handlersChain.addInlineHandlerFromAttribute(ON + eventName);
handlersChain.addBehaviors(eventName);
- handlersChain.addAjaxSubmitFunction();
+// handlersChain.addAjaxSubmitFunction();
String handler = handlersChain.toScript();
if (handler != null) {
@@ -168,11 +168,11 @@
}
}
- private static AjaxEventOptions getAjaxOptions(FacesContext context, UIComponent
panel) {
+ public static AjaxEventOptions getAjaxOptions(FacesContext context, UIComponent
panel) {
return AjaxRendererUtils.buildEventOptions(context, panel);
}
- private List<JSObject> getChildrenScriptObjects(FacesContext context,
UIComponent component) {
+ protected List<JSObject> getChildrenScriptObjects(FacesContext context,
UIComponent component) {
List<JSObject> res = new
ArrayList<JSObject>(component.getChildCount());
for (UIComponent child : component.getChildren()) {
res.add(getChildScriptObject(context, (AbstractTogglePanelItem) child));
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ChangeExpandListenerHandler.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.view.facelets.html;
+
+import org.richfaces.event.ChangeExpandEvent;
+import org.richfaces.event.ChangeExpandListener;
+import org.richfaces.event.ChangeExpandSource;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.TagConfig;
+
+/**
+ *
+ * @author akolonitsky
+ * @version 1.0
+ */
+public final class ChangeExpandListenerHandler extends EventListenerHandler {
+
+ private static class LazyChangeExpandListener extends
LazyEventListener<ChangeExpandListener> implements ChangeExpandListener {
+ private static final long serialVersionUID = -391020876192823200L;
+
+ LazyChangeExpandListener(String type, ValueExpression binding) {
+ super(type, binding);
+ }
+
+ public void processChangeExpand(ChangeExpandEvent event) throws
AbortProcessingException {
+ processEvent(event);
+ }
+ }
+
+ public ChangeExpandListenerHandler(TagConfig config) {
+ super(config);
+ }
+
+ public void applyAttachedObject(FacesContext context, UIComponent parent) {
+ ValueExpression expression = null;
+ if (this.binding != null) {
+ FaceletContext ctx = (FaceletContext)
context.getAttributes().get(FaceletContext.FACELET_CONTEXT_KEY);
+ expression = this.binding.getValueExpression(ctx,
ChangeExpandListener.class);
+ }
+
+ ChangeExpandSource source = (ChangeExpandSource) parent;
+ source.addChangeExpandListener(new LazyChangeExpandListener(this.listenerType,
expression));
+ }
+
+ @Override
+ public boolean isEventSource(UIComponent comp) {
+ return comp instanceof ChangeExpandSource;
+ }
+}
+
Copied:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java
(from rev 19108,
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/CollapsiblePanelTagHandler.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,92 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.view.facelets.html;
+
+import org.richfaces.component.AbstractCollapsiblePanel;
+
+import org.richfaces.event.MethodExpressionChangeExpandListener;
+import org.richfaces.event.ChangeExpandEvent;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRule;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.Metadata;
+import javax.faces.view.facelets.MetadataTarget;
+import javax.faces.view.facelets.TagAttribute;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-27
+ */
+public class CollapsiblePanelTagHandler extends ComponentHandler {
+
+ private static final MetaRule META_RULE = new CollapsiblePanelMetaRule();
+
+
+ public CollapsiblePanelTagHandler(ComponentConfig config) {
+ super(config);
+ }
+
+ @Override
+ protected MetaRuleset createMetaRuleset(Class type) {
+ MetaRuleset metaRuleset = super.createMetaRuleset(type);
+ metaRuleset.addRule(META_RULE);
+ return metaRuleset;
+ }
+
+ private static class CollapsiblePanelMetaRule extends MetaRule{
+
+ @Override
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget
meta) {
+ if (meta.isTargetInstanceOf(AbstractCollapsiblePanel.class)) {
+ if ("changeExpandListener".equals(name)) {
+ return new ChangeExpandExpressionMetadata(attribute);
+ }
+
+ }
+ return null;
+ }
+ }
+
+ private static final class ChangeExpandExpressionMetadata extends Metadata {
+ private static final Class<?>[] CHANGE_EXPAND_SIG = new Class[]
{ChangeExpandEvent.class };
+
+ private final TagAttribute attr;
+
+ ChangeExpandExpressionMetadata(TagAttribute attr) {
+ this.attr = attr;
+ }
+
+ @Override
+ public void applyMetadata(FaceletContext ctx, Object instance) {
+ ((AbstractCollapsiblePanel) instance).addChangeExpandListener(new
MethodExpressionChangeExpandListener(
+ this.attr.getMethodExpression(ctx, null,
CHANGE_EXPAND_SIG)));
+ }
+ }
+
+
+
+}
+
Modified:
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -22,7 +22,6 @@
package org.richfaces.view.facelets.html;
-import org.richfaces.component.AbstractTogglePanel;
import org.richfaces.event.ItemChangeEvent;
import org.richfaces.event.ItemChangeListener;
import org.richfaces.event.ItemChangeSource;
@@ -31,14 +30,8 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
-import javax.faces.view.EditableValueHolderAttachedObjectHandler;
-import javax.faces.view.facelets.ComponentHandler;
import javax.faces.view.facelets.FaceletContext;
-import javax.faces.view.facelets.TagAttribute;
-import javax.faces.view.facelets.TagAttributeException;
import javax.faces.view.facelets.TagConfig;
-import javax.faces.view.facelets.TagException;
-import javax.faces.view.facelets.TagHandler;
import java.io.Serializable;
/**
@@ -46,90 +39,24 @@
* @author akolonitsky
* @version 1.0
*/
-public final class ItemChangeListenerHandler extends TagHandler implements
EditableValueHolderAttachedObjectHandler {
+public final class ItemChangeListenerHandler extends EventListenerHandler {
- private static class LazyItemChangeListener implements ItemChangeListener,
Serializable {
+ private static class LazyItemChangeListener extends
LazyEventListener<ItemChangeListener> implements ItemChangeListener, Serializable {
+ private static final long serialVersionUID = 7715606467989165179L;
- private static final long serialVersionUID = 1L;
-
- private final String type;
-
- private final ValueExpression binding;
-
LazyItemChangeListener(String type, ValueExpression binding) {
- this.type = type;
- this.binding = binding;
+ super(type, binding);
}
- public void processItemChange(ItemChangeEvent event)
- throws AbortProcessingException {
-
- FacesContext faces = FacesContext.getCurrentInstance();
- if (faces == null) {
- return;
- }
-
- ItemChangeListener instance = null;
- if (this.binding != null) {
- instance = (ItemChangeListener) binding.getValue(faces.getELContext());
- }
- if (instance == null && this.type != null) {
- try {
- instance = (ItemChangeListener) forName(this.type).newInstance();
- } catch (Exception e) {
- throw new AbortProcessingException("Couldn't Lazily
instantiate ItemChangeListener", e);
- }
- if (this.binding != null) {
- binding.setValue(faces.getELContext(), instance);
- }
- }
- if (instance != null) {
- instance.processItemChange(event);
- }
+ public void processItemChange(ItemChangeEvent event) throws
AbortProcessingException {
+ processEvent(event);
}
}
- private final TagAttribute binding;
-
- private final String listenerType;
-
public ItemChangeListenerHandler(TagConfig config) {
super(config);
- this.binding = this.getAttribute("binding");
- TagAttribute type = this.getAttribute("type");
- if (type != null) {
- if (type.isLiteral()) {
- try {
- forName(type.getValue());
- } catch (ClassNotFoundException e) {
- throw new TagAttributeException(type, "Couldn't qualify
ItemChangeListener", e);
- }
- } else {
- throw new TagAttributeException(type, "Must be a literal class name
of type ItemChangeListener");
- }
- this.listenerType = type.getValue();
- } else {
- this.listenerType = null;
- }
}
- public void apply(FaceletContext ctx, UIComponent parent) {
-
- // only process if it's been created
- if (parent == null || !ComponentHandler.isNew(parent)) {
- return;
- }
-
- if (parent instanceof AbstractTogglePanel) {
- applyAttachedObject(ctx.getFacesContext(), parent);
- } else if (UIComponent.isCompositeComponent(parent)) {
- // Allow the composite component to know about the target component.
- TagHandlerUtils.getOrCreateRetargetableHandlersList(parent).add(this);
- } else {
- throw new TagException(this.tag, "Parent is not of type
AbstractTogglePanel, type is: " + parent);
- }
- }
-
public void applyAttachedObject(FacesContext context, UIComponent parent) {
ValueExpression valueExpr = null;
if (this.binding != null) {
@@ -141,17 +68,9 @@
evh.addItemChangeListener(new LazyItemChangeListener(this.listenerType,
valueExpr));
}
- public String getFor() {
- TagAttribute attr = this.getAttribute("for");
- return attr == null ? null : attr.getValue();
+ @Override
+ public boolean isEventSource(UIComponent comp) {
+ return comp instanceof ItemChangeSource;
}
-
- public static Class<?> forName(String name) throws ClassNotFoundException {
- if (null == name || "".equals(name)) {
- return null;
- }
-
- return Class.forName(name, false,
Thread.currentThread().getContextClassLoader());
- }
}
Modified: branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -11,6 +11,61 @@
</behavior>
<component>
+ <component-type>org.richfaces.CollapsiblePanel</component-type>
+
<component-class>org.richfaces.component.html.HtmlCollapsiblePanel</component-class>
+ <property>
+ <description></description>
+ <property-name>switchType</property-name>
+
<property-class>org.richfaces.component.SwitchType</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>expanded</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>header</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>bypassUpdates</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>limitToList</property-name>
+ <property-class>boolean</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>data</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>status</property-name>
+ <property-class>java.lang.String</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>execute</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>render</property-name>
+ <property-class>java.lang.Object</property-class>
+ </property>
+ <property>
+ <description></description>
+ <property-name>changeExpandListener</property-name>
+ <property-class>javax.el.MethodExpression</property-class>
+ </property>
+
+ </component>
+ <component>
<component-type>org.richfaces.TogglePanel</component-type>
<component-class>org.richfaces.component.html.HtmlTogglePanel</component-class>
<property>
@@ -604,6 +659,11 @@
<render-kit>
<render-kit-id>HTML_BASIC</render-kit-id>
<renderer>
+
<component-family>org.richfaces.CollapsiblePanel</component-family>
+ <renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
+
<renderer-class>org.richfaces.renderkit.html.CollapsiblePanelRenderer</renderer-class>
+ </renderer>
+ <renderer>
<component-family>org.richfaces.TogglePanel</component-family>
<renderer-type>org.richfaces.TogglePanel</renderer-type>
<renderer-class>org.richfaces.renderkit.html.TogglePanelRenderer</renderer-class>
Modified: branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-09-03
17:34:35 UTC (rev 19119)
+++ branches/RF-7560/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml 2010-09-03
18:18:05 UTC (rev 19120)
@@ -29,6 +29,217 @@
</tag>
<tag>
+ <tag-name>collapsiblePanel</tag-name>
+ <component>
+ <component-type>org.richfaces.CollapsiblePanel</component-type>
+ <renderer-type>org.richfaces.CollapsiblePanel</renderer-type>
+
<handler-class>org.richfaces.view.facelets.html.CollapsiblePanelTagHandler</handler-class>
+ </component>
+ <attribute>
+ <description></description>
+ <name>switchType</name>
+ <type>org.richfaces.component.SwitchType</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>expanded</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>header</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>bypassUpdates</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>limitToList</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>data</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>status</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>execute</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>render</name>
+ <type>java.lang.Object</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>id</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>binding</name>
+ <type>javax.faces.component.UIComponent</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>rendered</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>immediate</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>changeExpandListener</name>
+ <type>javax.el.MethodExpression</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>bodyClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>headerClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>headerControlClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>oncomplete</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onbeforedomupdate</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onswitch</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onbeforeswitch</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>lang</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>title</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>style</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>styleClass</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>dir</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onclick</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>ondblclick</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmousedown</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmousemove</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseout</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseover</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>onmouseup</name>
+ <type>java.lang.String</type>
+ </attribute>
+
+ </tag>
+ <tag>
+ <description>
+ Register a ChangeExpandListener instance on the UIComponent
+ associated with the closest parent UIComponent custom
+ action.
+ </description>
+ <tag-name>changeExpandListener</tag-name>
+
<handler-class>org.richfaces.view.facelets.html.ChangeExpandListenerHandler</handler-class>
+ <attribute>
+ <description>
+ Fully qualified Java class name of a
+ ChangeExpandListener to be created and registered.
+ </description>
+ <name>type</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description>
+ Value binding expression that evaluates to an object that
+ implements org.richfaces.event.ChangeExpandListener.
+ </description>
+ <name>binding</name>
+ <required>false</required>
+ <type>org.richfaces.event.ChangeExpandListener</type>
+ </attribute>
+ <attribute>
+ <description>
+ <p class="changed_added_2_0">If present, this
attribute refers
+ to the value of one of the exposed attached objects within the
+ composite component inside of which this tag is
nested.</p>
+ </description>
+ <name>for</name>
+ <required>false</required>
+ <type>java.lang.String</type>
+ </attribute>
+ </tag>
+
+ <tag>
<tag-name>togglePanel</tag-name>
<component>
<component-type>org.richfaces.TogglePanel</component-type>
@@ -37,6 +248,11 @@
</component>
<attribute>
<description></description>
+ <name>cycledSwitching</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>switchType</name>
<type>org.richfaces.component.SwitchType</type>
</attribute>
@@ -57,11 +273,6 @@
</attribute>
<attribute>
<description></description>
- <name>cycledSwitching</name>
- <type>boolean</type>
- </attribute>
- <attribute>
- <description></description>
<name>data</name>
<type>java.lang.Object</type>
</attribute>
@@ -219,7 +430,7 @@
<component>
<component-type>org.richfaces.TogglePanelItem</component-type>
<renderer-type>org.richfaces.TogglePanelItem</renderer-type>
-
+
</component>
<attribute>
<description></description>
@@ -324,10 +535,15 @@
<component>
<component-type>org.richfaces.Accordion</component-type>
<renderer-type>org.richfaces.Accordion</renderer-type>
-
+
</component>
<attribute>
<description></description>
+ <name>cycledSwitching</name>
+ <type>boolean</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>switchType</name>
<type>org.richfaces.component.SwitchType</type>
</attribute>
@@ -338,16 +554,6 @@
</attribute>
<attribute>
<description></description>
- <name>height</name>
- <type>java.lang.String</type>
- </attribute>
- <attribute>
- <description></description>
- <name>width</name>
- <type>java.lang.String</type>
- </attribute>
- <attribute>
- <description></description>
<name>bypassUpdates</name>
<type>boolean</type>
</attribute>
@@ -358,11 +564,6 @@
</attribute>
<attribute>
<description></description>
- <name>cycledSwitching</name>
- <type>boolean</type>
- </attribute>
- <attribute>
- <description></description>
<name>data</name>
<type>java.lang.Object</type>
</attribute>
@@ -408,6 +609,16 @@
</attribute>
<attribute>
<description></description>
+ <name>width</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
+ <name>height</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <description></description>
<name>itemHeaderClassActive</name>
<type>java.lang.String</type>
</attribute>
@@ -509,7 +720,7 @@
<component>
<component-type>org.richfaces.TogglePanelTitledItem</component-type>
<renderer-type>org.richfaces.AccordionItem</renderer-type>
-
+
</component>
<attribute>
<description></description>
@@ -673,8 +884,4 @@
</attribute>
</tag>
-
-
-
-
</facelet-taglib>
Modified:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -41,7 +41,16 @@
this.index = options["index"];
this.getTogglePanel().getItems()[this.index] = this;
- rf.Event.bindById(this.id + ":header", "click",
this.__onHeaderClick, this)
+ if (!this.disabled) {
+ rf.Event.bindById(this.id + ":header", "click",
this.__onHeaderClick, this);
+ }
+
+ if (this.isSelected()) {
+ var item = this;
+ $(this.togglePanelId).ready(function () {
+ item.__fitToHeight(item.getTogglePanel());
+ });
+ }
},
/***************************** Public Methods
****************************************************************/
@@ -59,7 +68,7 @@
__header : function (state) {
var res = $(rf.getDomElement(this.id + ":header"));
if (state) {
- return res.find(".rf-aci-h-" + state);
+ return res.find(".rf-ac-itm-hdr-" + state);
}
return res;
@@ -83,24 +92,28 @@
__enter : function () {
var parentPanel = this.getTogglePanel();
if (parentPanel.isKeepHeight) {
- this.__content().hide();
- var h = parentPanel.getInnerHeight();
-
- var items = parentPanel.getItems();
- for (var i = 0; i < items.length; i++) {
- h -= items[i].__header().outerHeight();
- }
-
- this.__content().height(h - 20); // 20 it is padding top and bottom
+ this.__content().hide(); // TODO ?
+ this.__fitToHeight(parentPanel);
}
this.__content().show();
- this.__header("inactive").hide();
- this.__header("active").show();
+ this.__header("inact").hide();
+ this.__header("act").show();
return this.__fireEnter();
},
+ __fitToHeight : function (parentPanel) {
+ var h = parentPanel.getInnerHeight();
+
+ var items = parentPanel.getItems();
+ for (var i in items) {
+ h -= items[i].__header().outerHeight();
+ }
+
+ this.__content().height(h - 20); // 20 it is padding top and bottom
+ },
+
getHeight : function (recalculate) {
if (recalculate || !this.__height) {
this.__height = $(rf.getDomElement(this.id)).outerHeight(true)
@@ -121,8 +134,8 @@
}
this.__content().hide();
- this.__header("active").hide();
- this.__header("inactive").show();
+ this.__header("act").hide();
+ this.__header("inact").show();
return true;
},
Copied:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js
(from rev 19108,
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanel.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,87 @@
+/*
+ * 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.
+ */
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.CollapsiblePanel = rf.ui.TogglePanel.extendClass({
+
+ name:"CollapsiblePanel",
+
+ /**
+ * @class CollapsiblePanel
+ * @name CollapsiblePanel
+ *
+ * @constructor
+ * @param {String} componentId - component id
+ * @param {Hash} options - params
+ * */
+ init : function (componentId, options) {
+ rf.ui.TogglePanel.call(this, componentId, options);
+ this.switchMode = options.switchMode;
+
+ this.__addUserEventHandler("beforeswitch");
+ this.__addUserEventHandler("switch");
+
+ this.items = [
+ new RichFaces.ui.CollapsiblePanelItem(
+ this.id + ":content", {"index":0,
"togglePanelId":this.id, "switchMode":this.switchMode,
"name":"true"}),
+
+ new RichFaces.ui.CollapsiblePanelItem(
+ this.id + ":empty", {"index":1,
"togglePanelId":this.id, "switchMode":this.switchMode,
"name":"false"})
+ ];
+ this.options.cycledSwitching = true;
+
+ rf.Event.bindById(this.id + ":header", "click",
this.__onHeaderClick, this)
+ },
+
+ switchPanel : function (to) {
+ this.switchToItem(to || "@next");
+ },
+
+ /***************************** Private Methods
********************************************************/
+
+ __onHeaderClick : function () {
+ this.switchToItem("@next");
+ },
+
+ __fireItemChange : function (oldItem, newItem) {
+ return new rf.Event.fireById(this.id, "switch", {
+ id: this.id,
+ isExpanded : newItem.getName()
+ });
+ },
+
+ __fireBeforeItemChange : function (oldItem, newItem) {
+ return rf.Event.fireById(this.id, "beforeswitch", {
+ id: this.id,
+ isExpanded : newItem.getName()
+ });
+ },
+
+
+ destroy: function () {
+ rf.ui.TogglePanel.destroy.call(this);
+ }
+ });
+})(jQuery, RichFaces);
Copied:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js
(from rev 19108,
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/CollapsiblePanelItem.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+(function ($, rf) {
+
+ rf.ui = rf.ui || {};
+
+ rf.ui.CollapsiblePanelItem = rf.ui.TogglePanelItem.extendClass({
+
+ init : function (componentId, options) {
+ rf.ui.TogglePanelItem.call(this, componentId, options);
+ },
+
+ __enter : function () {
+ rf.getDomElement(this.id).style.display = "block";
+ this.__header(this.__state()).show();
+
+ return true;
+ },
+
+ __leave : function () {
+ rf.getDomElement(this.id).style.display = "none";
+ this.__header(this.__state()).hide();
+
+ return true;
+ },
+
+ __state : function () {
+ return this.getName() === "true" ? "expanded" :
"collapsed";
+ },
+
+ __header : function (state) {
+ var res = $(rf.getDomElement(this.togglePanelId + ":header"));
+ if (state) {
+ return res.find(".rf-cp-hdr-" + state);
+ }
+
+ return res;
+ }
+ });
+})(jQuery, RichFaces);
Modified:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -66,7 +66,7 @@
this.__setActiveItem(newPanel.getName());
- rf.submitForm(this.__getParentForm(), null, {});
+ rf.submitForm(this.__getParentForm());
return false;
},
@@ -111,7 +111,7 @@
this.__setActiveItem(newPanel.getName());
newPanel.__enter();
- this.__fireItemChange(oldPanel, newPanel);
+ this.comp.__fireItemChange(oldPanel, newPanel);
return true;
},
@@ -136,16 +136,6 @@
* */
__getValueInputId: function () {
return this.comp.id + "-value"
- },
-
- /********************* Events *************************/
-
- __fireItemChange : function (oldItem, newItem) {
- return new rf.Event.fireById(this.comp.id, "itemchange", {
- id: this.comp.id,
- oldItem : oldItem,
- newItem : newItem
- });
}
};
@@ -163,19 +153,22 @@
name:"TogglePanel",
init : function (componentId, options) {
- // call constructor of parent class
rf.BaseComponent.call(this, componentId);
this.attachToDom(componentId);
this.options = options;
this.activeItem = this.options.activeItem;
this.items = this.options.items;
+
+ this.__addUserEventHandler("itemchange");
+ this.__addUserEventHandler("beforeitemchange");
},
- /***************************** Public Methods
********************************************************************/
+ /***************************** Public Methods
****************************************************************/
/**
* @methodOf
+ *
* @name TogglePanel#getSelectItem
*
* @return {String} name of current selected panel item
@@ -326,20 +319,42 @@
/********************* Methods *************************/
- __ITEMS_META_NAMES : {
- "@first" : function (comp) { return 0; },
- "@prev" : function (comp) { return
comp.__getItemIndex(comp.activeItem) - 1; },
- "@next" : function (comp) { return
comp.__getItemIndex(comp.activeItem) + 1; },
- "@last" : function (comp) { return comp.items.length - 1; }
- },
+ __ITEMS_META_NAMES : (function () {
+ function goFrom (comp, ind, step) {
+ var res = ind;
+ while ((!comp.items[res] || comp.items[res].disabled) && res <
comp.items.length && res > 0) {
+ res += step;
+ }
+ return res;
+ }
+
+ return {
+ "@first" : function (comp) {
+ return goFrom(comp, 0, 1);
+ },
+
+ "@prev" : function (comp) {
+ return goFrom(comp, parseInt(comp.__getItemIndex(comp.activeItem)) -
1 , -1);
+ },
+
+ "@next" : function (comp) {
+ return goFrom(comp, parseInt(comp.__getItemIndex(comp.activeItem)) +
1 , 1);
+ },
+
+ "@last" : function (comp) {
+ return goFrom(comp, comp.items.length - 1, -1);
+ }
+ }
+ })(),
+
/**
* @private
* */
__getItemIndex : function (itemName) {
- for (var i = 0; i < this.items.length; i++) {
- if (this.items[i].getName() === itemName) {
- return i;
+ for (var i in this.items) {
+ if (!this.items[i].disabled && this.items[i].getName() ===
itemName) {
+ return parseInt(i);
}
}
@@ -349,6 +364,16 @@
/**
* @private
+ * */
+ __addUserEventHandler : function (name) {
+ var handler = this.options["on" + name];
+ if (handler) {
+ rf.Event.bindById(this.id, name, handler);
+ }
+ },
+
+ /**
+ * @private
* @param {Number} index - array index
*
* @return {TogglePanelItem}
@@ -381,6 +406,15 @@
/**
* Fire Concealable Event
* */
+
+ __fireItemChange : function (oldItem, newItem) {
+ return new rf.Event.fireById(this.id, "itemchange", {
+ id: this.id,
+ oldItem : oldItem,
+ newItem : newItem
+ });
+ },
+
__fireBeforeItemChange : function (oldItem, newItem) {
return rf.Event.fireById(this.id, "beforeitemchange", {
id: this.id,
@@ -389,11 +423,8 @@
});
},
- // class stuff
destroy: function () {
- // rf.Event.unbindById(this.options.buttonId,
"."+this.namespace);
- // rf.Event.unbindById(this.componentId,
"."+this.namespace);
- // $super.destroy.call(this);
+ rf.BaseComponent.destroy.call(this);
}
});
})(jQuery, RichFaces);
Modified:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanelItem.js
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanelItem.js 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanelItem.js 2010-09-03
18:18:05 UTC (rev 19120)
@@ -38,6 +38,7 @@
this.name = this.options.name;
this.togglePanelId = this.options.togglePanelId;
this.switchMode = this.options.switchMode;
+ this.disabled = this.options.disabled || false;
},
/***************************** Public Methods
*****************************************************************/
Modified:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss 2010-09-03
17:34:35 UTC (rev 19119)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss 2010-09-03
18:18:05 UTC (rev 19120)
@@ -1,5 +1,4 @@
.rf-ac {
- /*width: 300px;*/ /*visible width*/
border-width: 1px;
border-style: solid;
border-color: '#{richSkin.panelBorderColor}';
@@ -7,7 +6,7 @@
background: '#{richSkin.generalBackgroundColor}';
}
-.rf-aci-h {
+.rf-ac-itm-hdr {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: '#{richSkin.panelBorderColor}';
@@ -24,13 +23,17 @@
cursor: pointer;
}
-.rf-aci-c {
+.rf-ac-itm-hdr-act {}
+.rf-ac-itm-hdr-inact {}
+.rf-ac-itm-hdr-dis {}
+
+.rf-ac-itm-cnt {
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: '#{richSkin.panelBorderColor}';
- /*height: 100px*/ /*visible modal panel height minus header height*/;
position: relative;
overflow: auto;
overflow-x: hidden;
padding: 10px;
-}
\ No newline at end of file
+}
+
Copied:
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss
(from rev 19108,
trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss)
===================================================================
---
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/collapsiblePanel.ecss 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,32 @@
+.rf-cp{
+ background-color:'#{richSkin.generalBackgroundColor}';
+ color:'#{richSkin.panelBorderColor}';
+ border-width:1px;
+ border-style:solid;
+ padding:1px;
+}
+
+.rf-cp-hdr{
+ background-color:'#{richSkin.headerBackgroundColor}';
+ border-color:'#{richSkin.headerBackgroundColor}';
+ font-size:'#{richSkin.headerSizeFont}';
+ color:'#{richSkin.headerTextColor}';
+ font-weight:'#{richSkin.headerWeightFont}';
+ font-family:'#{richSkin.headerFamilyFont}';
+ padding:2px;
+ border-width:1px;
+ border-style:solid;
+ background-position:top left;
+ background-repeat:repeat-x;
+ background-image:"url(#{resource['org.richfaces.renderkit.html.GradientA']})";
+}
+
+.rf-cp-hdr-exp {}
+.rf-cp-hdr-colps {}
+
+.rf-cp-b{
+ font-size:'#{richSkin.generalSizeFont}';
+ color:'#{richSkin.generalTextColor}';
+ font-family:'#{richSkin.generalFamilyFont}';
+ padding:10px;
+}
\ No newline at end of file
Copied:
branches/RF-7560/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java
(from rev 19108,
trunk/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java)
===================================================================
---
branches/RF-7560/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java
(rev 0)
+++
branches/RF-7560/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java 2010-09-03
18:18:05 UTC (rev 19120)
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+package org.richfaces.component;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.faces.component.UIComponent;
+import java.util.List;
+
+/**
+ * @author akolonitsky
+ * @since 2010-08-24
+ */
+public class UITogglePanelItemTest {
+
+ private UITogglePanelItem togglePanelItem;
+
+ @Before
+ public void setUp () {
+ togglePanelItem = new UITogglePanelItem();
+ }
+
+ @Test
+ public void testGetName() {
+ Assert.assertNull(togglePanelItem.getName());
+
+ String id = "id";
+ togglePanelItem.setId(id);
+ Assert.assertEquals(togglePanelItem.getId(), id);
+ Assert.assertEquals(togglePanelItem.getName(), id);
+
+ String name = "name";
+ togglePanelItem.setName(name);
+ Assert.assertEquals(togglePanelItem.getName(), name);
+ }
+}
+