Author: alexsmirnov
Date: 2010-10-29 20:25:36 -0400 (Fri, 29 Oct 2010)
New Revision: 19792
Added:
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
Log:
CODING IN PROGRESS - issue RF-9216: CSV: server side development
https://jira.jboss.org/browse/RF-9216
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-10-29
23:11:21 UTC (rev 19791)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/component/behavior/ClientValidatorImpl.java 2010-10-30
00:25:36 UTC (rev 19792)
@@ -59,6 +59,7 @@
*
*/
public class ClientValidatorImpl extends AjaxBehavior implements ClientValidatorBehavior
{
+
private static final String VALUE = "value";
Modified:
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-29
23:11:21 UTC (rev 19791)
+++
branches/RF-8742/ui/validator/ui/src/main/java/org/richfaces/renderkit/html/ClientValidatorRenderer.java 2010-10-30
00:25:36 UTC (rev 19792)
@@ -67,6 +67,10 @@
}
}
+ @Override
+ public void decode(FacesContext context, UIComponent component, ClientBehavior
behavior) {
+ // TODO - properly set phase and re-render.
+ }
/**
* <p class="changed_added_4_0">
* This method builds client-side validation script and stores it in View resource
component
@@ -142,7 +146,7 @@
validatorScript = createValidatorScript(behaviorContext,
behavior, validators, clientSideConverterScript);
} catch (ScriptNotFoundException e) {
// ajax-only validation
- validatorScript = new
AjaxOnlyScript(behavior.getAjaxScript(behaviorContext));
+ validatorScript = new
AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
}
} else {
validatorScript = createValidatorScript(behaviorContext, behavior,
validators, null);
@@ -150,7 +154,7 @@
} catch (ConverterNotFoundException e) {
throw new FacesException(e);
}
- String clientId =
behaviorContext.getComponent().getClientId(behaviorContext.getFacesContext());
+ String clientId = getComponentClientId(behaviorContext);
String name = ScriptUtils.getValidJavascriptName(clientId+":v");
validatorScript.setName(name);
return validatorScript;
@@ -160,20 +164,33 @@
}
}
+ private String getComponentClientId(ClientBehaviorContext behaviorContext) {
+ return
behaviorContext.getComponent().getClientId(behaviorContext.getFacesContext());
+ }
+
private ValidatorScriptBase createValidatorScript(ClientBehaviorContext
behaviorContext,
ClientValidatorBehavior behavior, Collection<ValidatorDescriptor>
validators,
LibraryScriptString clientSideConverterScript) {
Collection<? extends LibraryScriptString> validatorScripts =
getClientSideValidatorScript(behaviorContext.getFacesContext(), validators);
if (validatorScripts.isEmpty()) {
- return new AjaxOnlyScript(behavior.getAjaxScript(behaviorContext));
+ return new AjaxOnlyScript(createAjaxScript(behaviorContext, behavior));
} else if (validatorScripts.size() < validators.size()) {
return new ClientAndAjaxScript(clientSideConverterScript, validatorScripts,
- behavior.getAjaxScript(behaviorContext));
+ createAjaxScript(behaviorContext, behavior));
} else {
return new ClientOnlyScript(clientSideConverterScript, validatorScripts);
}
}
+ private String createAjaxScript(ClientBehaviorContext behaviorContext,
ClientValidatorBehavior behavior) {
+ String ajaxScript = behavior.getAjaxScript(behaviorContext);
+ ajaxScript=ajaxScript.replace("this", "element");
+ String clientId = getComponentClientId(behaviorContext);
+
ajaxScript=ajaxScript.replace("'"+clientId+"'",ValidatorScriptBase.CLIENT_ID);
+
ajaxScript=ajaxScript.replace("\""+clientId+"\"",ValidatorScriptBase.CLIENT_ID);
+ return ajaxScript;
+ }
+
/**
* <p class="changed_added_4_0">
* Build client-side function call for Server-side component descriptor.
Added: branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
===================================================================
--- branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
(rev 0)
+++ branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml 2010-10-30
00:25:36 UTC (rev 19792)
@@ -0,0 +1,15 @@
+<?xml-stylesheet type="text/xsl" href=""?>
+<facelet-taglib
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd"
+ version="2.0">
+ <
namespace>http://richfaces.org/csv</namespace>
+
+ <tag>
+ <tag-name>validator</tag-name>
+ <behavior>
+ <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
+ </behavior>
+ </tag>
+
+</facelet-taglib>
Property changes on:
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/csv.taglib.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml
===================================================================
---
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-10-29
23:11:21 UTC (rev 19791)
+++
branches/RF-8742/ui/validator/ui/src/main/resources/META-INF/faces-config.xml 2010-10-30
00:25:36 UTC (rev 19792)
@@ -4,11 +4,19 @@
<component-type>org.richfaces.ValidatroScript</component-type>
<component-class>org.richfaces.component.UIValidatorScript</component-class>
</component>
+<behavior>
+ <behavior-id>org.richfaces.behavior.ClientValidator</behavior-id>
+
<behavior-class>org.richfaces.component.behavior.ClientValidatorImpl</behavior-class>
+</behavior>
<render-kit>
<renderer>
<component-family>org.richfaces.Script</component-family>
<renderer-type>org.richfaces.renderer.ValidatorScriptRenderer</renderer-type>
<renderer-class>org.richfaces.renderkit.html.ValidatorScriptRenderer</renderer-class>
</renderer>
+ <client-behavior-renderer>
+
<client-behavior-renderer-type>org.richfaces.ClientValidatorRenderer</client-behavior-renderer-type>
+
<client-behavior-renderer-class>org.richfaces.renderkit.html.ClientValidatorRenderer</client-behavior-renderer-class>
+ </client-behavior-renderer>
</render-kit>
</faces-config>
\ No newline at end of file