JBoss Rich Faces SVN: r14755 - in branches/community/3.3.X/ui/suggestionbox/src/main: java/org/richfaces/renderkit/html and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2009-07-01 06:34:51 -0400 (Wed, 01 Jul 2009)
New Revision: 14755
Modified:
branches/community/3.3.X/ui/suggestionbox/src/main/config/component/suggestionbox.xml
branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
Log:
https://jira.jboss.org/jira/browse/RF-7450
Modified: branches/community/3.3.X/ui/suggestionbox/src/main/config/component/suggestionbox.xml
===================================================================
--- branches/community/3.3.X/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2009-06-30 15:42:23 UTC (rev 14754)
+++ branches/community/3.3.X/ui/suggestionbox/src/main/config/component/suggestionbox.xml 2009-07-01 10:34:51 UTC (rev 14755)
@@ -282,7 +282,7 @@
suggestion pop-up it is caused again
</description>
</property>
- <property required="true">
+ <property>
<name>width</name>
<classname>java.lang.String</classname>
<description>
@@ -290,7 +290,7 @@
</description>
<defaultvalue>"200"</defaultvalue>
</property>
- <property required="true">
+ <property>
<name>height</name>
<classname>java.lang.String</classname>
<description>
Modified: branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2009-06-30 15:42:23 UTC (rev 14754)
+++ branches/community/3.3.X/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2009-07-01 10:34:51 UTC (rev 14755)
@@ -45,6 +45,7 @@
import org.ajax4jsf.renderkit.RendererBase;
import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.ajax4jsf.renderkit.compiler.HtmlCompiler;
import org.ajax4jsf.renderkit.compiler.PreparedTemplate;
import org.ajax4jsf.renderkit.compiler.TemplateContext;
@@ -65,13 +66,6 @@
private static final Map<String, Pattern> tokensCache = new ReferenceMap<String, Pattern>();
/**
- * Component options.
- */
- private static final String[] OPTIONS = {"popupClass", "popupStyle",
- "width", "height", "entryClass", "selectedClass", "param",
- "frequency", "minChars", "tokens", "rows", "selectValueClass", "useSuggestObjects" };
-
- /**
* Shadow depth.
*/
public static final int SHADOW_DEPTH = 4;
@@ -390,65 +384,42 @@
component, context, "RichFaces.Suggestion");
submitSuggest.addParameter(targetId);
submitSuggest.addParameter(component.getClientId(context));
- submitSuggest.addParameter(component.getAttributes().get("onsubmit"));
Map<String, Object> options = AjaxRendererUtils.buildEventOptions(context, component, true);
- options.put("popup", component.getClientId(context));
- for (int i = 0; i < OPTIONS.length; i++) {
- String option = OPTIONS[i];
- Object value = attributes.get(option);
-
- if(option.equals("entryClass") && isDefOptionValue(value)) {
- value = "richfaces_suggestionEntry";
- }
-
- if(option.equals("selectValueClass") && isDefOptionValue(value)) {
- value = "richfaces_suggestionSelectValue";
- }
-
- if (null != value) {
- if (!"frequency".equals(option) || ((Double) value).doubleValue() > 1E-9) {
-
- options.put(option, value);
- }
- }
- }
+
+ getUtils().addToScriptHash(options, "onsubmit", attributes.get("onsubmit"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "popupClass", attributes.get("popupClass"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "popupStyle", attributes.get("popupStyle"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "width", attributes.get("width"), "200" , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "height", attributes.get("height"), "200" , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "entryClass", attributes.get("entryClass"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "selectedClass", attributes.get("selectedClass"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "param", attributes.get("param"), "inputvalue" , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "frequency", attributes.get("frequency"), "0.4" , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "minChars", attributes.get("minChars"), "0" , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "tokens", attributes.get("tokens"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "selectValueClass", attributes.get("selectValueClass"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "usingSuggestObjects", attributes.get("usingSuggestObjects"), null , ScriptHashVariableWrapper.DEFAULT);
+ getUtils().addToScriptHash(options, "zindex", attributes.get("zindex"), "200" , ScriptHashVariableWrapper.DEFAULT);
+
// If implicit ajax queue name not set, put clientId
String implicitEventsQueue = (String) options.get("implicitEventsQueue");
if (null == implicitEventsQueue) {
options.put("implicitEventsQueue", component.getClientId(context));
}
+
String onselect = (String) attributes.get("onselect");
if (null != onselect) {
- JSFunctionDefinition function = new JSFunctionDefinition("suggestion");
- function.addParameter("event");
+ JSFunctionDefinition function = new JSFunctionDefinition("suggestion","event");
function.addToBody(onselect);
-
options.put("onselect", function);
-
}
String onobjectchange = (String) attributes.get("onobjectchange");
if (null != onobjectchange) {
JSFunctionDefinition function = new JSFunctionDefinition("suggestion","event");
function.addToBody(onobjectchange);
-
options.put("onobjectchange", function);
-
}
- if (component.getValueBinding("fetchValue") != null
- || attributes.get("fetchValue") != null) {
- Object select = attributes.get("selectValueClass");
- if (isDefOptionValue(select)) {
- select = "richfaces_suggestionSelectValue";
- }
- options.put("select", select);
- }
-
- UISuggestionBox suggestionBox = (UISuggestionBox) component;
- options.put("usingSuggestObjects", suggestionBox.isUsingSuggestObjects());
- // pass "zindex" attribute to js though the "options" attribute
- options.put("zindex", suggestionBox.getZindex());
-
submitSuggest.addParameter(options);
script.append(submitSuggest.toScript()).append(";\n");
return "Richfaces.onAvailable('" + targetId + "', function() {" + script.toString() + "});";
Modified: branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js
===================================================================
--- branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2009-06-30 15:42:23 UTC (rev 14754)
+++ branches/community/3.3.X/ui/suggestionbox/src/main/resources/org/richfaces/renderkit/html/scripts/suggestionbox.js 2009-07-01 10:34:51 UTC (rev 14755)
@@ -970,23 +970,43 @@
}
+Richfaces.SuggestionBox = {}
+Richfaces.SuggestionBox.defaultOptions = {
+ popupClass: '',
+ popupStyle: '',
+ width: 200,
+ height: 200,
+ entryClass: 'richfaces_suggestionEntry',
+ selectedClass: '',
+ param: 'inputvalue',
+ frequency: 0.4,
+ minChars: 0,
+ tokens: null,
+ selectValueClass: 'richfaces_suggestionSelectValue',
+ usingSuggestObjects: false,
+ zindex: 200
+}
RichFaces.Suggestion = Class.create();
Object.extend(Object.extend(RichFaces.Suggestion.prototype, Suggestion.Base.prototype), {
- initialize: function(actionUrl, element, content, onsubmit, options) {
- var update = options.popup || 'ac1update';
- if (!$(update)) this.create(element, update, content, options);
- this.baseInitialize(element, update, options);
+ initialize: function(actionUrl, element, content, options) {
+
+ this.options = Object.clone(Richfaces.SuggestionBox.defaultOptions);
+ Object.extend(this.options, options);
+
+ var update = content || 'ac1update';
+ if (!$(update)) this.create(element, update, content, this.options);
+ this.baseInitialize(element, update, this.options);
this.options.asynchronous = true;
- this.options.onajaxcomplete = options.oncomplete;
+ this.options.onajaxcomplete = this.options.oncomplete;
this.options.oncomplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
this.content = content;
this.contentTable = content+":suggest";
this.actionUrl = actionUrl;
- if (onsubmit && onsubmit != 'null'){
- this.onsubmitFunction = new Function(onsubmit+';return true;').bind(this.element);
+ if (this.options.onsubmit && this.options.onsubmit != 'null'){
+ this.onsubmitFunction = new Function(this.options.onsubmit+';return true;').bind(this.element);
}
this.update.component = this;
15 years, 6 months