Author: abelevich
Date: 2011-02-04 13:44:31 -0500 (Fri, 04 Feb 2011)
New Revision: 21467
Modified:
trunk/examples/input-demo/src/main/webapp/examples/select.xhtml
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js
Log:
RF-10164 select: inconsistency of usage arrow button and showPopup api method.
Modified: trunk/examples/input-demo/src/main/webapp/examples/select.xhtml
===================================================================
--- trunk/examples/input-demo/src/main/webapp/examples/select.xhtml 2011-02-04 18:41:40
UTC (rev 21466)
+++ trunk/examples/input-demo/src/main/webapp/examples/select.xhtml 2011-02-04 18:44:31
UTC (rev 21467)
@@ -1,46 +1,61 @@
<!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:in="http://richfaces.org/input">
-<f:view contentType="text/html" />
+
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:in="http://richfaces.org/input"
+
xmlns:misc="http://richfaces.org/misc">
+<f:view contentType="text/html"/>
<h:head>
- <title>Select</title>
+ <title>Select</title>
</h:head>
<h:body>
- <h:form id="form">
- <div id="scroll" style="width: 400px; height:100px;
overflow:auto;" >
- <fieldset>
- <legend>Select Test App</legend>
- <in:select id="select" enableManualInput="true"
defaultLabel="Select Value ..." value="#{inputBean.value}">
- <f:selectItem itemLabel="Label#1" itemValue="Value#1"/>
- <f:selectItem itemLabel="Label#2" itemValue="Value#2"/>
- <f:selectItem itemLabel="Label#3" itemValue="Value#3"/>
- <f:selectItem itemLabel="Label#4" itemValue="Value#4"/>
- <f:selectItem itemLabel="Label#5" itemValue="Value#5"/>
- <f:selectItem itemLabel="Label#6" itemValue="Value#6"/>
- <f:selectItem itemLabel="Label#7" itemValue="Value#7"/>
- <f:selectItem itemLabel="Label#8" itemValue="Value#8"/>
- <f:selectItem itemLabel="Label#9" itemValue="Value#9"/>
- <f:selectItem itemLabel="Label#10" itemValue="Value#10"/>
- <f:selectItem itemLabel="Label#11" itemValue="Value#11"/>
- <f:selectItem itemLabel="Label#12" itemValue="Value#12"/>
- <f:selectItem itemLabel="Label#13" itemValue="Value#13"/>
- <f:selectItem itemLabel="Label#14" itemValue="Value#14"/>
- <f:ajax event="change" execute="@form"
render="out"/>
- </in:select>
- </fieldset>
- <h:commandButton value="submit">
- <f:ajax execute="@form" render="select out"/>
- </h:commandButton>
- </div>
- <h:panelGroup id="out">
- <h:outputText value="Selected Value: #{inputBean.value}"/>
- </h:panelGroup>
- </h:form>
+ <h:form id="form">
+ <div id="scroll" style="width: 400px; height:100px;
overflow:auto;">
+ <fieldset>
+ <legend>Select Test App</legend>
+ <in:select id="select" openOnEdit="true"
enableManualInput="true" defaultLabel="Select Value ..."
+ value="#{inputBean.value}">
+ <f:selectItem itemLabel="Label#1"
itemValue="Value#1"/>
+ <f:selectItem itemLabel="Label#2"
itemValue="Value#2"/>
+ <f:selectItem itemLabel="Label#3"
itemValue="Value#3"/>
+ <f:selectItem itemLabel="Label#4"
itemValue="Value#4"/>
+ <f:selectItem itemLabel="Label#5"
itemValue="Value#5"/>
+ <f:selectItem itemLabel="Label#6"
itemValue="Value#6"/>
+ <f:selectItem itemLabel="Label#7"
itemValue="Value#7"/>
+ <f:selectItem itemLabel="Label#8"
itemValue="Value#8"/>
+ <f:selectItem itemLabel="Label#9"
itemValue="Value#9"/>
+ <f:selectItem itemLabel="Label#10"
itemValue="Value#10"/>
+ <f:selectItem itemLabel="Label#11"
itemValue="Value#11"/>
+ <f:selectItem itemLabel="Label#12"
itemValue="Value#12"/>
+ <f:selectItem itemLabel="Label#13"
itemValue="Value#13"/>
+ <f:selectItem itemLabel="Label#14"
itemValue="Value#14"/>
+ <f:ajax event="change" execute="@form"
render="out"/>
+ </in:select>
+ </fieldset>
+ <h:commandButton value="submit">
+ <f:ajax execute="@form" render="select out"/>
+ </h:commandButton>
+ </div>
+
+ <ul>
+ <li>
+ <h:commandButton value="ShowPopup"
+
onclick="#{misc:component('select')}.showPopup(); return false;"/>
+ </li>
+ <li>
+ <h:commandButton value="HidePopup"
+
onclick="#{misc:component('select')}.hidePopup(); return false;"/>
+ </li>
+
+
+ </ul>
+ <h:panelGroup id="out">
+ <h:outputText value="Selected Value: #{inputBean.value}"/>
+ </h:panelGroup>
+ </h:form>
</h:body>
</html>
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 2011-02-04
18:41:40 UTC (rev 21466)
+++
trunk/ui/input/ui/src/main/resources/META-INF/resources/org.richfaces/select.js 2011-02-04
18:44:31 UTC (rev 21467)
@@ -75,7 +75,7 @@
this.__updateItems();
this.__showPopup();
} else {
- this.hidePopup();
+ this.__hidePopup();
}
this.isMouseDown = true;
},
@@ -134,7 +134,7 @@
case rf.KEYS.ESC:
e.preventDefault();
if(visible) {
- this.hidePopup();
+ this.__hidePopup();
}
break;
@@ -257,9 +257,43 @@
this.popupList.show();
},
- hidePopup: function() {
+ __hidePopup: function() {
this.popupList.hide();
},
+
+ showPopup: function() {
+ if (!this.popupList.isVisible()) {
+ this.__updateItems();
+ this.__showPopup();
+ }
+ this.__setInputFocus();
+ 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));
+ }
+ },
+
+ hidePopup: function() {
+ if (this.popupList.isVisible()){
+ 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));
+ if (this.focusValue != this.selValueInput.val()) {
+ this.invokeEvent.call(this, "change",
document.getElementById(this.id));
+ }
+ }
+ },
processItem: function(item) {
var key = $(item).attr("id");
@@ -271,7 +305,7 @@
}
});
this.__setValue(label);
- this.hidePopup();
+ this.__hidePopup();
this.__setInputFocus();
this.__save();
@@ -303,7 +337,7 @@
},
onblur: function(e) {
- this.hidePopup();
+ this.__hidePopup();
var inputLabel = this.__getValue();
if(!inputLabel || inputLabel == "") {