Author: pyaschenko
Date: 2008-03-31 07:17:07 -0400 (Mon, 31 Mar 2008)
New Revision: 7452
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
Log:
http://jira.jboss.com/jira/browse/RF-2872
Modified:
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
---
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-03-31
11:07:07 UTC (rev 7451)
+++
trunk/ui/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2008-03-31
11:17:07 UTC (rev 7452)
@@ -26,6 +26,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
import javax.faces.FacesException;
@@ -267,9 +268,15 @@
renderChild(context, popupFacet);
}
writer.endElement(HTML.DIV_ELEM);
+
+ writer.startElement(HTML.DIV_ELEM, component);
+ writer.writeAttribute("id", component.getClientId(context) +
"_script", null);
+ writer.writeAttribute("style", "display:none;", null);
writer.startElement(HTML.SCRIPT_ELEM, component);
writer.writeText(getScript(context, component), "script");
writer.endElement(HTML.SCRIPT_ELEM);
+ writer.endElement(HTML.DIV_ELEM);
+
writer.startElement("iframe", component);
writer.writeAttribute("src",
getResource("/org/richfaces/renderkit/html/images/spacer.gif")
@@ -309,14 +316,21 @@
final UIComponent component)
throws IOException {
UISuggestionBox suggestionBox = (UISuggestionBox) component;
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ Set<String> ajaxRenderedAreas = ajaxContext.getAjaxRenderedAreas();
+ String clientId = component.getClientId(context);
+
if (suggestionBox.isSubmitted()) {
body.encode(getTemplateContext(context, suggestionBox));
// Replace rendered area ID from component to suggestion table
suggestionBox.setRowIndex(-1);
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- ajaxContext.removeRenderedArea(component.getClientId(context));
+ ajaxContext.removeRenderedArea(clientId);
ajaxContext.addRenderedArea(getContentId(context, component));
}
+ else if (ajaxContext.isAjaxRequest() &&
ajaxRenderedAreas.contains(clientId))
+ {
+ ajaxRenderedAreas.add(clientId + "_script");
+ }
}
/**