Author: nbelaevski
Date: 2008-04-04 16:41:53 -0400 (Fri, 04 Apr 2008)
New Revision: 7614
Modified:
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-2713
http://jira.jboss.com/jira/browse/RF-2344
Modified:
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
---
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2008-04-04
20:40:29 UTC (rev 7613)
+++
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2008-04-04
20:41:53 UTC (rev 7614)
@@ -23,7 +23,6 @@
import java.util.Map;
-import javax.el.MethodExpression;
import javax.faces.component.UIData;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
Modified:
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-04-04
20:40:29 UTC (rev 7613)
+++
branches/3.1.x/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-04-04
20:41:53 UTC (rev 7614)
@@ -51,6 +51,7 @@
import org.ajax4jsf.resource.TemplateCSSResource;
import org.richfaces.component.AjaxSuggestionEvent;
import org.richfaces.component.UISuggestionBox;
+import org.richfaces.component.util.HtmlUtil;
import org.richfaces.skin.Skin;
import org.richfaces.skin.SkinFactory;
@@ -81,6 +82,7 @@
*/
private final InternetResource[] additionalScripts = {
new org.ajax4jsf.javascript.PrototypeScript(),
+ getResource("/org/richfaces/renderkit/html/scripts/available.js"),
new org.ajax4jsf.javascript.SmartPositionScript(),
getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
getResource("scripts/scriptaculo.js"),
@@ -280,8 +282,18 @@
+ " not found in SuggestionBox " + component.getId());
}
} else {
- throw new FacesException("Component SuggestionBox "
- + component.getId() + " don't have property 'for'
");
+ UIComponent parent = component.getParent();
+ if (parent != null) {
+ if (HtmlUtil.shouldWriteId(parent)) {
+ return parent;
+ } else {
+ throw new FacesException("SuggestonBox cannot be attached to the
component with id = " + parent.getId() +
+ ", because a client identifier of the component won't be rendered
onto the page. Please, set the identifier.");
+ }
+ } else {
+ throw new FacesException("Parent component is null for SuggestionBox
" +
+ component.getId());
+ }
}
}
@@ -300,7 +312,8 @@
JSFunction submitSuggest = AjaxRendererUtils.buildAjaxFunction(
component, context, "RichFaces.Suggestion");
UIComponent targetComponent = getTarget(component);
- submitSuggest.addParameter(targetComponent.getClientId(context));
+ String targetId = targetComponent.getClientId(context);
+ submitSuggest.addParameter(targetId);
submitSuggest.addParameter(component.getClientId(context));
submitSuggest.addParameter(component.getAttributes().get("onsubmit"));
Map options = AjaxRendererUtils.buildEventOptions(context, component);
@@ -334,7 +347,8 @@
submitSuggest.addParameter(options);
script.append(submitSuggest.toScript()).append(";\n");
- return script.toString();
+
+ return "Richfaces.onAvailable('" + targetId + "',
function() {" + script.toString() + "});";
}
/**