Author: nbelaevski
Date: 2009-04-20 19:32:12 -0400 (Mon, 20 Apr 2009)
New Revision: 13713
Modified:
trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx
trunk/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
Log:
https://jira.jboss.org/jira/browse/RF-2302
Modified: trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx
===================================================================
--- trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx 2009-04-20
22:48:43 UTC (rev 13712)
+++ trunk/ui/componentControl/src/main/templates/htmlComponentControl.jspx 2009-04-20
23:32:12 UTC (rev 13713)
@@ -49,7 +49,7 @@
<jsp:scriptlet><![CDATA[ } ]]></jsp:scriptlet>
-<jsp:scriptlet><![CDATA[ if (! "#".equals(attachTo) ) { ]]>
+<jsp:scriptlet><![CDATA[ if (attachTo != null &&
attachTo.trim().length() != 0 && !"#".equals(attachTo)) { ]]>
attachEventAccordingToTimingOption(context, component);
<![CDATA[ } ]]>
</jsp:scriptlet>
Modified:
trunk/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java
===================================================================
---
trunk/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java 2009-04-20
22:48:43 UTC (rev 13712)
+++
trunk/ui/componentControl/src/test/java/org/richfaces/component/ComponentControlTest.java 2009-04-20
23:32:12 UTC (rev 13713)
@@ -35,6 +35,7 @@
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlInput;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlScript;
/**
* Unit test for simple Component.
@@ -113,34 +114,45 @@
eventStringParams(eventString);
}
- public void testAttachString() throws Exception {
- HtmlPage page = renderView();
+ public void testAttachStringEmpty() throws Exception {
+ HtmlPage page = renderView();
assertNotNull(page);
- List<?> scripts = page.getHtmlElementsByName("script");
- String attachTo = componentControl.getAttachTo();
- assertTrue("If on componentControl defined attachTo attr, on page must be
presented attach script",
- scripts.isEmpty() && (attachTo == null || attachTo.length() ==
0));
+ List<?> scripts = page.getByXPath("//script");
String eventString = null;
for (Object obj : scripts) {
HtmlElement element = (HtmlElement) obj;
- if
(element.asText().contains("Richfaces.componentControl.attachEvent")) {
- eventString = element.asText();
+ if
(element.asXml().contains("Richfaces.componentControl.attachEvent")) {
+ eventString = element.asXml();
break;
}
}
- if (attachTo == null || attachTo.length() == 0) {
- assertNull(eventString);
- } else {
- assertNotNull(eventString);
-
assertTrue(eventString.contains("Richfaces.componentControl.attachEvent"));
-
- eventStringParams(eventString);
+ assertNull(eventString);
+ }
+
+ public void testAttachString() throws Exception {
+ this.componentControl.setAttachTo("#output");
+
+ HtmlPage page = renderView();
+ assertNotNull(page);
+
+ List<?> scripts = page.getByXPath("//script");
+ assertFalse(scripts.isEmpty());
+
+ String eventString = null;
+ for (Object obj : scripts) {
+ HtmlScript element = (HtmlScript) obj;
+ if
(element.asXml().contains("Richfaces.componentControl.attachEvent")) {
+ eventString = element.asXml();
+ break;
+ }
}
+
+ assertNotNull(eventString);
}
-
+
private void eventStringParams(String eventString) {
String [] params = eventString.split(",");
assertEquals(6, params.length);