Author: abelevich
Date: 2008-04-16 12:21:07 -0400 (Wed, 16 Apr 2008)
New Revision: 7876
Modified:
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/comboboxUtils.js
trunk/ui/combobox/src/main/templates/combobox.jspx
Log:
http://jira.jboss.com/jira/browse/RF-2956
Modified:
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java
===================================================================
---
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-16
15:27:42 UTC (rev 7875)
+++
trunk/ui/combobox/src/main/java/org/richfaces/renderkit/ComboBoxBaseRenderer.java 2008-04-16
16:21:07 UTC (rev 7876)
@@ -15,7 +15,6 @@
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.ScriptUtils;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
import org.ajax4jsf.util.InputUtils;
import org.ajax4jsf.util.SelectUtils;
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js
===================================================================
---
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-04-16
15:27:42 UTC (rev 7875)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/combobox.js 2008-04-16
16:21:07 UTC (rev 7876)
@@ -31,13 +31,12 @@
this.comboList = new Richfaces.ComboBoxList(listId, parentListId, selectFirstOnUpdate,
classes.COMBO_LIST, listWidth,
listHeight, itemsText, onlistcall, fieldId, shadowId, showDelay,
hideDelay);
this.defaultMessage = defaultMessage;
- // TODO: should we move this logic to the template?
- //
http://jira.jboss.com/jira/browse/RF-2956
if (value) {
var item = this.comboList.findItemBySubstr(value);
if (item) {
this.comboList.doSelectItem(item);
- this.comboValue.value = item.innerHTML.unescapeHTML();
+// initialize moved to the template
http://jira.jboss.com/jira/browse/RF-2956
+// this.comboValue.value = item.innerHTML.unescapeHTML();
}
} else {
if (this.defaultMessage) {
Modified:
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/comboboxUtils.js
===================================================================
---
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/comboboxUtils.js 2008-04-16
15:27:42 UTC (rev 7875)
+++
trunk/ui/combobox/src/main/resources/org/richfaces/renderkit/html/scripts/comboboxUtils.js 2008-04-16
16:21:07 UTC (rev 7876)
@@ -1,9 +1,33 @@
if (!window.Richfaces) window.Richfaces = {};
+if (!window.RichComboUtils) window.RichComboUtils = {};
Richfaces.defined = function(o) {
return (typeof(o)!="undefined");
};
+RichComboUtils.execOnLoad = function(func, condition, timeout) {
+
+ if (condition()) {
+ func();
+ } else {
+ window.setTimeout(
+ function() {
+ RichComboUtils.execOnLoad(func, condition, timeout);
+ },
+ timeout
+ );
+ }
+};
+
+RichComboUtils.Condition = {
+ ElementPresent : function(element) {
+ return function () {
+ var el = $(element);
+ return el && el.offsetHeight > 0;
+ };
+ }
+};
+
Richfaces.getBody = function() {
if (document.body) {
return document.body;
Modified: trunk/ui/combobox/src/main/templates/combobox.jspx
===================================================================
--- trunk/ui/combobox/src/main/templates/combobox.jspx 2008-04-16 15:27:42 UTC (rev 7875)
+++ trunk/ui/combobox/src/main/templates/combobox.jspx 2008-04-16 16:21:07 UTC (rev 7876)
@@ -205,7 +205,7 @@
<div id="#{clientId}">
<div id="#{clientId}combobox" class="rich-combobox-font rich-combobox
#{styleClass}" style="width:#{listWidth};#{style}"
x:passThruWithExclusions="value,name,type,id,styleClass,class,style,size,autocomplete,disabled,onchange">
- <input id="#{clientId}comboboxValue" name="#{clientId}"
type="hidden"/>
+
<div class="rich-combobox-list-cord"></div>
<div class="rich-combobox-font rich-combobox-shell"
style="width:#{width};z-index:1;">
<input id="#{clientId}comboboxField"
@@ -258,9 +258,25 @@
</div>
</div>
</div>
+ <jsp:scriptlet>
+ <![CDATA[
+
+ String hiddenValue = null;
+ if (items.contains(value)) {
+ variables.setVariable("hiddenValue", value);
+ }
+
+ ]]>
+ </jsp:scriptlet>
+ <input id="#{clientId}comboboxValue" name="#{clientId}"
type="hidden" value="#{hiddenValue}"/>
+
+
</div>
<script type="text/javascript">
+
+ var clientId = '#{clientId}';
+ RichComboUtils.execOnLoad( function(){
Richfaces.ComboBox.CLASSES = {
BUTTON : {CLASSES :
{NORMAL : "rich-combobox-font-inactive rich-combobox-button-icon-inactive
rich-combobox-button-inactive #{buttonInactiveClass}",
@@ -320,6 +336,7 @@
"#{defaultLabel}",
#{disabled}, #{convertedValue},
#{component.attributes["showDelay"]},
#{component.attributes["hideDelay"]});
+ }, RichComboUtils.Condition.ElementPresent("#{clientId}"), 100);
</script>
</div>
</f:root>
\ No newline at end of file