Author: mvitenkov
Date: 2008-07-15 14:23:04 -0400 (Tue, 15 Jul 2008)
New Revision: 9625
Modified:
trunk/test-applications/jsp/src/main/java/validator/ValidatorBean.java
trunk/test-applications/jsp/src/main/webapp/Validator/Validator.jsp
trunk/test-applications/jsp/src/main/webapp/WEB-INF/faces-config-Validator.xml
trunk/test-applications/jsp/src/main/webapp/WEB-INF/web.xml
Log:
Modified: trunk/test-applications/jsp/src/main/java/validator/ValidatorBean.java
===================================================================
--- trunk/test-applications/jsp/src/main/java/validator/ValidatorBean.java 2008-07-15
17:56:39 UTC (rev 9624)
+++ trunk/test-applications/jsp/src/main/java/validator/ValidatorBean.java 2008-07-15
18:23:04 UTC (rev 9625)
@@ -1,16 +1,37 @@
package validator;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.validator.Validator;
-import javax.faces.validator.ValidatorException;
+import javax.faces.component.UIMessages;
-public class ValidatorBean implements Validator {
+import org.hibernate.validator.CreditCardNumber;
+import org.hibernate.validator.Email;
- public void validate(FacesContext context, UIComponent component,
- Object value) throws ValidatorException {
- // TODO Auto-generated method stub
+public class ValidatorBean {
+ @Email(message="not a valid email value!")
+ private String mailValue;
+ @CreditCardNumber(message="not a valid credit card number")
+ private String creditValue;
+ public String getCreditValue() {
+ return creditValue;
}
+ public void setCreditValue(String creditValue) {
+ this.creditValue = creditValue;
+ }
+
+ public String getMailValue() {
+ return mailValue;
+ }
+
+ public ValidatorBean(){
+ this.mailValue = "";
+ this.creditValue = "";
+ }
+ public String getMailDescription() {
+ return "E-mail validation:";
+ }
+
+ public String getCreditDescription() {
+ return "Credit card validation:";
+ }
}
Modified: trunk/test-applications/jsp/src/main/webapp/Validator/Validator.jsp
===================================================================
--- trunk/test-applications/jsp/src/main/webapp/Validator/Validator.jsp 2008-07-15
17:56:39 UTC (rev 9624)
+++ trunk/test-applications/jsp/src/main/webapp/Validator/Validator.jsp 2008-07-15
18:23:04 UTC (rev 9625)
@@ -3,5 +3,61 @@
<%@ taglib
uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib
uri="http://richfaces.org/rich" prefix="rich"%>
<f:subview id="validatorSubviewID">
-<div style="FONT-WEIGHT:bold;">Insert rich:validator</div>
+ <rich:panel>
+ <f:facet name="header">
+ <h:outputText>Single input field with label and message. Validated by AJAX on
every changing.</h:outputText>
+ </f:facet>
+ <h:outputLabel for="ltext" value="#{lengthBean.textDescription}"
/>
+ <h:inputText id="ltext" value="#{lengthBean.text}">
+ <rich:ajaxValidator event="onchange" />
+ </h:inputText>
+ <rich:message for="ltext" showDetail="true"
showSummary="true" />
+ </rich:panel>
+ <h2>Input fields with label and message in the JSF dataTable. Each
+ field validated by AJAX on "onchange" event</h2>
+ <rich:graphValidator value="#{data}">
+ <rich:dataTable value="#{data.beans}" var="bean"
id="table">
+ <f:facet name="header">
+ <h:outputText
+ value="Validate values in the data table. Total sum for an all integer values
validated for a value less then 20" />
+ </f:facet>
+
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="text field" />
+ </f:facet>
+ <h:outputLabel for="text" value="#{bean.textDescription}"
/>
+ <h:inputText id="text" value="#{bean.text}">
+ <rich:ajaxValidator event="onchange" />
+ </h:inputText>
+ <rich:message for="text" showDetail="true"
showSummary="true" />
+ </h:column>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="integer field" />
+ </f:facet>
+ <h:outputLabel for="intValue" value="#{bean.intDescription}"
/>
+ <h:inputText id="intValue" value="#{bean.intValue}">
+ <rich:ajaxValidator event="onchange" />
+ </h:inputText>
+ <rich:message for="intValue" showDetail="true"
showSummary="true" />
+ </h:column>
+ <f:facet name="footer">
+ <h:panelGroup>
+ <h:outputText>in addition to fields validation, total sum for an all integer
values validated for a value less then 20.</h:outputText>
+ <h:commandButton value="Submit all fields"></h:commandButton>
+ </h:panelGroup>
+ </f:facet>
+ </rich:dataTable>
+ </rich:graphValidator>
+ <br />
+
+
+ <h:panelGroup>
+ <h:outputLabel for="mailValue"
value="#{validator.mailDescription}" />
+ <h:inputText value="#{validator.someValue}" id="mailValue">
+ <rich:ajaxValidator event="onchange"></rich:ajaxValidator>
+ </h:inputText>
+ <rich:message for="mailValue" showDetail="true"
showSummary="true" />
+ </h:panelGroup>
</f:subview>
\ No newline at end of file
Modified: trunk/test-applications/jsp/src/main/webapp/WEB-INF/faces-config-Validator.xml
===================================================================
---
trunk/test-applications/jsp/src/main/webapp/WEB-INF/faces-config-Validator.xml 2008-07-15
17:56:39 UTC (rev 9624)
+++
trunk/test-applications/jsp/src/main/webapp/WEB-INF/faces-config-Validator.xml 2008-07-15
18:23:04 UTC (rev 9625)
@@ -3,6 +3,21 @@
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
<faces-config>
<managed-bean>
+ <managed-bean-name>bean</managed-bean-name>
+ <managed-bean-class>validator.Bean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>data</managed-bean-name>
+ <managed-bean-class>validator.DataBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
+ <managed-bean-name>lengthBean</managed-bean-name>
+ <managed-bean-class>validator.LengthBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
+<managed-bean>
<managed-bean-name>validator</managed-bean-name>
<managed-bean-class>validator.ValidatorBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
Modified: trunk/test-applications/jsp/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/test-applications/jsp/src/main/webapp/WEB-INF/web.xml 2008-07-15 17:56:39 UTC
(rev 9624)
+++ trunk/test-applications/jsp/src/main/webapp/WEB-INF/web.xml 2008-07-15 18:23:04 UTC
(rev 9625)
@@ -20,7 +20,7 @@
</context-param>
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
-
<param-value>/WEB-INF/faces-config-ComponentInfo.xml,/WEB-INF/faces-config-HotKey.xml,/WEB-INF/faces-config-DataTable.xml,/WEB-INF/faces-config-SimpleTogglePanel.xml,/WEB-INF/faces-config-Panel.xml,/WEB-INF/faces-config-PanelBar.xml,/WEB-INF/faces-config-TabPanel.xml,/WEB-INF/faces-config-TogglePanel.xml,/WEB-INF/faces-config-Paint2D.xml,/WEB-INF/faces-config-InputNumberSlider.xml,/WEB-INF/faces-config-InputNumberSpinner.xml,/WEB-INF/faces-config-DDMenu.xml,/WEB-INF/faces-config-Tree.xml,/WEB-INF/faces-config-PanelMenu.xml,/WEB-INF/faces-config-Icon.xml,/WEB-INF/faces-config-ModalPanel.xml,/WEB-INF/faces-config-tooltip.xml,/WEB-INF/faces-config-Skin.xml,/WEB-INF/faces-config-Calendar.xml,/WEB-INF/faces-config-Gmap.xml,/WEB-INF/faces-config-DataFilterSlider.xml,/WEB-INF/faces-config-Separator.xml,/WEB-INF/faces-config-Spacer.xml,/WEB-INF/faces-config-ToolBar.xml,/WEB-INF/faces-config-DataScroller.xml,/WEB-INF/faces-config-SuggestionBox.xml,/WEB-INF/faces-config-Message.xml!
,/WEB-INF/faces-config-VirtualEarth.xml,/WEB-INF/faces-config-Effect.xml,/WEB-INF/faces-config-Insert.xml,/WEB-INF/faces-config-RichBean.xml,/WEB-INF/faces-config-ScrollableDataTable.xml,/WEB-INF/faces-config-jQuery.xml,/WEB-INF/faces-config-DragAndDrop.xml,/WEB-INF/faces-config-OrderingList.xml,/WEB-INF/faces-config-DataOrderedList.xml,/WEB-INF/faces-config-DataDefinitionList.xml,/WEB-INF/faces-config-ContextMenu.xml,/WEB-INF/faces-config-ListShuttle.xml,/WEB-INF/faces-config-Converter.xml,/WEB-INF/faces-config-ComponentControl.xml,/WEB-INF/faces-config-Columns.xml,/WEB-INF/faces-config-PickList.xml,/WEB-INF/faces-config-Combobox.xml,/WEB-INF/faces-config-PTComponent.xml,/WEB-INF/faces-config-Event.xml,/WEB-INF/faces-config-ProgressBar.xml,/WEB-INF/faces-config-Options.xml,/WEB-INF/faces-config-SortingAndFiltering.xml,/WEB-INF/faces-config-Style.xml,/WEB-INF/faces-config-FileUpload.xml,/WEB-INF/faces-config-InplaceSelect.xml,/WEB-INF/faces-config-InplaceInput.xml,/WEB-INF/!
faces-config-Skinning.xml,/WEB-INF/faces-config-Custom.xml</param-valu
e>
+
<param-value>/WEB-INF/faces-config-Validator.xml,/WEB-INF/faces-config-ComponentInfo.xml,/WEB-INF/faces-config-HotKey.xml,/WEB-INF/faces-config-DataTable.xml,/WEB-INF/faces-config-SimpleTogglePanel.xml,/WEB-INF/faces-config-Panel.xml,/WEB-INF/faces-config-PanelBar.xml,/WEB-INF/faces-config-TabPanel.xml,/WEB-INF/faces-config-TogglePanel.xml,/WEB-INF/faces-config-Paint2D.xml,/WEB-INF/faces-config-InputNumberSlider.xml,/WEB-INF/faces-config-InputNumberSpinner.xml,/WEB-INF/faces-config-DDMenu.xml,/WEB-INF/faces-config-Tree.xml,/WEB-INF/faces-config-PanelMenu.xml,/WEB-INF/faces-config-Icon.xml,/WEB-INF/faces-config-ModalPanel.xml,/WEB-INF/faces-config-tooltip.xml,/WEB-INF/faces-config-Skin.xml,/WEB-INF/faces-config-Calendar.xml,/WEB-INF/faces-config-Gmap.xml,/WEB-INF/faces-config-DataFilterSlider.xml,/WEB-INF/faces-config-Separator.xml,/WEB-INF/faces-config-Spacer.xml,/WEB-INF/faces-config-ToolBar.xml,/WEB-INF/faces-config-DataScroller.xml,/WEB-INF/faces-config-SuggestionBox.x!
ml,/WEB-INF/faces-config-Message.xml,/WEB-INF/faces-config-VirtualEarth.xml,/WEB-INF/faces-config-Effect.xml,/WEB-INF/faces-config-Insert.xml,/WEB-INF/faces-config-RichBean.xml,/WEB-INF/faces-config-ScrollableDataTable.xml,/WEB-INF/faces-config-jQuery.xml,/WEB-INF/faces-config-DragAndDrop.xml,/WEB-INF/faces-config-OrderingList.xml,/WEB-INF/faces-config-DataOrderedList.xml,/WEB-INF/faces-config-DataDefinitionList.xml,/WEB-INF/faces-config-ContextMenu.xml,/WEB-INF/faces-config-ListShuttle.xml,/WEB-INF/faces-config-Converter.xml,/WEB-INF/faces-config-ComponentControl.xml,/WEB-INF/faces-config-Columns.xml,/WEB-INF/faces-config-PickList.xml,/WEB-INF/faces-config-Combobox.xml,/WEB-INF/faces-config-PTComponent.xml,/WEB-INF/faces-config-Event.xml,/WEB-INF/faces-config-ProgressBar.xml,/WEB-INF/faces-config-Options.xml,/WEB-INF/faces-config-SortingAndFiltering.xml,/WEB-INF/faces-config-Style.xml,/WEB-INF/faces-config-FileUpload.xml,/WEB-INF/faces-config-InplaceSelect.xml,/WEB-INF/fac!
es-config-InplaceInput.xml,/WEB-INF/faces-config-Skinning.xml,/WEB-INF
/faces-config-Custom.xml</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>