Author: pyaschenko
Date: 2011-01-24 11:57:46 -0500 (Mon, 24 Jan 2011)
New Revision: 21181
Modified:
trunk/examples/misc-demo/pom.xml
trunk/examples/misc-demo/src/main/webapp/index.jsp
trunk/ui/misc/ui/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java
trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/component-control.js
Log:
http://jira.jboss.com/jira/browse/RF-10080
Modified: trunk/examples/misc-demo/pom.xml
===================================================================
--- trunk/examples/misc-demo/pom.xml 2011-01-24 16:46:58 UTC (rev 21180)
+++ trunk/examples/misc-demo/pom.xml 2011-01-24 16:57:46 UTC (rev 21181)
@@ -47,6 +47,10 @@
<groupId>org.richfaces.ui.misc</groupId>
<artifactId>richfaces-ui-misc-ui</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.richfaces.ui.input</groupId>
+ <artifactId>richfaces-ui-input-ui</artifactId>
+ </dependency>
<!-- todo remove this dependency -->
<dependency>
<groupId>org.richfaces.ui.core</groupId>
Modified: trunk/examples/misc-demo/src/main/webapp/index.jsp
===================================================================
--- trunk/examples/misc-demo/src/main/webapp/index.jsp 2011-01-24 16:46:58 UTC (rev
21180)
+++ trunk/examples/misc-demo/src/main/webapp/index.jsp 2011-01-24 16:57:46 UTC (rev
21181)
@@ -6,6 +6,7 @@
<body>
<a href="pages/index.jsf">Facelets</a><br />
+ <a href="pages/componentControl.jsf">componentControl dev
sample</a><br />
</body>
</html>
\ No newline at end of file
Modified:
trunk/ui/misc/ui/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java
===================================================================
---
trunk/ui/misc/ui/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java 2011-01-24
16:46:58 UTC (rev 21180)
+++
trunk/ui/misc/ui/src/main/java/org/richfaces/component/behavior/ComponentControlBehavior.java 2011-01-24
16:57:46 UTC (rev 21181)
@@ -49,7 +49,7 @@
private List<UIComponent> children;
enum PropertyKeys {
- event, target, selector, operation
+ event, target, selector, operation, onbeforeoperation
}
public List<UIComponent> getChildren() {
@@ -94,6 +94,15 @@
public void setOperation(String operation) {
getStateHelper().put(PropertyKeys.operation, operation);
}
+
+ @Attribute
+ public String getOnbeforeoperation() {
+ return (String) getStateHelper().eval(PropertyKeys.onbeforeoperation);
+ }
+
+ public void setOnbeforeoperation(String onbeforeoperation) {
+ getStateHelper().put(PropertyKeys.onbeforeoperation, onbeforeoperation);
+ }
@Override
public String getRendererType() {
@@ -108,6 +117,8 @@
setTarget((String) value);
} else if (compare(PropertyKeys.selector, name)) {
setSelector((String) value);
+ } else if (compare(PropertyKeys.onbeforeoperation, name)) {
+ setOnbeforeoperation((String) value);
}
}
}
Modified:
trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java
===================================================================
---
trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2011-01-24
16:46:58 UTC (rev 21180)
+++
trunk/ui/misc/ui/src/main/java/org/richfaces/renderkit/ComponentControlBehaviorRenderer.java 2011-01-24
16:57:46 UTC (rev 21181)
@@ -75,6 +75,8 @@
private static final String PARAM_TARGET = "target";
private static final String PARAM_SELECTOR = "selector";
+
+ private static final String PARAM_ONBEFOREOPERATION = "onbeforeoperation";
private static final Pattern COMMA_SEPARATED_STRING =
Pattern.compile("\\s*,\\s*");
@@ -106,6 +108,13 @@
parameters.put(PARAM_CALLBACK, callback);
parameters.put(PARAM_TARGET, resolveTargets(facesContext, targetSourceString));
parameters.put(PARAM_SELECTOR, selector);
+
+ String onBeforeOperation = controlBehavior.getOnbeforeoperation();
+ if (null!=onBeforeOperation && !onBeforeOperation.isEmpty()) {
+ JSFunctionDefinition onBeforeOperationFunction = new JSFunctionDefinition(new
JSReference(REF_EVENT));
+ onBeforeOperationFunction.addToBody(onBeforeOperation);
+ parameters.put(PARAM_ONBEFOREOPERATION, onBeforeOperationFunction);
+ }
// execution function
JSFunction eventFunction = new JSFunction(FUNC_NAME);
Modified:
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/component-control.js
===================================================================
---
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/component-control.js 2011-01-24
16:46:58 UTC (rev 21180)
+++
trunk/ui/misc/ui/src/main/resources/META-INF/resources/org.richfaces/component-control.js 2011-01-24
16:57:46 UTC (rev 21181)
@@ -11,6 +11,11 @@
var selector = parameters.selector;
var callback = parameters.callback;
+ if (parameters.onbeforeoperation && typeof parameters.onbeforeoperation ==
"function") {
+ var result = parameters.onbeforeoperation(event);
+ if (result=="false" || result==0) return;
+ }
+
if (targetList) {
for (var i = 0; i < targetList.length; i++) {
var component = document.getElementById(targetList[i]);