Author: abelevich
Date: 2010-11-04 12:38:37 -0400 (Thu, 04 Nov 2010)
New Revision: 19931
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
trunk/ui/input/ui/src/main/templates/select.template.xml
Log:
RF-9625, RF-9578, RF-9577
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractInplaceSelect.java 2010-11-04
16:38:37 UTC (rev 19931)
@@ -74,7 +74,6 @@
@Attribute
public abstract String getListClass();
-
@Attribute(defaultValue="click")
public abstract String getEditEvent();
@@ -106,7 +105,7 @@
public abstract String getOninputkeypress();
@Attribute(events=@EventName("inputkeyup"))
- public abstract String getOninputkeypup();
+ public abstract String getOninputkeyup();
@Attribute(events=@EventName("inputfocus"))
public abstract String getOninputfocus();
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java
===================================================================
--- trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-11-04
13:50:28 UTC (rev 19930)
+++ trunk/ui/input/ui/src/main/java/org/richfaces/component/AbstractSelect.java 2010-11-04
16:38:37 UTC (rev 19931)
@@ -93,7 +93,7 @@
public abstract String getOnkeypress();
@Attribute(events=@EventName("keyup"))
- public abstract String getOnkeypup();
+ public abstract String getOnkeyup();
@Attribute(events=@EventName("mousedown"))
public abstract String getOnmousedown();
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceInputRendererBase.java 2010-11-04
16:38:37 UTC (rev 19931)
@@ -23,19 +23,15 @@
import java.io.IOException;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
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 org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.InplaceComponent;
import org.richfaces.component.InplaceState;
-import org.richfaces.component.util.HtmlUtil;
/**
* @author Anton Belevich
@@ -159,11 +155,11 @@
String style = getReadyStateCss(inplaceComponent);
switch (inplaceState) {
case edit:
- style = HtmlUtil.concatClasses(style,
getEditStateCss(inplaceComponent));
+ style = concatClasses(style, getEditStateCss(inplaceComponent));
break;
case changed:
- style = HtmlUtil.concatClasses(style,
getChangedStateCss(inplaceComponent));
+ style = concatClasses(style, getChangedStateCss(inplaceComponent));
break;
case disable:
@@ -183,105 +179,36 @@
public String getEditStyleClass(UIComponent component, InplaceState inplaceState) {
InplaceComponent inplaceComponent = (InplaceComponent)component;
- return (InplaceState.edit != inplaceState) ?
HtmlUtil.concatClasses(getEditCss(inplaceComponent), getNoneCss(inplaceComponent)) :
getEditCss(inplaceComponent);
+ return (InplaceState.edit != inplaceState) ?
concatClasses(getEditCss(inplaceComponent), getNoneCss(inplaceComponent)) :
getEditCss(inplaceComponent);
}
-
- public void buildScript(ResponseWriter writer, FacesContext facesContext,
- UIComponent component, Object additional) throws IOException {
- if (!(component instanceof InplaceComponent)) {
- return;
- }
-
- String scriptName = getScriptName();
- JSFunction function = new JSFunction(scriptName);
- String clientId = component.getClientId(facesContext);
- Map<String, Object> options = createInplaceComponentOptions(clientId,
- (InplaceComponent) component);
- addToOptions(facesContext, component, options, additional);
- function.addParameter(clientId);
- function.addParameter(options);
- writer.write(function.toString());
- }
-
- protected String getScriptName() {
- return "new RichFaces.ui.InplaceInput";
- }
-
- private Map<String, Object> createInplaceComponentOptions(String clientId,
- InplaceComponent inplaceComponent) {
- Map<String, Object> options = new HashMap<String, Object>();
-
- if(!"click".equals(inplaceComponent.getEditEvent())){
- options.put(OPTIONS_EDIT_EVENT, inplaceComponent.getEditEvent());
- }
-
- if(!(InplaceState.ready == inplaceComponent.getState())) {
- options.put(OPTIONS_STATE, inplaceComponent.getState());
- }
-
- String css = inplaceComponent.getNoneClass();
- if(css != null && css.trim().length() > 0) {
- options.put(OPTIONS_NONE_CSS, getNoneCss(inplaceComponent));
- }
-
- css = inplaceComponent.getChangedStateClass();
- if(css != null && css.trim().length() > 0) {
- options.put(OPTIONS_CHANGED_CSS, getChangedStateCss(inplaceComponent));
- }
-
- css = inplaceComponent.getEditStateClass();
- if(css != null && css.trim().length() > 0) {
- options.put(OPTIONS_EDIT_CSS, getEditStateCss(inplaceComponent));
- }
-
- String label = inplaceComponent.getDefaultLabel();
- if(label != null && label.trim().length() > 0) {
- options.put(OPTIONS_DEFAULT_LABEL, inplaceComponent.getDefaultLabel());
- }
-
- if(!inplaceComponent.isSaveOnBlur()) {
- options.put(OPTIONS_SAVE_ON_BLUR, inplaceComponent.isSaveOnBlur());
- }
-
- if(inplaceComponent.isShowControls()) {
- options.put(OPTIONS_SHOWCONTROLS, inplaceComponent.isShowControls());
- }
-
- return options;
- }
-
- public void addToOptions(FacesContext facesContext, UIComponent component,
- Map<String, Object> options, Object additional) {
- // override this method if you need additional options
- }
-
+
public String getReadyStateCss(InplaceComponent component) {
String css = component.getReadyStateClass();
- return HtmlUtil.concatClasses("rf-ii-d-s", css);
+ return concatClasses("rf-ii-d-s", css);
}
public String getEditStateCss(InplaceComponent component) {
String css = component.getEditStateClass();
- return HtmlUtil.concatClasses("rf-ii-e-s", css);
+ return concatClasses("rf-ii-e-s", css);
}
public String getChangedStateCss(InplaceComponent component) {
String css = component.getChangedStateClass();
- return HtmlUtil.concatClasses("rf-ii-c-s", css);
+ return concatClasses("rf-ii-c-s", css);
}
public String getDisableStateCss(InplaceComponent component) {
String css = component.getDisableStateClass();
- return HtmlUtil.concatClasses("rf-ii-dis-s", css);
+ return concatClasses("rf-ii-dis-s", css);
}
public String getEditCss(InplaceComponent component) {
String css = component.getEditClass();
- return HtmlUtil.concatClasses("rf-ii-edit", css);
+ return concatClasses("rf-ii-edit", css);
}
public String getNoneCss(InplaceComponent component) {
String css = component.getNoneClass();
- return HtmlUtil.concatClasses("rf-ii-none", css);
+ return concatClasses("rf-ii-none", css);
}
}
Modified:
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/InplaceSelectRendererBase.java 2010-11-04
16:38:37 UTC (rev 19931)
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.util.List;
-import java.util.Map;
import javax.faces.application.ResourceDependencies;
import javax.faces.application.ResourceDependency;
@@ -32,9 +31,7 @@
import javax.faces.context.FacesContext;
import org.richfaces.component.AbstractInplaceSelect;
-import org.richfaces.component.AbstractSelect;
import org.richfaces.component.InplaceComponent;
-import org.richfaces.component.util.HtmlUtil;
/**
* @author Anton Belevich
@@ -68,12 +65,6 @@
public static final String LIST_CSS = "rf-is-lst-cord";
-
- @Override
- protected String getScriptName() {
- return "new RichFaces.ui.InplaceSelect";
- }
-
public List<ClientSelectItem> getConvertedSelectItems(FacesContext
facesContext, UIComponent component) {
return SelectHelper.getConvertedSelectItems(facesContext, component);
}
@@ -95,20 +86,6 @@
return SelectHelper.getSelectInputLabel(facesContext, component);
}
- @Override
- public void addToOptions(FacesContext facesContext, UIComponent component,
Map<String, Object> options, Object additional) {
- AbstractSelect abstractSelect = (AbstractSelect)component;
- SelectHelper.addSelectCssToOptions(abstractSelect, options, new String[]
{ITEM_CSS, SELECT_ITEM_CSS, LIST_CSS});
- boolean openOnEdit =
(Boolean)component.getAttributes().get("openOnEdit");
- boolean saveOnSelect =
(Boolean)component.getAttributes().get("saveOnSelect");
- if(openOnEdit) {
- options.put(OPTIONS_OPEN_ON_EDIT, openOnEdit);
- options.put(OPTIONS_SAVE_ON_SELECT, saveOnSelect);
-
- }
- options.put(SelectHelper.OPTIONS_LIST_ITEMS, additional);
- }
-
public String getSelectLabel(FacesContext facesContext, UIComponent component) {
AbstractInplaceSelect select = (AbstractInplaceSelect) component;
String label = getSelectInputLabel(facesContext, select);
@@ -120,31 +97,31 @@
public String getReadyStateCss(InplaceComponent component) {
String css = component.getReadyStateClass();
- return HtmlUtil.concatClasses("rf-is-d-s", css);
+ return concatClasses("rf-is-d-s", css);
}
public String getEditStateCss(InplaceComponent component) {
String css = component.getEditStateClass();
- return HtmlUtil.concatClasses("rf-is-e-s", css);
+ return concatClasses("rf-is-e-s", css);
}
public String getChangedStateCss(InplaceComponent component) {
String css = component.getChangedStateClass();
- return HtmlUtil.concatClasses("rf-is-c-s", css);
+ return concatClasses("rf-is-c-s", css);
}
public String getDisableStateCss(InplaceComponent component) {
String css = component.getDisableStateClass();
- return HtmlUtil.concatClasses("rf-is-dis-s", css);
+ return concatClasses("rf-is-dis-s", css);
}
public String getEditCss(InplaceComponent component) {
String css = component.getEditClass();
- return HtmlUtil.concatClasses("rf-is-edit", css);
+ return concatClasses("rf-is-edit", css);
}
public String getNoneCss(InplaceComponent component) {
String css = component.getNoneClass();
- return HtmlUtil.concatClasses("rf-is-none", css);
+ return concatClasses("rf-is-none", css);
}
}
Modified: trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java
===================================================================
---
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/java/org/richfaces/renderkit/SelectRendererBase.java 2010-11-04
16:38:37 UTC (rev 19931)
@@ -23,17 +23,13 @@
package org.richfaces.renderkit;
import java.io.IOException;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
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 org.ajax4jsf.javascript.JSFunction;
import org.richfaces.component.AbstractSelect;
/**
@@ -54,11 +50,6 @@
public static final String ITEM_CSS = "rf-sel-opt";
- public static final String SELECT_ITEM_CSS = "rf-sel-sel";
-
- public static final String LIST_CSS = "rf-sel-lst-cord";
-
-
public void renderListHandlers(FacesContext facesContext, UIComponent component)
throws IOException {
RenderKitUtils.renderPassThroughAttributesOptimized(facesContext, component,
SelectHelper.SELECT_LIST_HANDLER_ATTRIBUTES);
}
@@ -84,46 +75,4 @@
throws IOException {
SelectHelper.encodeItems(facesContext, component, clientSelectItems,
HtmlConstants.DIV_ELEM, ITEM_CSS);
}
-
- public void buildScript(ResponseWriter writer, FacesContext facesContext, UIComponent
component, List<ClientSelectItem> selectItems) throws IOException {
- if (!(component instanceof AbstractSelect)) {
- return;
- }
-
- AbstractSelect abstractSelect = (AbstractSelect)component;
- String scriptName = getScriptName();
- JSFunction function = new JSFunction(scriptName);
-
- String clientId = abstractSelect.getClientId(facesContext);
- Map<String, Object> options = new HashMap<String, Object>();
- options.put(SelectHelper.OPTIONS_LIST_ITEMS, selectItems);
-
- if(!abstractSelect.isShowButton()) {
- options.put(SelectHelper.OPTIONS_SHOWCONTROL,
abstractSelect.isShowButton());
- }
-
- String defaultLabel = abstractSelect.getDefaultLabel();
- if( defaultLabel != null && defaultLabel.trim().length() > 0) {
- options.put(SelectHelper.OPTIONS_INPUT_DEFAULT_LABEL, defaultLabel);
- }
-
- if(abstractSelect.isEnableManualInput()) {
- options.put(SelectHelper.OPTIONS_ENABLE_MANUAL_INPUT,
abstractSelect.isEnableManualInput());
- }
-
- if(!abstractSelect.isSelectFirst()) {
- options.put(SelectHelper.OPTIONS_LIST_SELECT_FIRST,
abstractSelect.isSelectFirst());
- }
-
- SelectHelper.addSelectCssToOptions(abstractSelect, options, new String[]
{ITEM_CSS, SELECT_ITEM_CSS, LIST_CSS});
-
- function.addParameter(clientId);
- function.addParameter(options);
-
- writer.write(function.toString());
- }
-
- protected String getScriptName() {
- return "new RichFaces.ui.Select";
- }
}
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceBase.js 2010-11-04
16:38:37 UTC (rev 19931)
@@ -55,10 +55,6 @@
oncancel: function() {
},
- isValueSaved: function() {
- return this.isSaved;
- },
-
save: function() {
var value = this.getValue()
if(value.length > 0) {
@@ -85,6 +81,10 @@
this.__hide();
this.oncancel();
},
+
+ isValueSaved: function() {
+ return this.isSaved;
+ },
isEditState: function() {
return this.editState;
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceInput.js 2010-11-04
16:38:37 UTC (rev 19931)
@@ -65,17 +65,8 @@
}
},
- __handleBlur: function() {
- if(!this.isValueSaved() && this.__isSaveOnBlur()) {
- this.save();
- } else {
- this.__hide();
- }
- this.getInput().bind("focus", $.proxy(this.__editHandler,
this));
- },
-
__blurHandler: function(e) {
- this.__handleBlur();
+ this.onblur();
},
__changeHandler: function(e) {
@@ -121,8 +112,17 @@
onhide: function() {
this.focusElement.focus();
- }
-
+ },
+
+ onblur: function() {
+ if(!this.isValueSaved() && this.__isSaveOnBlur()) {
+ this.save();
+ } else {
+ this.__hide();
+ }
+ this.getInput().bind("focus", $.proxy(this.__editHandler,
this));
+ }
+
}
})());
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inplaceSelect.js 2010-11-04
16:38:37 UTC (rev 19931)
@@ -5,7 +5,7 @@
rf.ui.InplaceSelect = function(id, options) {
var mergedOptions = $.extend({}, defaultOptions, options);
$super.constructor.call(this, id, mergedOptions)
-
+ this.getInput().bind("click", $.proxy(this.__clickHandler, this));
mergedOptions['attachTo'] = id;
mergedOptions['scrollContainer'] = $(document.getElementById(id +
"Items")).parent()[0];
this.popupList = new rf.ui.PopupList(id+"List", this, mergedOptions);
@@ -81,7 +81,12 @@
this.saveItemValue(value);
}
},
-
+
+ onblur: function() {
+ this.hidePopup();
+ $super.onblur.call(this);
+ },
+
processItem: function(item) {
var label = this.getItemLabel(item);
this.setValue(label);
@@ -160,12 +165,11 @@
$super.__keydownHandler.call(this,e);
},
-
+
__blurHandler: function(e) {
if(this.isEditState()) {
this.timeoutId = window.setTimeout($.proxy(function(){
- this.hidePopup();
- this.__handleBlur();
+ this.onblur();
}, this), 200);
}
},
Modified:
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/inputBase.js 2010-11-04
16:38:37 UTC (rev 19931)
@@ -13,7 +13,6 @@
this.input.bind("keydown", $.proxy(this.__keydownHandler, this));
this.input.bind("blur", $.proxy(this.__blurHandler, this));
this.input.bind("change", $.proxy(this.__changeHandler, this));
- this.input.bind("click", $.proxy(this.__clickHandler, this));
this.input.bind("focus", $.proxy(this.__focusHandler, this));
};
@@ -26,6 +25,7 @@
name : "inputBase",
+
getName: function() {
return this.name;
},
@@ -33,14 +33,10 @@
getNamespace: function() {
return this.namespace;
},
-
+
__focusHandler: function(e) {
-
},
- __clickHandler: function(e) {
- },
-
__keydownHandler: function(e) {
},
Modified: trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
===================================================================
---
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-04
13:50:28 UTC (rev 19930)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2010-11-04
16:38:37 UTC (rev 19931)
@@ -24,8 +24,7 @@
var result = true;
for (var i = 0; i<this.values.length; i++) {
if (this.values[i].indexOf(this.key)!=0) {
- result = false;
- break;
+ result = false; break;
}
}
return result;
@@ -42,10 +41,13 @@
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];
+
if (useCustomFilterFunction && filterFunction(key, value)) {
newCache.push(itemsCache[i]);
} else {
@@ -58,6 +60,7 @@
if ((!this.lastKey || key.indexOf(this.lastKey)!=0) && newCache.length > 0)
{
this.cache[key] = newCache;
+
if (newCache.length==1) {
this.lastKey = key;
}
@@ -94,16 +97,17 @@
rf.ui = rf.ui || {};
rf.ui.Select = function(id, options) {
- $super.constructor.call(this, id);
this.id = id;
- var mergedOptions = $.extend({}, defaultOptions, options);
+ var mergedOptions = $.extend({}, defaultOptions, options);
mergedOptions['attachTo'] = id;
mergedOptions['scrollContainer'] = $(document.getElementById(id +
"Items")).parent()[0];
-
- this.defaultLabel = mergedOptions.defaultLabel;
+
+ $super.constructor.call(this, id, mergedOptions);
+
+ this.options = mergedOptions;
+ this.defaultLabel = mergedOptions.defaultLabel;
var inputLabel = this.getValue() ;
this.initialValue = (inputLabel != this.defaultLabel) ? inputLabel :
"";
-
this.selValueInput = $(document.getElementById(id+"selValue"));
this.clientItems = mergedOptions.items;
@@ -114,15 +118,16 @@
this.focusin = false;
}));
}
+
this.selectFirst = mergedOptions.selectFirst;
this.popupList = new rf.ui.PopupList((id+"List"), this,
mergedOptions);
this.listElem = $(document.getElementById(id+"List"));
this.listElem.bind("click", $.proxy(this.__onListClick, this));
+ this.items = this.popupList.__getItems();
+ this.enableManualInput = mergedOptions.enableManualInput;
- var items = this.popupList.__getItems();
- var enableManualInput = mergedOptions.enableManualInput;
- if (items.length>0 && enableManualInput) {
- this.cache = new rf.utils.Cache("", items, getData, true);
+ if (this.items.length>0 && this.enableManualInput) {
+ this.cache = new rf.utils.Cache("", this.items, getData, true);
}
this.changeDelay = mergedOptions.changeDelay;
@@ -153,7 +158,6 @@
}
$.extend(rf.ui.Select.prototype, ( function () {
-
return{
name : "select",
@@ -169,14 +173,19 @@
},
__focusHandler: function(e) {
- if(this.getValue() == this.defaultLabel) {
- this.setValue("");
+ if (!this.focused) {
+ if(this.getValue() == this.defaultLabel) {
+ this.setValue("");
+ }
+ this.focusValue = this.selValueInput.val();
+ this.focused = true;
+ this.invokeEvent.call(this, "focus", document.getElementById(this.id +
'Input'), e);
}
},
__keydownHandler: function(e) {
var code;
-
+
if(e.keyCode) {
code = e.keyCode;
} else if(e.which) {
@@ -184,6 +193,7 @@
}
var visible = this.popupList.isVisible();
+
switch(code) {
case rf.KEYS.DOWN:
e.preventDefault();
@@ -232,7 +242,6 @@
var newValue = this.getValue();
if(this.cache && this.cache.isCached(newValue)) {
-
this.__updateItems();
if(!this.popupList.isVisible()) {
@@ -241,19 +250,10 @@
}
},
- __handleBlur: function(e) {
- var inputLabel = this.getValue();
- if(!inputLabel || inputLabel == "") {
- this.setValue(this.defaultLabel);
- this.selValueInput.val("");
- }
- },
-
__blurHandler: function(e) {
this.timeoutId = window.setTimeout($.proxy(function(){
- this.hidePopup();
- this.__handleBlur();
- }, this), 200);
+ this.onblur(e);
+ }, this), 200);
},
__onListClick: function(e) {
@@ -264,16 +264,19 @@
var newValue = this.getValue();
newValue = (newValue != this.defaultLabel) ? newValue : "";
this.__updateItemsFromCache(newValue);
+
if(this.selectFirst) {
this.popupList.__selectByIndex(0);
}
},
__updateItemsFromCache: function(value) {
- var newItems = this.cache.getItems(value);
- var items = $(newItems);
- this.popupList.__setItems(items);
- $(document.getElementById(this.id+"Items")).empty().append(items);
+ if(this.items.length>0 && this.enableManualInput) {
+ var newItems = this.cache.getItems(value);
+ var items = $(newItems);
+ this.popupList.__setItems(items);
+ $(document.getElementById(this.id+"Items")).empty().append(items);
+ }
},
showPopup: function() {
@@ -287,7 +290,7 @@
processItem: function(item) {
var key = $(item).attr("id");
var value = this.getItemValue(key);
- this.saveItemValue(value);
+ this.selValueInput.val(value);
var label = this.getItemLabel(key);
this.setValue(label);
this.hidePopup();
@@ -312,11 +315,23 @@
}
},
- saveItemValue: function(value) {
- this.selValueInput.val(value);
+ onblur: function(e) {
+ this.hidePopup();
+ var inputLabel = this.getValue();
+ if(!inputLabel || inputLabel == "") {
+ this.setValue(this.defaultLabel);
+ this.selValueInput.val("");
+ }
+
+ this.focused = false;
+
+ this.invokeEvent.call(this,"blur", document.getElementById(this.id +
'Input'), e);
+
+ if(this.focusValue != this.selValueInput.val() ) {
+ this.invokeEvent.call(this, "change", document.getElementById(this.id +
'Input'), e);
+ }
}
}
-
})());
})(jQuery, window.RichFaces);
Modified: trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-11-04 13:50:28 UTC
(rev 19930)
+++ trunk/ui/input/ui/src/main/templates/inplaceInput.template.xml 2010-11-04 16:38:37 UTC
(rev 19931)
@@ -82,7 +82,13 @@
</c:if>
</span>
<script type="text/javascript">
- <cdk:call expression="buildScript(responseWriter, facesContext, component,
null);"/>
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption name="noneCss"
value="#{concatClasses('rf-ii-none',
component.attributes['noneClass'])}"/>
+ <cdk:scriptOption name="changedCss"
value="#{concatClasses('rf-ii-c-s',
component.attributes['changedClass'])}"/>
+ <cdk:scriptOption name="editCss"
value="#{concatClasses('rf-ii-e-s',
component.attributes['editClass'])}"/>
+ <cdk:scriptOption attributes="editEvent state defaultLabel saveOnBlur
showControls" />
+ </cdk:scriptObject>
+ new RichFaces.ui.InplaceInput("#{clientId}", #{toScriptArgs(options)});
</script>
</c:if>
</span>
Modified: trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-11-04 13:50:28
UTC (rev 19930)
+++ trunk/ui/input/ui/src/main/templates/inplaceSelect.template.xml 2010-11-04 16:38:37
UTC (rev 19931)
@@ -98,7 +98,14 @@
</span>
</span>
<script type="text/javascript">
- <cdk:call expression="buildScript(responseWriter, facesContext, component,
clientSelectItems);" />
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption name="items" value="#{clientSelectItems}"
/>
+ <cdk:scriptOption name="noneCss"
value="#{concatClasses('rf-is-none',
component.attributes['noneClass'])}"/>
+ <cdk:scriptOption name="changedCss"
value="#{concatClasses('rf-is-c-s',
component.attributes['changedClass'])}"/>
+ <cdk:scriptOption name="editCss"
value="#{concatClasses('rf-is-e-s',
component.attributes['editClass'])}"/>
+ <cdk:scriptOption attributes="editEvent state defaultLabel saveOnBlur
showControls openOnEdit saveOnSelect" />
+ </cdk:scriptObject>
+ new RichFaces.ui.InplaceSelect("#{clientId}", #{toScriptArgs(options)});
</script>
</c:if>
</span>
Modified: trunk/ui/input/ui/src/main/templates/select.template.xml
===================================================================
--- trunk/ui/input/ui/src/main/templates/select.template.xml 2010-11-04 13:50:28 UTC (rev
19930)
+++ trunk/ui/input/ui/src/main/templates/select.template.xml 2010-11-04 16:38:37 UTC (rev
19931)
@@ -64,7 +64,15 @@
</div>
</div>
<script type="text/javascript">
- <cdk:call expression="buildScript(responseWriter, facesContext, component,
clientSelectItems);"/>
+ <cdk:scriptObject name="options">
+ <cdk:scriptOption name="items"
value="#{clientSelectItems}" />
+ <cdk:scriptOption name="itemCss"
value="#{concatClasses('rf-sel-opt',
component.attributes['itemClass'])}" />
+ <cdk:scriptOption name="selectItemCss"
value="#{concatClasses('rf-sel-sel',
component.attributes['selectItemClass'])}" />
+ <cdk:scriptOption name="listCss"
value="#{concatClasses('rf-sel-lst-cord',
component.attributes['listClass'])}" />
+ <cdk:scriptOption attributes="onchange onselect"
wrapper="eventHandler"/>
+ <cdk:scriptOption attributes="showControl defaultLabel enableManualInput
selectFirst" />
+ </cdk:scriptObject>
+ new RichFaces.ui.Select("#{clientId}", #{toScriptArgs(options)});
</script>
</div>
</cc:implementation>