JBoss Rich Faces SVN: r5274 - trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-01-10 12:28:49 -0500 (Thu, 10 Jan 2008)
New Revision: 5274
Modified:
trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
Log:
selection functionality was corrected
Modified: trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
--- trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-01-10 16:14:39 UTC (rev 5273)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-01-10 17:28:49 UTC (rev 5274)
@@ -208,6 +208,7 @@
Richfaces.ComboBoxList.prototype = {
initialize: function(listId, parentListId, selectFirstOnUpdate, classes, width, height, itemsText, onlistcall, fieldXY) {
+
this.list = $(listId);
this.listParent = $(parentListId);
17 years
JBoss Rich Faces SVN: r5273 - trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: vmolotkov
Date: 2008-01-10 11:14:39 -0500 (Thu, 10 Jan 2008)
New Revision: 5273
Modified:
trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
Log:
selection functionality was corrected
Modified: trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
--- trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-01-10 15:17:54 UTC (rev 5272)
+++ trunk/sandbox/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-01-10 16:14:39 UTC (rev 5273)
@@ -57,6 +57,9 @@
} else {
this.comboList.createDefaultList();
this.comboList.show();
+ if (this.comboList.selectedItem) {
+ this.comboList.scrollingUpToItem(this.comboList.selectedItem);
+ }
this.comboList.isList = false;
}
this.field.focus();
@@ -66,7 +69,7 @@
//changes item's decoration
var item = this.comboList.getEventItem(event);
if (item) {
- this.comboList.selectItem(this.comboList.getEventItem(event));
+ this.comboList.doActiveItem(this.comboList.getEventItem(event));
}
},
@@ -94,10 +97,10 @@
},
setValue : function(toSetOnly) {
- if (!this.comboList.selectedItem) {
+ if (!this.comboList.activeItem) {
return;
}
- var value = this.comboList.selectedItem.innerHTML;
+ var value = this.comboList.activeItem.innerHTML;
if (toSetOnly) {
var oV = this.field.value;
if (oV == value) {
@@ -106,6 +109,7 @@
}
}
this.field.value = value;
+ this.comboList.doSelectItem(this.comboList.activeItem);
this.combobox.fire("rich:onitemselected", {});
if (oV != value) {
this.combobox.fire("rich:onchange", {});
@@ -131,10 +135,10 @@
this.comboList.hide();
break;
case Event.KEY_DOWN :
- this.comboList.moveSelectedItem(event);
+ this.comboList.moveActiveItem(event);
break;
case Event.KEY_UP :
- this.comboList.moveSelectedItem(event);
+ this.comboList.moveActiveItem(event);
break;
default :
//this.dataUpdating(event);
@@ -146,6 +150,11 @@
var value = this.field.value;
if (value.length == 0) {
this.applyDefaultText();
+ } else {
+ var item = this.comboList.findItemBySubstr(value);
+ if (item) {
+ this.comboList.doSelectItem(item);
+ }
}
this.comboList.hide();
this.doDisable();
@@ -171,10 +180,10 @@
if (!this.comboList.visible()) {
this.comboList.show();
}
- var item = this.comboList.findItemByText(this.field.value);
+ var item = this.comboList.findItemBySubstr(this.field.value);
if (item) {
- this.comboList.selectItem(this.comboList.findItemByText(this.field.value));
- this.comboList.scrollingUpToSdItem();
+ this.comboList.doActiveItem(item);
+ this.comboList.scrollingUpToItem(this.comboList.activeItem);
}
}
@@ -217,7 +226,9 @@
this.defaultRowsAmount = 15;
this.selectedItem = null;
+ this.activeItem = null;
+
this.width = width;
this.height = height;
this.fieldDimensions = fieldXY;
@@ -253,10 +264,19 @@
this.setSize();
this.setPosition(this.fieldDimensions.top, this.fieldDimensions.left, this.fieldDimensions.height);
- var curItems = this.getItems();
+ if (this.selectedItem) {
+ //was created new item list, so necessary to recreate selectedItem
+ this.doSelectItem(this.findItemBySubstr(this.selectedItem.innerHTML));
+ }
+
if (this.selectFirstOnUpdate) {
+ var curItems = this.getItems();
if (curItems.length != 0) {
- this.selectItem(curItems[0]);
+ if (this.selectedItem) {
+ this.doActiveItem(this.selectedItem);
+ } else {
+ this.doActiveItem(curItems[0]);
+ }
}
}
this.listParent.show();
@@ -339,7 +359,7 @@
var increment;
var listTop = Richfaces.ComboBoxList.getElemXY(this.listParent).top;
var scrollTop = this.listParent.scrollTop;
- var itemTop = Richfaces.ComboBoxList.getElemXY(this.selectedItem).top;
+ var itemTop = Richfaces.ComboBoxList.getElemXY(this.activeItem).top;
if ((event.keyCode == Event.KEY_UP) || (event.keyCode == 33)) {
increment = (itemTop - scrollTop) - listTop;
@@ -347,7 +367,7 @@
this.listParent.scrollTop += increment;
}
} else if ((event.keyCode == Event.KEY_DOWN) || (event.keyCode == 34)) {
- var itemBottom = itemTop + this.selectedItem.offsetHeight;
+ var itemBottom = itemTop + this.activeItem.offsetHeight;
var increment = (itemBottom - scrollTop) - (listTop + this.listParent.clientHeight);
if (increment > 0) {
this.listParent.scrollTop += increment;
@@ -356,26 +376,30 @@
Event.stop(event);
},
- scrollingUpToSdItem : function() {
- var increment = (Richfaces.ComboBoxList.getElemXY(this.selectedItem).top - this.listParent.scrollTop) - Richfaces.ComboBoxList.getElemXY(this.listParent).top;
+ scrollingUpToItem : function(item) {
+ var increment = (Richfaces.ComboBoxList.getElemXY(item).top - this.listParent.scrollTop) - Richfaces.ComboBoxList.getElemXY(this.listParent).top;
this.listParent.scrollTop += increment;
},
/* items library*/
- selectItem : function(item) {
- if (this.selectedItem) {
- this.normalizeItem(this.selectedItem);
+ doActiveItem : function(item) {
+ if (this.activeItem) {
+ this.doNormalItem(this.activeItem);
}
- this.selectedItem = item;
+ this.activeItem = item;
this.changeItem(item, this.classes.ITEM.SELECTED);
},
- normalizeItem : function(item) {
- this.selectedItem = null;
+ doNormalItem : function(item) {
+ this.activeItem = null;
this.changeItem(item, this.classes.ITEM.NORMAL);
},
+ doSelectItem : function(item) {
+ this.selectedItem = item;
+ },
+
changeItem : function(item, className) {
item.className = className;
},
@@ -388,9 +412,9 @@
return item;
},
- moveSelectedItem : function(event) {
- var item = this.selectedItem;
- if (!this.selectedItem) {
+ moveActiveItem : function(event) {
+ var item = this.activeItem;
+ if (!this.activeItem) {
return;
}
if (event.keyCode == Event.KEY_UP) {
@@ -408,15 +432,15 @@
},
itemsRearrangement : function(item, newItem) {
- //this.normalizeItem(item);
- this.selectItem(newItem);
+ //this.doNormalItem(item);
+ this.doActiveItem(newItem);
},
resetState : function() {
var tempList = this.list.cloneNode(false);
this.listParent.replaceChild(tempList, this.listParent.firstChild);
this.list = this.listParent.firstChild;
- this.selectedItem = null;
+ this.activeItem = null;
this.isList = false;
},
@@ -435,15 +459,24 @@
return items;
},
- findItemByText : function(text) {
- for (var i = 0; i < this.itemsText.length; i++) {
- var itText = this.itemsText[i];
- if (itText.substr(0, text.length).toLowerCase() == text.toLowerCase()) { //FIXME: to optimaize
- return this.list.childNodes[i];
+ findItemBySubstr : function(substr) {
+ var items = this.getItems();
+ for (var i = 0; i < items.length; i++) {
+ var item = items[i]
+ var itText = item.innerHTML;
+ if (itText.substr(0, substr.length).toLowerCase() == substr.toLowerCase()) { //FIXME: to optimaize
+ return item;
}
}
},
+ /*findItemByText : function(text) {
+ var id = this.itemsText.indexOf(text);
+ if (id != -1) {
+ return this.getItems()[this.itemsText.indexOf(text)];
+ }
+ },*/
+
createNewList : function(items) {
//FIX for FF
this.list.innerHTML = items.join("");
17 years
JBoss Rich Faces SVN: r5272 - in trunk/sandbox/samples/combobox-sample/src/main: webapp/WEB-INF and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 10:17:54 -0500 (Thu, 10 Jan 2008)
New Revision: 5272
Modified:
trunk/sandbox/samples/combobox-sample/src/main/java/org/richfaces/samples/Bean.java
trunk/sandbox/samples/combobox-sample/src/main/webapp/WEB-INF/web.xml
trunk/sandbox/samples/combobox-sample/src/main/webapp/pages/index.jsp
Log:
new values
Modified: trunk/sandbox/samples/combobox-sample/src/main/java/org/richfaces/samples/Bean.java
===================================================================
--- trunk/sandbox/samples/combobox-sample/src/main/java/org/richfaces/samples/Bean.java 2008-01-10 15:17:02 UTC (rev 5271)
+++ trunk/sandbox/samples/combobox-sample/src/main/java/org/richfaces/samples/Bean.java 2008-01-10 15:17:54 UTC (rev 5272)
@@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.List;
+import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
/**
@@ -36,7 +37,16 @@
String suggestions = "Alabama,Alaska,Arizona,Arkansas,California,Colorado,Connecticut,Delaware,Florida,Maryland,Massachusetts,Michigan,Georgia,Hawaii,Idaho,Indiana,Iowa,Kansas,Kentucky,Louisiana,Maine,Minnesota,Mississippi,Missouri,Montana,Nebraska";
List selectItems = new ArrayList();
+ private String state="";
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
public Bean() {
selectItems.add(new SelectItem("District of Columbia"));
selectItems.add(new SelectItem("Illinois"));
@@ -45,7 +55,17 @@
selectItems.add(new SelectItem("New Hampshire"));
selectItems.add(new SelectItem("New Jersey"));
}
+
+ public void selectionChanged(ValueChangeEvent evt) {
+ String selectedValue = (String) evt.getNewValue();
+ if (selectedValue.equals("")) {
+ state = "No selected state";
+ } else {
+ state = selectedValue;
+ }
+ }
+
public List getSuggestions() {
List result = Arrays.asList(suggestions.split(","));
Collections.shuffle(result);
Modified: trunk/sandbox/samples/combobox-sample/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/sandbox/samples/combobox-sample/src/main/webapp/WEB-INF/web.xml 2008-01-10 15:17:02 UTC (rev 5271)
+++ trunk/sandbox/samples/combobox-sample/src/main/webapp/WEB-INF/web.xml 2008-01-10 15:17:54 UTC (rev 5272)
@@ -7,6 +7,10 @@
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param>
<context-param>
+ <param-name>org.ajax4jsf.SKIN</param-name>
+ <param-value>blueSky</param-value>
+ </context-param>
+ <context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
Modified: trunk/sandbox/samples/combobox-sample/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/sandbox/samples/combobox-sample/src/main/webapp/pages/index.jsp 2008-01-10 15:17:02 UTC (rev 5271)
+++ trunk/sandbox/samples/combobox-sample/src/main/webapp/pages/index.jsp 2008-01-10 15:17:54 UTC (rev 5272)
@@ -8,16 +8,17 @@
<body>
<f:view>
<h:form>
- <cmb:comboBox suggestionValues="#{bean.suggestions}"
- listWidth="300"
- listHeight="200"
- inputSize="30">
+ <cmb:comboBox value="#{bean.state}" valueChangeListener="#{bean.selectionChanged}" suggestionValues="#{bean.suggestions}" listWidth="150px">
<f:selectItems value="#{bean.selectItems}"/>
<f:selectItem itemValue="Oregon"/>
<f:selectItem itemValue="Pennsylvania"/>
<f:selectItem itemValue="Rhode Island"/>
<f:selectItem itemValue="South Carolina"/>
</cmb:comboBox>
+ <br/>
+ <h:commandButton action="none" value="submit"></h:commandButton>
+ <br>
+ <h:outputText value="Selected state is: #{bean.state}"></h:outputText>
</h:form>
</f:view>
</body>
17 years
JBoss Rich Faces SVN: r5271 - in trunk/sandbox/ui/combobox/src/main: java/org/richfaces/renderkit and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 10:17:02 -0500 (Thu, 10 Jan 2008)
New Revision: 5271
Modified:
trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
Log:
add "name" attribute for comboboxField input, add html_input* entities, format debug message
Modified: trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml
===================================================================
--- trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml 2008-01-10 14:54:33 UTC (rev 5270)
+++ trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml 2008-01-10 15:17:02 UTC (rev 5271)
@@ -221,8 +221,10 @@
<description></description>
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
-
+ &html_input_attributes;
+ &html_input_events;
&html_events;
+ &ui_input_attributes;
</properties>
</component>
</components>
Modified: trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
--- trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:54:33 UTC (rev 5270)
+++ trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 15:17:02 UTC (rev 5271)
@@ -58,7 +58,7 @@
}
if (InputUtils.isDisabled(comboBox) || InputUtils.isReadOnly(comboBox)) {
- if (logger.isTraceEnabled()) {
+ if (logger.isDebugEnabled()) {
logger.trace("No decoding necessary since the component "
+ component.getId() + " is disabled");
}
@@ -66,7 +66,7 @@
String clientId = component.getClientId(context);
if (clientId == null) {
- throw new NullPointerException("client id is null in component " + comboBox.getClientId(context));
+ throw new NullPointerException("component " + comboBox.getClientId(context) + " client id is NULL" );
}
clientId = "comboboxField" + clientId;
Modified: trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx 2008-01-10 14:54:33 UTC (rev 5270)
+++ trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx 2008-01-10 15:17:02 UTC (rev 5271)
@@ -62,7 +62,7 @@
</jsp:scriptlet>
<div id="#{clientId}" class="rich-combobox-font rich-combobox-shell" style="width:#{listWidth}">
- <input id="comboboxField#{clientId}" class="rich-combobox-font rich-combobox-input-default rich-combobox-input" type="text" value="#{value}" size="#{inputSize}" autocomplete="off" style="width:#{listWidth}">
+ <input id="comboboxField#{clientId}" name="comboboxField#{clientId}" class="rich-combobox-font rich-combobox-input-default rich-combobox-input" type="text" value="#{value}" size="#{inputSize}" autocomplete="off" style="width:#{listWidth}">
</input>
<input id="comboBoxButtonBG#{clientId}" readonly="true" type="text" value="" class="rich-combobox-font rich-combobox-button-background rich-combobox-button">
</input>
17 years
JBoss Rich Faces SVN: r5270 - management/design/progressBar.
by richfaces-svn-commits@lists.jboss.org
Author: smukhina
Date: 2008-01-10 09:54:33 -0500 (Thu, 10 Jan 2008)
New Revision: 5270
Modified:
management/design/progressBar/Func-Spec-ProgressBar.doc
Log:
RF-1689 - see spec revisions for details
Modified: management/design/progressBar/Func-Spec-ProgressBar.doc
===================================================================
(Binary files differ)
17 years
JBoss Rich Faces SVN: r5269 - trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 09:53:42 -0500 (Thu, 10 Jan 2008)
New Revision: 5269
Modified:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
Log:
Modified: trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
--- trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:53:18 UTC (rev 5268)
+++ trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:53:42 UTC (rev 5269)
@@ -9,7 +9,6 @@
import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
17 years
JBoss Rich Faces SVN: r5268 - trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 09:53:18 -0500 (Thu, 10 Jan 2008)
New Revision: 5268
Modified:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
Log:
refactor getConvertedStringValue method
Modified: trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
--- trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:33:35 UTC (rev 5267)
+++ trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:53:18 UTC (rev 5268)
@@ -155,16 +155,22 @@
protected String getConvertedStringValue(FacesContext context, UIComboBox comboBox, Object value) {
Converter converter = comboBox.getConverter();
+
if (converter == null) {
if (value == null) {
return "";
} else if (value instanceof String) {
return (String) value;
- } else {
- String message = "Value is not String (class=" + value.getClass().getName() + ", value=" + value
- + ") and component " + comboBox.getClientId(context) + " does not have a Converter";
- throw new IllegalArgumentException(message);
}
+
+ Class converterType = value.getClass();
+ if (converterType != null ) {
+ converter = context.getApplication().createConverter(converterType);
+ }
+
+ if (converter == null) {
+ return value.toString();
+ }
}
return converter.getAsString(context, comboBox, value);
}
17 years
JBoss Rich Faces SVN: r5267 - in trunk/sandbox/ui/combobox/src/main: templates and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 09:33:35 -0500 (Thu, 10 Jan 2008)
New Revision: 5267
Modified:
trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml
trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
Log:
rename disable->disabled, add encoding input value attribute
Modified: trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml
===================================================================
--- trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml 2008-01-10 14:30:18 UTC (rev 5266)
+++ trunk/sandbox/ui/combobox/src/main/config/component/combobox.xml 2008-01-10 14:33:35 UTC (rev 5267)
@@ -102,7 +102,7 @@
<defaultvalue><![CDATA[""]]></defaultvalue>
</property>
<property>
- <name>disable</name>
+ <name>disabled</name>
<classname>boolean</classname>
<description>make component disabled</description>
<defaultvalue>false</defaultvalue>
Modified: trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx 2008-01-10 14:30:18 UTC (rev 5266)
+++ trunk/sandbox/ui/combobox/src/main/templates/combobox.jspx 2008-01-10 14:33:35 UTC (rev 5267)
@@ -49,13 +49,20 @@
Boolean selectFirstOnUpdate = (Boolean) component.getAttributes().get("selectFirstOnUpdate");
variables.setVariable("selectFirstOnUpdate", selectFirstOnUpdate);
+
+ Object value = component.getAttributes().get("value");
+ if (value != null) {
+ value = getConvertedStringValue(context, component,value);
+ }
+ variables.setVariable("value", value);
+
]]>
</jsp:scriptlet>
<div id="#{clientId}" class="rich-combobox-font rich-combobox-shell" style="width:#{listWidth}">
- <input id="comboboxField#{clientId}" class="rich-combobox-font rich-combobox-input-default rich-combobox-input" type="text" size="#{inputSize}" autocomplete="off" style="width:#{listWidth}">
+ <input id="comboboxField#{clientId}" class="rich-combobox-font rich-combobox-input-default rich-combobox-input" type="text" value="#{value}" size="#{inputSize}" autocomplete="off" style="width:#{listWidth}">
</input>
<input id="comboBoxButtonBG#{clientId}" readonly="true" type="text" value="" class="rich-combobox-font rich-combobox-button-background rich-combobox-button">
</input>
17 years
JBoss Rich Faces SVN: r5266 - trunk/sandbox/ui/combobox/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 09:30:18 -0500 (Thu, 10 Jan 2008)
New Revision: 5266
Modified:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java
Log:
Modified: trunk/sandbox/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java
===================================================================
--- trunk/sandbox/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java 2008-01-10 14:29:50 UTC (rev 5265)
+++ trunk/sandbox/ui/combobox/src/main/java/org/richfaces/component/UIComboBox.java 2008-01-10 14:30:18 UTC (rev 5266)
@@ -13,7 +13,8 @@
public abstract class UIComboBox extends UIInput {
+
public abstract Object getSuggestionValues();
public abstract void setSuggestionValues(Object value);
-
-}
+
+}
\ No newline at end of file
17 years
JBoss Rich Faces SVN: r5265 - trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-01-10 09:29:50 -0500 (Thu, 10 Jan 2008)
New Revision: 5265
Modified:
trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
Log:
add decode, getConvertedValue method impl
Modified: trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
--- trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:11:05 UTC (rev 5264)
+++ trunk/sandbox/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-01-10 14:29:50 UTC (rev 5265)
@@ -5,20 +5,28 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
+import javax.el.ValueExpression;
import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
import javax.faces.model.SelectItem;
+import org.ajax4jsf.Messages;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSReference;
import org.ajax4jsf.javascript.ScriptString;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.util.InputUtils;
import org.ajax4jsf.util.SelectUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.richfaces.component.UIComboBox;
/**
@@ -30,11 +38,46 @@
public class ComboBoxBaseRenderer extends HeaderResourcesRendererBase {
private ArrayList <String> valuesList = null;
+ private static Log logger = LogFactory.getLog(ComboBoxBaseRenderer.class);
+
protected Class<UIComboBox> getComponentClass() {
return UIComboBox.class;
}
+ protected void doDecode(FacesContext context, UIComponent component) {
+ UIComboBox comboBox = null;
+
+ if (component instanceof UIComboBox) {
+ comboBox = (UIComboBox)component;
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No decoding necessary since the component "
+ + component.getId() + " is not an instance or a sub class of UIComboBox");
+ }
+ return;
+ }
+
+ if (InputUtils.isDisabled(comboBox) || InputUtils.isReadOnly(comboBox)) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("No decoding necessary since the component "
+ + component.getId() + " is disabled");
+ }
+ }
+
+ String clientId = component.getClientId(context);
+ if (clientId == null) {
+ throw new NullPointerException("client id is null in component " + comboBox.getClientId(context));
+ }
+
+ clientId = "comboboxField" + clientId;
+ Map request = context.getExternalContext().getRequestParameterMap();
+ if (request.containsKey(clientId)) {
+ String newValue = (String)request.get(clientId);
+ comboBox.setSubmittedValue(newValue);
+ }
+ }
+
public void encodeItems( FacesContext context, UIComponent component) throws IOException {
UIComboBox comboBox = (UIComboBox)component;
Object suggestionValues = comboBox.getSuggestionValues();
@@ -71,7 +114,43 @@
encodeSuggestion(writer, comboBox, value);
}
}
+ }
+ @Override
+ public Object getConvertedValue(FacesContext context, UIComponent component, Object submittedValue) throws ConverterException {
+ Object convertedValue = null;
+ UIComboBox comboBox = null;
+ String newValue = (String)submittedValue;
+
+ comboBox = (UIComboBox)component;
+
+ Converter converter = comboBox.getConverter();
+ ValueExpression valueExpression = component.getValueExpression("value");
+
+ if (converter == null) {
+ if (valueExpression != null) {
+ Class valueType = valueExpression.getType(context.getELContext());
+ if(valueType == null || String.class.equals(valueType) || Object.class.equals(valueType)){
+ if(logger.isDebugEnabled()) {
+ logger.debug("No conversion necessary for value " +
+ newValue + " of component " + component.getClientId(context));
+ }
+ } else {
+ converter = context.getApplication().createConverter(valueType);
+ if(converter == null){
+ throw new ConverterException(Messages.getMessage(Messages.NO_CONVERTER_FOUND_ERROR, valueType.getName()));
+ }
+ }
+
+ }
+ }
+
+ if(converter != null){
+ convertedValue = converter.getAsObject(context, component, newValue);
+ } else {
+ convertedValue = newValue;
+ }
+ return convertedValue;
}
protected String getConvertedStringValue(FacesContext context, UIComboBox comboBox, Object value) {
@@ -87,7 +166,6 @@
throw new IllegalArgumentException(message);
}
}
-
return converter.getAsString(context, comboBox, value);
}
@@ -121,12 +199,6 @@
result = function;
}
}
-
return ScriptUtils.toScript(result);
}
-
- @Override
- public boolean getRendersChildren() {
- return super.getRendersChildren();
- }
}
17 years