Author: nbelaevski
Date: 2010-06-30 15:32:51 -0400 (Wed, 30 Jun 2010)
New Revision: 17690
Modified:
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
root/commons/trunk/api/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
Log:
https://jira.jboss.org/browse/RF-8744
Modified:
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java
===================================================================
---
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-06-30
19:18:06 UTC (rev 17689)
+++
root/commons/trunk/api/src/main/java/org/richfaces/renderkit/RenderKitUtils.java 2010-06-30
19:32:51 UTC (rev 17690)
@@ -353,16 +353,16 @@
}
}
- public static void decodeBehaviors(FacesContext context, UIComponent component) {
+ public static String decodeBehaviors(FacesContext context, UIComponent component) {
if (!(component instanceof ClientBehaviorHolder)) {
- return;
+ return null;
}
ClientBehaviorHolder holder = (ClientBehaviorHolder) component;
Map<String, List<ClientBehavior>> behaviors =
holder.getClientBehaviors();
if (behaviors == null || behaviors.isEmpty()) {
- return;
+ return null;
}
ExternalContext externalContext = context.getExternalContext();
@@ -370,7 +370,7 @@
String behaviorEvent = parametersMap.get(BEHAVIOR_EVENT_NAME);
if (behaviorEvent == null) {
- return;
+ return null;
}
List<ClientBehavior> behaviorsForEvent = behaviors.get(behaviorEvent);
@@ -378,12 +378,16 @@
String clientId = component.getClientId(context);
if (behaviorSource != null && behaviorSource.equals(clientId)) {
- if (behaviorsForEvent != null) {
+ if (behaviorsForEvent != null && !behaviorsForEvent.isEmpty()) {
for (ClientBehavior behavior : behaviorsForEvent) {
behavior.decode(context, component);
}
+
+ return behaviorEvent;
}
}
+
+ return null;
}
}
Modified:
root/commons/trunk/api/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java
===================================================================
---
root/commons/trunk/api/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-06-30
19:18:06 UTC (rev 17689)
+++
root/commons/trunk/api/src/test/java/org/richfaces/renderkit/RenderKitUtilsMocksTest.java 2010-06-30
19:32:51 UTC (rev 17690)
@@ -25,6 +25,8 @@
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.same;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
@@ -322,7 +324,7 @@
facesEnvironment.replay();
- RenderKitUtils.decodeBehaviors(facesContext, component);
+ assertEquals("action", RenderKitUtils.decodeBehaviors(facesContext,
component));
}
@Test
@@ -337,7 +339,7 @@
facesEnvironment.replay();
- RenderKitUtils.decodeBehaviors(facesContext, component);
+ assertEquals("blur", RenderKitUtils.decodeBehaviors(facesContext,
component));
}
@Test
@@ -348,7 +350,7 @@
facesEnvironment.replay();
- RenderKitUtils.decodeBehaviors(facesContext, component);
+ assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
}
@Test
@@ -359,7 +361,7 @@
facesEnvironment.replay();
- RenderKitUtils.decodeBehaviors(facesContext, component);
+ assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
}
@Test
@@ -370,6 +372,6 @@
facesEnvironment.replay();
- RenderKitUtils.decodeBehaviors(facesContext, component);
+ assertNull(RenderKitUtils.decodeBehaviors(facesContext, component));
}
}
\ No newline at end of file