JBoss Rich Faces SVN: r19062 - in branches/autocomplete: examples/input-demo/src/main/webapp and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-09-01 06:02:54 -0400 (Wed, 01 Sep 2010)
New Revision: 19062
Modified:
branches/autocomplete/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java
branches/autocomplete/examples/input-demo/src/main/webapp/autocomplete.xhtml
branches/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
branches/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
Log:
https://jira.jboss.org/browse/RF-8875
modes implementation && bug fixes
Modified: branches/autocomplete/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java
===================================================================
--- branches/autocomplete/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java 2010-09-01 10:00:55 UTC (rev 19061)
+++ branches/autocomplete/examples/input-demo/src/main/java/org/richfaces/demo/AutoCompleteBean.java 2010-09-01 10:02:54 UTC (rev 19062)
@@ -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/autocomplete/examples/input-demo/src/main/webapp/autocomplete.xhtml
===================================================================
--- branches/autocomplete/examples/input-demo/src/main/webapp/autocomplete.xhtml 2010-09-01 10:00:55 UTC (rev 19061)
+++ branches/autocomplete/examples/input-demo/src/main/webapp/autocomplete.xhtml 2010-09-01 10:02:54 UTC (rev 19062)
@@ -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 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/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js
===================================================================
--- branches/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-09-01 10:00:55 UTC (rev 19061)
+++ branches/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/Autocomplete.js 2010-09-01 10:02:54 UTC (rev 19062)
@@ -1,14 +1,21 @@
(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.values = processValues(typeof values != "function" ? values || this.cache[this.key] : values(items));
+ this.useCache = useCache || checkValuesPrefix.call(this);
};
+ var processValues = function (values) {
+ for (var i = 0; i<values.length; i++) {
+ values[i] = values[i].toLowerCase();
+ }
+ return values;
+ }
+
var checkValuesPrefix = function () {
var result = true;
for (var i = 0; i<this.values.length; i++) {
@@ -33,7 +40,7 @@
} else {
var itemsCache = this.cache[this.key];
for (var i = 0; i<this.values.length; i++) {
- var value = this.values[i].toLowerCase();
+ var value = this.values[i];
var p = value.indexOf(key);
if (p == 0) {
newCache.push(itemsCache[i]);
@@ -107,6 +114,7 @@
minChars:1,
selectFirst:true,
ajaxMode:true,
+ lazyClientMode:false,
isCachedAjax:true,
tokens: ",",
attachToBody:true
@@ -150,9 +158,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 +170,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 +200,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 +232,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 +246,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 +262,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);
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();
+ window.console && console.log && console.log("updateItemsFromCache");
};
var clearItems = function () {
@@ -264,31 +284,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 +388,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 +408,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 +429,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/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js
===================================================================
--- branches/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js 2010-09-01 10:00:55 UTC (rev 19061)
+++ branches/autocomplete/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/AutocompleteBase.js 2010-09-01 10:02:54 UTC (rev 19062)
@@ -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);
}
}
};
14 years, 2 months
JBoss Rich Faces SVN: r19061 - in branches/autocomplete/ui/input/ui/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-09-01 06:00:55 -0400 (Wed, 01 Sep 2010)
New Revision: 19061
Modified:
branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
branches/autocomplete/ui/input/ui/src/main/templates/autocomplete.template.xml
Log:
https://jira.jboss.org/browse/RF-9180
bug fixes
Modified: branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java
===================================================================
--- branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-09-01 09:00:11 UTC (rev 19060)
+++ branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteRendererBase.java 2010-09-01 10:00:55 UTC (rev 19061)
@@ -79,7 +79,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");
@@ -90,12 +89,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, "isCachedAjax", false, "true");
- } else if (attributes.get("mode").equals("client")) {
- utils.addToScriptHash(options, "ajaxMode", false, "true");
- }
+ String mode = (String)attributes.get("mode");
+ if (mode != null) {
+ if (mode.equals("ajax")){
+ utils.addToScriptHash(options, "isCachedAjax", false, "true");
+ } 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();
builder.append(ScriptUtils.toScript(options));
@@ -218,13 +221,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);
}
}
@@ -251,7 +252,7 @@
writer.writeText(item, null);
}
}
-
+ strategy.encodeItemEnd(facesContext, comboBox);
}
private AutocompleteEncodeStrategy getStrategy(UIComponent component) {
Modified: branches/autocomplete/ui/input/ui/src/main/templates/autocomplete.template.xml
===================================================================
--- branches/autocomplete/ui/input/ui/src/main/templates/autocomplete.template.xml 2010-09-01 09:00:11 UTC (rev 19060)
+++ branches/autocomplete/ui/input/ui/src/main/templates/autocomplete.template.xml 2010-09-01 10:00:55 UTC (rev 19061)
@@ -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">
14 years, 2 months
JBoss Rich Faces SVN: r19060 - trunk/ui/output/ui/src/test/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-09-01 05:00:11 -0400 (Wed, 01 Sep 2010)
New Revision: 19060
Added:
trunk/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java
Log:
Added: trunk/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java (rev 0)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/component/UITogglePanelItemTest.java 2010-09-01 09:00:11 UTC (rev 19060)
@@ -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);
+ }
+}
+
14 years, 2 months
JBoss Rich Faces SVN: r19059 - branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2010-09-01 04:49:24 -0400 (Wed, 01 Sep 2010)
New Revision: 19059
Removed:
branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java
Log:
Deleted: branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java
===================================================================
--- branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java 2010-09-01 08:33:51 UTC (rev 19058)
+++ branches/autocomplete/ui/input/ui/src/main/java/org/richfaces/renderkit/AutocompleteGridLayoutStrategy.java 2010-09-01 08:49:24 UTC (rev 19059)
@@ -1,34 +0,0 @@
-package org.richfaces.renderkit;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.richfaces.component.AbstractAutocomplete;
-
-public class AutocompleteGridLayoutStrategy extends AbstractAutocompleteLayoutStrategy implements
- AutocompleteEncodeStrategy {
-
- public void encodeFakeItem(FacesContext facesContext, UIComponent component) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- public void encodeItemsContainerBegin(FacesContext facesContext, UIComponent component) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- public void encodeItemsContainerEnd(FacesContext facesContext, UIComponent component) throws IOException {
- // TODO Auto-generated method stub
-
- }
-
- public void encodeItem(FacesContext facesContext, AbstractAutocomplete comboBox, Object nextItem)
- throws IOException {
- // TODO Auto-generated method stub
-
- }
-
-}
14 years, 2 months
JBoss Rich Faces SVN: r19058 - in trunk: ui/output/ui/src/main/java/org/richfaces/component and 4 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-09-01 04:33:51 -0400 (Wed, 01 Sep 2010)
New Revision: 19058
Modified:
trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
Log:
Toggle Panel bug fixing and refactoring
add header facet as default for headerActive/Inactive/Disabled in Accordion
id as default for name in togglePanelItem
Modified: trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/examples/output-demo/src/main/webapp/qunit/accordionHeaders.xhtml 2010-09-01 08:33:51 UTC (rev 19058)
@@ -26,17 +26,17 @@
<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
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractCollapsiblePanel.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -37,9 +37,12 @@
public static final String COMPONENT_TYPE = "org.richfaces.CollapsiblePanel";
public static final String COMPONENT_FAMILY = "org.richfaces.CollapsiblePanel";
- private static final String STATE_EXPANDED = "expanded";
- private static final String STATE_COLLAPSED = "collapsed";
+ public enum States {
+ expanded,
+ collapsed
+ }
+
protected AbstractCollapsiblePanel() {
setRendererType("org.richfaces.CollapsiblePanel");
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanel.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -56,6 +56,11 @@
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";
@@ -467,13 +472,13 @@
}
public AbstractTogglePanelItem getItem(String name) {
- if ("@first".equals(name)) {
+ if (META_NAME_FIRST.equals(name)) {
return getFirstItem();
- } else if ("@prev".equals(name)) {
+ } else if (META_NAME_PREV.equals(name)) {
return getPrevItem();
- } else if ("@next".equals(name)) {
+ } else if (META_NAME_NEXT.equals(name)) {
return getNextItem();
- } else if ("@last".equals(name)) {
+ } else if (META_NAME_LAST.equals(name)) {
return getLastItem();
} else {
return getItemByIndex(getChildIndex(name));
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelItem.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -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(RendererUtils.HTML.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: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractTogglePanelTitledItem.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -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,12 @@
public static final String COMPONENT_FAMILY = "org.richfaces.TogglePanelTitledItem";
+ public enum HeaderStates {
+ active,
+ inactive,
+ disable
+ }
+
protected AbstractTogglePanelTitledItem() {
setRendererType("org.richfaces.TogglePanelTitledItem");
}
@@ -71,4 +79,20 @@
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;
+ }
}
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/UITogglePanelItem.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -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: trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/behavior/ToggleControl.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -54,7 +54,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) {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionChangeExpandListener.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -51,7 +51,7 @@
super(methodExprOneArg, methodExprZeroArg);
}
- // ------------------------------------------------------- Event Method
+ // ------------------------------------------------------- Listener Method
public void processChangeExpand(ChangeExpandEvent changeExpandEvent) throws AbortProcessingException {
processEvent(changeExpandEvent);
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/event/MethodExpressionItemChangeListener.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -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: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionItemRenderer.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -34,6 +34,8 @@
import javax.faces.context.ResponseWriter;
import java.io.IOException;
+import static org.richfaces.component.AbstractTogglePanelTitledItem.HeaderStates;
+
/**
*
* <div id="clientId" class="rf-aci">
@@ -50,7 +52,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"),
@@ -118,15 +120,15 @@
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(facesContext, titledItem, responseWriter, HeaderStates.inactive, !isActive && !isDisabled);
+ encodeHeader(facesContext, titledItem, responseWriter, HeaderStates.active, isActive && !isDisabled);
+ encodeHeader(facesContext, titledItem, responseWriter, HeaderStates.disable, isDisabled);
responseWriter.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 +136,11 @@
writer.writeAttribute("style", "display : none", null);
}
- String name = "headerClass" + capitalize(state);
+ String name = "headerClass" + capitalize(state.toString());
writer.writeAttribute("class", "rf-aci-h-" + state + " " + attributeAsString(component, name), name);
- UIComponent headerFacet = component.getFacet("header" + capitalize(state));
+ UIComponent headerFacet = component.getHeaderFacet(state);
if (headerFacet != null && headerFacet.isRendered()) {
headerFacet.encodeAll(facesContext);
} else {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -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"),
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/CollapsiblePanelRenderer.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -25,6 +25,7 @@
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;
@@ -32,9 +33,11 @@
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;
@@ -104,11 +107,13 @@
protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
AbstractTogglePanel panel = (AbstractTogglePanel) component;
- Map<String, Object> options = super.getScriptObjectOptions(context, 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);
+ TogglePanelRenderer.addEventOption(context, panel, options, SWITCH);
+ TogglePanelRenderer.addEventOption(context, panel, options, BEFORE_SWITCH);
return options;
}
@@ -119,18 +124,18 @@
writer.writeAttribute("class", concatClasses("rf-cp-hr", attributeAsString(component, "headerClass")), null);
AbstractCollapsiblePanel panel = (AbstractCollapsiblePanel) component;
- encodeHeader(context, component, writer, "expanded", panel.isExpanded());
- encodeHeader(context, component, writer, "collapsed", !panel.isExpanded());
+ 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, String state, boolean isVisible) throws IOException {
+ 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-hr-" + state, null);
responseWriter.writeAttribute("style", concatStyles(styleElement("display", isVisible ? "" : "none"), attributeAsString(component, "headerClass")), null);
- UIComponent header = component.getFacet("header" + capitalize(state));
+ UIComponent header = AbstractTogglePanelTitledItem.getHeaderFacet(component, state);
if (header != null && header.isRendered()) {
header.encodeAll(context);
} else {
Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -86,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: trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-01 08:15:07 UTC (rev 19057)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/view/facelets/html/ItemChangeListenerHandler.java 2010-09-01 08:33:51 UTC (rev 19058)
@@ -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) {
@@ -140,18 +67,5 @@
ItemChangeSource evh = (ItemChangeSource) parent;
evh.addItemChangeListener(new LazyItemChangeListener(this.listenerType, valueExpr));
}
-
- public String getFor() {
- TagAttribute attr = this.getAttribute("for");
- return attr == null ? null : attr.getValue();
- }
-
- public static Class<?> forName(String name) throws ClassNotFoundException {
- if (null == name || "".equals(name)) {
- return null;
- }
-
- return Class.forName(name, false, Thread.currentThread().getContextClassLoader());
- }
}
14 years, 2 months
JBoss Rich Faces SVN: r19056 - modules/tests/metamer/trunk/ftest.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-09-01 04:12:10 -0400 (Wed, 01 Sep 2010)
New Revision: 19056
Modified:
modules/tests/metamer/trunk/ftest/pom.xml
Log:
ftest supports metamer classifiers jee6, mojarra (default) and myfaces (RFPL-714, RFPL-774)
Modified: modules/tests/metamer/trunk/ftest/pom.xml
===================================================================
--- modules/tests/metamer/trunk/ftest/pom.xml 2010-09-01 08:11:47 UTC (rev 19055)
+++ modules/tests/metamer/trunk/ftest/pom.xml 2010-09-01 08:12:10 UTC (rev 19056)
@@ -79,6 +79,7 @@
<properties>
<context.path>/metamer/</context.path>
+ <deployable.classifier>mojarra</deployable.classifier>
<deployable.version>4.0.0-SNAPSHOT</deployable.version>
<ftest.source.version>4.0.0-SNAPSHOT</ftest.source.version>
<testng.suite.xml>src/test/resources/testng.xml</testng.suite.xml>
@@ -95,6 +96,7 @@
<dependency>
<groupId>org.richfaces.tests</groupId>
<artifactId>metamer</artifactId>
+ <classifier>${deployable.classifier}</classifier>
<type>${deployable.type}</type>
<version>${deployable.version}</version>
</dependency>
@@ -136,6 +138,7 @@
<groupId>org.richfaces.tests</groupId>
<artifactId>metamer</artifactId>
<type>${deployable.type}</type>
+ <classifier>${deployable.classifier}</classifier>
<properties>
<context>${context.deploy.path}</context>
</properties>
14 years, 2 months
JBoss Rich Faces SVN: r19055 - in modules/tests/metamer/trunk: application and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: lfryc(a)redhat.com
Date: 2010-09-01 04:11:47 -0400 (Wed, 01 Sep 2010)
New Revision: 19055
Modified:
modules/tests/metamer/trunk/application/pom.xml
modules/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml
modules/tests/metamer/trunk/build.sh
modules/tests/metamer/trunk/pom.xml
Log:
configured project to deploy metamer application in 3 profiles - jee6, mojarra and myfaces (RFPL-714, RFPL-774)
Modified: modules/tests/metamer/trunk/application/pom.xml
===================================================================
--- modules/tests/metamer/trunk/application/pom.xml 2010-08-31 18:46:44 UTC (rev 19054)
+++ modules/tests/metamer/trunk/application/pom.xml 2010-09-01 08:11:47 UTC (rev 19055)
@@ -119,12 +119,78 @@
</configuration>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
- <attachClasses>true</attachClasses>
+ <classifier>jee6</classifier>
+ <packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*,WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*</packagingExcludes>
+ <archive>
+ <manifest>
+ <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+ <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
+ </manifest>
+ <manifestEntries>
+ <SCM-Revision>${buildNumber}</SCM-Revision>
+ <SCM-Timestamp>${timestamp}</SCM-Timestamp>
+ </manifestEntries>
+ </archive>
</configuration>
+ <executions>
+ <execution>
+ <id>sources-classes</id>
+ <phase>package</phase>
+ <goals>
+ <goal>war</goal>
+ </goals>
+ <configuration>
+ <attachClasses>true</attachClasses>
+ <attachSources>true</attachSources>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<plugin>
+ <groupId>com.google.code.maven-replacer-plugin</groupId>
+ <artifactId>maven-replacer-plugin</artifactId>
+ <version>1.3.2</version>
+ <executions>
+ <execution>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>replace</goal>
+ </goals>
+ <configuration>
+ <file>target/${project.build.finalName}/WEB-INF/web.xml</file>
+ <regex>true</regex>
+ <regexFlags>
+ <regexFlag>MULTILINE</regexFlag>
+ </regexFlags>
+ <token><param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>\s*<param-value>false</param-value></token>
+ <value><param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name><param-value>true</param-value></value>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>initialize</phase>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ <configuration>
+ <fileset>
+ <directory>target/${project.build.finalName}/WEB-INF</directory>
+ <includes>
+ <include>web.xml</include>
+ </includes>
+ </fileset>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
@@ -155,121 +221,47 @@
<timestampFormat>{0,date,MMM dd, yyyy H:mm:ss zzz}</timestampFormat>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <attachClasses>true</attachClasses>
- <archive>
- <manifest>
- <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
- <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
- </manifest>
- <manifestEntries>
- <SCM-Revision>${buildNumber}</SCM-Revision>
- <SCM-Timestamp>${timestamp}</SCM-Timestamp>
- </manifestEntries>
- </archive>
- </configuration>
- </plugin>
</plugins>
</build>
<profiles>
- <profile>
- <id>release</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <executions>
- <execution>
- <id>jee6</id>
- <phase>package</phase>
- <goals>
- <goal>war</goal>
- </goals>
- <configuration>
- <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6</webappDirectory>
- <classifier>jee6</classifier>
- <packagingExcludes>WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/jta-*</packagingExcludes>
- <warSourceExcludes>WEB-INF/lib/jsf-api*,WEB-INF/lib/jsf-impl*,WEB-INF/lib/jta-*</warSourceExcludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>group-sources</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <finalName>sources</finalName>
- <descriptor>assembler.xml</descriptor>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>jar</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <classesDirectory>${basedir}/target/sources/sources</classesDirectory>
- <classifier>sources</classifier>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>jee6</id>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webappDirectory>${project.build.directory}/${project.build.finalName}-jee6
- </webappDirectory>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
+ <profile>
+ <id>mojarra</id>
+ <activation>
+ <property>
+ <name>!jsf_profile</name>
+ </property>
+ </activation>
<dependencies>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
- <scope>provided</scope>
</dependency>
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <scope>provided</scope>
- </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-war-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>myfaces</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>war</goal>
+ </goals>
+ <configuration>
+ <classifier>mojarra</classifier>
+ <packagingExcludes>WEB-INF/lib/myfaces-api-*,WEB-INF/lib/myfaces-impl-*</packagingExcludes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</profile>
<profile>
<id>myfaces</id>
@@ -279,30 +271,36 @@
<value>myfaces</value>
</property>
</activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.myfaces.core</groupId>
+ <artifactId>myfaces-impl</artifactId>
+ </dependency>
+ </dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webappDirectory>${project.build.directory}/${project.build.finalName}-myfaces</webappDirectory>
- </configuration>
+ <executions>
+ <execution>
+ <id>mojarra</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>war</goal>
+ </goals>
+ <configuration>
+ <classifier>myfaces</classifier>
+ <packagingExcludes>WEB-INF/lib/jsf-api-*,WEB-INF/lib/jsf-impl-*</packagingExcludes>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
-
- <dependencies>
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>jta</artifactId>
- <version>1.1</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <scope>provided</scope>
- </dependency>
- </dependencies>
</profile>
</profiles>
</project>
Modified: modules/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2010-08-31 18:46:44 UTC (rev 19054)
+++ modules/tests/metamer/trunk/application/src/main/webapp/WEB-INF/web.xml 2010-09-01 08:11:47 UTC (rev 19055)
@@ -13,6 +13,10 @@
<param-value>server</param-value>
</context-param>
<context-param>
+ <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
+ <param-value>false</param-value>
+ </context-param>
+ <context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>#{richBean.skin}</param-value>
</context-param>
Modified: modules/tests/metamer/trunk/build.sh
===================================================================
--- modules/tests/metamer/trunk/build.sh 2010-08-31 18:46:44 UTC (rev 19054)
+++ modules/tests/metamer/trunk/build.sh 2010-09-01 08:11:47 UTC (rev 19055)
@@ -1,2 +1,2 @@
#!/bin/bash
-mvn clean install -Dselenium.server.skip=true -Dselenium.test.skip=true $*
+mvn clean install -Pmyfaces -Dselenium.server.skip=true -Dselenium.test.skip=true $*
Modified: modules/tests/metamer/trunk/pom.xml
===================================================================
--- modules/tests/metamer/trunk/pom.xml 2010-08-31 18:46:44 UTC (rev 19054)
+++ modules/tests/metamer/trunk/pom.xml 2010-09-01 08:11:47 UTC (rev 19055)
@@ -151,7 +151,7 @@
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
- <arguments>-Dselenium.test.skip=true -Dselenium.server.skip=true</arguments>
+ <arguments>-Pmyfaces -Dselenium.test.skip=true -Dselenium.server.skip=true</arguments>
<tagBase>https://svn.jboss.org/repos/richfaces/modules/tests/metamer/tags</tagBase>
<branchBase>https://svn.jboss.org/repos/richfaces/modules/tests/metamer/branches</branchBase>
</configuration>
14 years, 2 months