You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gp...@apache.org on 2009/11/13 03:48:58 UTC
svn commit: r835712 [18/19] - in
/myfaces/extensions/validator/branches/branch_for_jsf_2_0: ./ assembly/
assembly/src/ assembly/src/main/ assembly/src/main/assembly/
assembly/src/main/resources/ component-support/
component-support/generic-support/ com...
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_en.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_en.properties?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_en.properties (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_en.properties Fri Nov 13 02:48:45 2009
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+duplicated_content_required=Input is different
+duplicated_content_required_detail=Input is different
+
+duplicated_content_denied=Same input isn't allowed
+duplicated_content_denied_detail=Same input isn't allowed
+
+wrong_date=Wrong date
+wrong_date_detail=Wrong date
+
+wrong_date_not_before=Date has to be after {0}
+wrong_date_not_before_detail=Date has to be after {0}
+
+wrong_date_not_after=Date has to be before {0}
+wrong_date_not_after_detail=Date has to be before {0}
+
+wrong_date_not_equal=Date isn't equal to {0}
+wrong_date_not_equal_detail=Date isn't equal to {0}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_es.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_es.properties?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_es.properties (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_es.properties Fri Nov 13 02:48:45 2009
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+duplicated_content_required=la entrada es diferente
+duplicated_content_required_detail=la entrada es diferente
+
+duplicated_content_denied=no se permiten entradas iguales
+duplicated_content_denied_detail=no se permiten entradas iguales
+
+wrong_date=fecha equivocada
+wrong_date_detail=fecha equivocada
+
+wrong_date_not_before=la fecha tiene que ser luego de {0}
+wrong_date_not_before_detail=la fecha tiene que ser luego de {0}
+
+wrong_date_not_after=la fecha tiene que ser antes de {0}
+wrong_date_not_after_detail=la fecha tiene que ser antes de {0}
+
+wrong_date_not_equal=la fecha no es igual a {0}
+wrong_date_not_equal_detail=la fecha no es igual a {0}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_fr.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_fr.properties?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_fr.properties (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_fr.properties Fri Nov 13 02:48:45 2009
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+duplicated_content_required=Les champs sont différents
+duplicated_content_required_detail=Les champs sont différents
+
+duplicated_content_denied=Les champs doivent être différents
+duplicated_content_denied_detail=Les champs doivent être différents
+
+wrong_date=La date est incorrecte
+wrong_date_detail=La date est incorrecte
+
+wrong_date_not_before=La date doit être après {0}
+wrong_date_not_before_detail=La date doit être après {0}
+
+wrong_date_not_after=La date doit être avant {0}
+wrong_date_not_after_detail=La date doit être avant {0}
+
+wrong_date_not_equal=La date n'est pas égale à {0}
+wrong_date_not_equal_detail=La date n'est pas égale à {0}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_it.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_it.properties?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_it.properties (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_it.properties Fri Nov 13 02:48:45 2009
@@ -0,0 +1,34 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+duplicated_content_required=Valori non uguali
+duplicated_content_required_detail=I valori inseriti non coincidono
+
+duplicated_content_denied=Lo stesso valore non è permesso
+duplicated_content_denied_detail=Lo stesso valore non è permesso
+
+wrong_date=Data errata
+wrong_date_detail=Data errata
+
+wrong_date_not_before=La data deve essere dopo di {0}
+wrong_date_not_before_detail=La data deve essere dopo di {0}
+
+wrong_date_not_after=La data deve essere prima di {0}
+wrong_date_not_after_detail=La data deve essere prima di {0}
+
+wrong_date_not_equal=La data non è uguale a {0}
+wrong_date_not_equal_detail=La data non è uguale a {0}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_tr.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_tr.properties?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_tr.properties (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/bundle/validation_messages_tr.properties Fri Nov 13 02:48:45 2009
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+
+duplicated_content_required=girilen de\u011fer farkl\u0131
+duplicated_content_required_detail=girilen de\u011fer farkl\u0131
+
+duplicated_content_denied=ayn\u0131 de\u011fer girilemez
+duplicated_content_denied_detail=ayn\u0131 de\u011fer girilemez
+
+wrong_date=yanl\u0131\u015f tarih
+wrong_date_detail=yanl\u0131\u015f tarih
+
+wrong_date_not_before=tarih {0} de\u011ferinden sonra olmal\u0131d\u0131r
+wrong_date_not_before_detail=tarih {0} de\u011ferinden sonra olmal\u0131d\u0131r
+
+wrong_date_not_after=tarih {0} de\u011ferinden \u00f6nce olmal\u0131d\u0131r
+wrong_date_not_after_detail=tarih {0} de\u011ferinden \u00f6nce olmal\u0131d\u0131r
+
+wrong_date_not_equal=tarih {0} de\u011ferine e\u015fit de\u011fil
+wrong_date_not_equal_detail=tarih {0} de\u011ferine e\u015fit de\u011fil
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.message.resolver;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultValidationErrorMessageResolver
+ extends
+ org.apache.myfaces.extensions.validator.core.validation.message.resolver.DefaultValidationErrorMessageResolver
+{
+ private static String baseName = null;
+
+ @Override
+ protected String getBaseName()
+ {
+ if (baseName == null)
+ {
+ baseName = super.getBaseName();
+ }
+
+ return baseName;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/recorder/CrossValidationUserInputRecorder.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.recorder;
+
+import org.apache.myfaces.extensions.validator.core.recorder.ProcessedInformationRecorder;
+import org.apache.myfaces.extensions.validator.core.property.PropertyDetails;
+import org.apache.myfaces.extensions.validator.crossval.storage.ProcessedInformationStorageEntry;
+import org.apache.myfaces.extensions.validator.crossval.storage.ProcessedInformationStorage;
+import org.apache.myfaces.extensions.validator.util.CrossValidationUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.context.FacesContext;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class CrossValidationUserInputRecorder implements ProcessedInformationRecorder
+{
+ public void recordUserInput(UIComponent uiComponent, Object value)
+ {
+ if (!(uiComponent instanceof EditableValueHolder))
+ {
+ return;
+ }
+
+ //to support local cross-validation (within the same entity)
+ ProcessedInformationStorage processedInformationStorage = CrossValidationUtils
+ .getOrInitProcessedInformationStorage();
+
+ ProcessedInformationStorageEntry entry;
+
+ PropertyDetails propertyDetails =
+ ExtValUtils.getELHelper().getPropertyDetailsOfValueBinding(uiComponent);
+
+ if(propertyDetails == null)
+ {
+ return;
+ }
+
+ entry = new ProcessedInformationStorageEntry();
+ entry.setBean(propertyDetails.getBaseObject());
+ entry.setConvertedValue(value);
+ entry.setComponent(uiComponent);
+ entry.setClientId(uiComponent.getClientId(FacesContext.getCurrentInstance()));
+
+ String key = propertyDetails.getKey();
+
+ //for local cross-validation
+ if (processedInformationStorage.containsEntry(key) &&
+ processedInformationStorage.getEntry(key).getBean() != null &&
+ !processedInformationStorage.getEntry(key).getBean().equals(entry.getBean()))
+ {
+ //for the validation within a complex component e.g. a table
+ //don't override existing expression (style: #{entry.property}) - make a special mapping
+
+ List<ProcessedInformationStorageEntry> furtherEntries =
+ processedInformationStorage.getEntry(key).getFurtherEntries();
+
+ if (furtherEntries == null)
+ {
+ furtherEntries = new ArrayList<ProcessedInformationStorageEntry>();
+
+ processedInformationStorage.getEntry(key).setFurtherEntries(furtherEntries);
+ }
+
+ furtherEntries.add(entry);
+ }
+ else
+ {
+ //for normal validation
+ processedInformationStorage.setEntry(key, entry);
+ }
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.util.List;
+
+/**
+ * normally it should be in the storage package - due to backward compatibility it isn't the case
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface CrossValidationStorage
+{
+ void add(CrossValidationStorageEntry entry);
+
+ List<CrossValidationStorageEntry> getCrossValidationStorageEntries();
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorageEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorageEntry.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorageEntry.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/CrossValidationStorageEntry.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.crossval.strategy.CrossValidationStrategy;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * normally it should be in the storage package - due to backward compatibility it isn't the case
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public class CrossValidationStorageEntry
+{
+ private MetaDataEntry metaDataEntry;
+ //for complex components (e.g. a table) stores the object of entry (#{entry.property})
+ private UIComponent component;
+ private Object convertedObject;
+ private CrossValidationStrategy validationStrategy;
+ //just for input components within complex components e.g. dataTable,...
+ private String clientId;
+
+ public MetaDataEntry getMetaDataEntry()
+ {
+ return metaDataEntry;
+ }
+
+ public void setMetaDataEntry(MetaDataEntry metaDataEntry)
+ {
+ this.metaDataEntry = metaDataEntry;
+ }
+
+ public UIComponent getComponent()
+ {
+ return component;
+ }
+
+ public void setComponent(UIComponent component)
+ {
+ this.component = component;
+ }
+
+ public Object getConvertedObject()
+ {
+ return convertedObject;
+ }
+
+ public void setConvertedObject(Object convertedObject)
+ {
+ this.convertedObject = convertedObject;
+ }
+
+ public CrossValidationStrategy getValidationStrategy()
+ {
+ return validationStrategy;
+ }
+
+ public void setValidationStrategy(CrossValidationStrategy validationStrategy)
+ {
+ this.validationStrategy = validationStrategy;
+ }
+
+ public String getClientId()
+ {
+ return clientId;
+ }
+
+ public void setClientId(String clientId)
+ {
+ this.clientId = clientId;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultCrossValidationStorage implements CrossValidationStorage
+{
+ private List<CrossValidationStorageEntry> crossValidationStorageEntries =
+ new ArrayList<CrossValidationStorageEntry>();
+
+ public void add(CrossValidationStorageEntry entry)
+ {
+ this.crossValidationStorageEntries.add(entry);
+ }
+
+ public List<CrossValidationStorageEntry> getCrossValidationStorageEntries()
+ {
+ return crossValidationStorageEntries;
+ }
+
+ public void setCrossValidationStorageEntries(List<CrossValidationStorageEntry> crossValidationStorageEntries)
+ {
+ this.crossValidationStorageEntries = crossValidationStorageEntries;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultCrossValidationStorageManager.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.core.storage.AbstractRequestScopeAwareStorageManager;
+
+/**
+ * default storage-manager for cross-validation entries
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultCrossValidationStorageManager
+ extends AbstractRequestScopeAwareStorageManager<CrossValidationStorage>
+{
+ public String getStorageManagerKey()
+ {
+ //for better backward compatibility
+ return CrossValidationStorage.class.getName();
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class DefaultProcessedInformationStorage implements ProcessedInformationStorage
+{
+ private Map<String, ProcessedInformationStorageEntry> processedInformationMap =
+ new HashMap<String, ProcessedInformationStorageEntry>();
+
+ public void setEntry(String key, ProcessedInformationStorageEntry entry)
+ {
+ this.processedInformationMap.put(key, entry);
+ }
+
+ public boolean containsEntry(String key)
+ {
+ return processedInformationMap.containsKey(key);
+ }
+
+ public ProcessedInformationStorageEntry getEntry(String key)
+ {
+ return processedInformationMap.get(key);
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/DefaultProcessedInformationStorageManager.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.core.storage.AbstractRequestScopeAwareStorageManager;
+import org.apache.myfaces.extensions.validator.util.CrossValidationUtils;
+
+/**
+ * default storage-manager for processed information entries
+ *
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(INTERNAL)
+public class DefaultProcessedInformationStorageManager
+ extends AbstractRequestScopeAwareStorageManager<CrossValidationStorage>
+{
+ public String getStorageManagerKey()
+ {
+ //for better backward compatibility
+ return CrossValidationUtils.class.getName();
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorage.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorage.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorage.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.API;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@UsageInformation(API)
+public interface ProcessedInformationStorage
+{
+ void setEntry(String key, ProcessedInformationStorageEntry entry);
+
+ boolean containsEntry(String key);
+
+ ProcessedInformationStorageEntry getEntry(String key);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorageEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorageEntry.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorageEntry.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/ProcessedInformationStorageEntry.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage;
+
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+
+import javax.faces.component.UIComponent;
+import java.util.List;
+
+/**
+ * In order to build up a mapping which is used for cross-validation.
+ *
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public class ProcessedInformationStorageEntry
+{
+ private Object bean;
+ private Object convertedValue;
+ private UIComponent component;
+ //for complex components (e.g. a table there are multiple entries with
+ //the same key (here the el expression #{entry.property})
+ //however, don't override the previous entry - they arn't the same;
+ private List<ProcessedInformationStorageEntry> furtherEntries;
+ //just for input components within complex components e.g. dataTable,...
+ private String clientId;
+
+ /*
+ * generated
+ */
+ public Object getBean()
+ {
+ return bean;
+ }
+
+ public void setBean(Object bean)
+ {
+ this.bean = bean;
+ }
+
+ public Object getConvertedValue()
+ {
+ return convertedValue;
+ }
+
+ public void setConvertedValue(Object convertedValue)
+ {
+ this.convertedValue = convertedValue;
+ }
+
+ public UIComponent getComponent()
+ {
+ return component;
+ }
+
+ public void setComponent(UIComponent component)
+ {
+ this.component = component;
+ }
+
+ public String getClientId()
+ {
+ return clientId;
+ }
+
+ public void setClientId(String clientId)
+ {
+ this.clientId = clientId;
+ }
+
+ public List<ProcessedInformationStorageEntry> getFurtherEntries()
+ {
+ return furtherEntries;
+ }
+
+ public void setFurtherEntries(List<ProcessedInformationStorageEntry> furtherEntries)
+ {
+ this.furtherEntries = furtherEntries;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/CrossValidationStorageNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/CrossValidationStorageNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/CrossValidationStorageNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/CrossValidationStorageNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorage;
+import org.apache.myfaces.extensions.validator.crossval.storage.DefaultCrossValidationStorage;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(200)
+@UsageInformation(INTERNAL)
+public class CrossValidationStorageNameMapper implements NameMapper<String>
+{
+ public String createName(String key)
+ {
+ return (CrossValidationStorage.class.getName().equals(key)) ?
+ DefaultCrossValidationStorage.class.getName() : null;
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/ProcessedInformationStorageNameMapper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/ProcessedInformationStorageNameMapper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/ProcessedInformationStorageNameMapper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/storage/mapper/ProcessedInformationStorageNameMapper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.storage.mapper;
+
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import static org.apache.myfaces.extensions.validator.internal.UsageCategory.INTERNAL;
+import org.apache.myfaces.extensions.validator.core.mapper.NameMapper;
+import org.apache.myfaces.extensions.validator.core.InvocationOrder;
+import org.apache.myfaces.extensions.validator.crossval.storage.ProcessedInformationStorage;
+import org.apache.myfaces.extensions.validator.crossval.storage.DefaultProcessedInformationStorage;
+
+/**
+ * @author Gerhard Petracek
+ * @since x.x.3
+ */
+@InvocationOrder(200)
+@UsageInformation(INTERNAL)
+public class ProcessedInformationStorageNameMapper implements NameMapper<String>
+{
+ public String createName(String key)
+ {
+ return (ProcessedInformationStorage.class.getName().equals(key)) ?
+ DefaultProcessedInformationStorage.class.getName() : null;
+ }
+}
\ No newline at end of file
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCompareStrategy.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,305 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.strategy;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.lang.annotation.Annotation;
+
+import javax.faces.application.FacesMessage;
+import javax.faces.validator.ValidatorException;
+
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorage;
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorageEntry;
+import org.apache.myfaces.extensions.validator.util.ClassUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.core.ExtValContext;
+import org.apache.myfaces.extensions.validator.core.CustomInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@SuppressWarnings({"unchecked"})
+@UsageInformation(UsageCategory.INTERNAL)
+public abstract class AbstractCompareStrategy<A extends Annotation> extends AbstractCrossValidationStrategy
+{
+ protected static List<ReferencingStrategy> referencingStrategies;
+ protected Map<Object, Object> violationResultStorage = new HashMap<Object, Object>();
+
+ public AbstractCompareStrategy()
+ {
+ initReferencingStrategies();
+ }
+
+ protected void initReferencingStrategies()
+ {
+ if (referencingStrategies == null)
+ {
+ referencingStrategies = new ArrayList<ReferencingStrategy>();
+
+ String customReferencingStrategyClassName =
+ ExtValContext.getContext().getInformationProviderBean()
+ .get(CustomInformation.BASE_PACKAGE) + "ReferencingStrategy";
+
+ ReferencingStrategy customReferencingStrategy = (ReferencingStrategy) ClassUtils
+ .tryToInstantiateClassForName(customReferencingStrategyClassName);
+
+ if (customReferencingStrategy != null)
+ {
+ referencingStrategies.add(customReferencingStrategy);
+ }
+
+ referencingStrategies.add(new ELCompareStrategy());
+ //referencingStrategies.add(new AliasCompareStrategy());
+ referencingStrategies.add(new LocalCompareStrategy());
+ referencingStrategies.add(new LocalPropertyChainCompareStrategy());
+ }
+ }
+
+ public void processCrossValidation(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorage crossValidationStorage) throws ValidatorException
+ {
+ //initCrossValidation is done in the CrossValidationPhaseListener
+
+ String[] validationTargets = getValidationTargets((A)
+ crossValidationStorageEntry.getMetaDataEntry().getValue());
+
+ for (String validationTarget : validationTargets)
+ {
+ validationTarget = validationTarget.trim();
+
+ //select validation method
+ tryToValidate(crossValidationStorageEntry, crossValidationStorage, validationTarget);
+ }
+ }
+
+ private boolean tryToValidate(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorage crossValidationStorage,
+ String validationTarget)
+ {
+ for (ReferencingStrategy referencingStrategy : referencingStrategies)
+ {
+ if (referencingStrategy.evaluateReferenceAndValidate(
+ crossValidationStorageEntry, crossValidationStorage, validationTarget, this))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @SuppressWarnings({"ThrowableInstanceNeverThrown"})
+ protected final void processTargetComponentAfterViolation(
+ CrossValidationStorageEntry entryOfSource,
+ CrossValidationStorageEntry entryOfTarget)
+ {
+ if (!handleTargetViolation(entryOfSource, entryOfTarget))
+ {
+ //no target - because there is no target component - value was validated against the model
+ if(entryOfTarget == null)
+ {
+ processTargetComponentAsSourceComponentAfterViolation(entryOfSource);
+ return;
+ }
+
+ return;
+ }
+
+ //get validation error messages for the target component
+ String summary = getErrorMessageSummary((A)entryOfSource.getMetaDataEntry().getValue(), true);
+ String details = getErrorMessageDetail((A)entryOfSource.getMetaDataEntry().getValue(), true);
+
+ //validation target isn't bound to a component withing the current page
+ //(see validateFoundEntry, tryToValidateLocally and tryToValidateBindingOnly)
+ if (entryOfTarget == null)
+ {
+ entryOfTarget = entryOfSource;
+ }
+
+ FacesMessage message;
+ if (entryOfTarget.getMetaDataEntry() != null)
+ {
+ message = getTargetComponentErrorMessage((A)entryOfTarget.getMetaDataEntry().getValue(), summary, details);
+ }
+ else
+ {
+ //TODO document possible side effects
+ //due to a missing target annotation (see: tryToValidateLocally)
+ message = getTargetComponentErrorMessage((A)entryOfSource.getMetaDataEntry().getValue(), summary, details);
+ }
+
+ if ((message.getSummary() != null || message.getDetail() != null) &&
+ entryOfSource.getClientId() != null && !entryOfSource.getClientId().equals(entryOfTarget.getClientId()))
+ {
+ ValidatorException validatorException = new ValidatorException(message);
+
+ if(ExtValUtils.executeAfterThrowingInterceptors(
+ entryOfTarget.getComponent(), entryOfTarget.getMetaDataEntry(),
+ entryOfTarget.getConvertedObject(), validatorException, this))
+ {
+ ExtValUtils.tryToAddViolationMessageForComponentId(entryOfTarget.getClientId(),
+ ExtValUtils.convertFacesMessage(validatorException.getFacesMessage()));
+ }
+ }
+ }
+
+ private void processTargetComponentAsSourceComponentAfterViolation(CrossValidationStorageEntry entryOfSource)
+ {
+ //get validation error messages for the current component
+ String summary = getReverseErrorMessageSummary((A)entryOfSource.getMetaDataEntry().getValue());
+ String details = getReverseErrorMessageDetail((A)entryOfSource.getMetaDataEntry().getValue());
+
+ FacesMessage message = getSourceComponentErrorMessage(
+ (A)entryOfSource.getMetaDataEntry().getValue(), summary, details);
+
+ if (message.getSummary() != null || message.getDetail() != null)
+ {
+ //TODO
+ ExtValUtils.tryToThrowValidatorExceptionForComponent(entryOfSource.getComponent(), message, null);
+ }
+ else
+ {
+ //TODO logging
+ }
+ }
+
+ protected final void processSourceComponentAfterViolation(CrossValidationStorageEntry entryOfSource)
+ {
+ if (handleSourceViolation(entryOfSource))
+ {
+ //get validation error messages for the current component
+ String summary = getErrorMessageSummary((A)entryOfSource.getMetaDataEntry().getValue(), false);
+ String details = getErrorMessageDetail((A)entryOfSource.getMetaDataEntry().getValue(), false);
+
+ FacesMessage message = getSourceComponentErrorMessage(
+ (A)entryOfSource.getMetaDataEntry().getValue(), summary, details);
+
+ if (message.getSummary() != null || message.getDetail() != null)
+ {
+ //TODO
+ ExtValUtils.tryToThrowValidatorExceptionForComponent(entryOfSource.getComponent(), message, null);
+ }
+ }
+
+ //just throw a new message - the error message is at the target
+ ExtValUtils.tryToThrowValidatorExceptionForComponent(
+ entryOfSource.getComponent(), new FacesMessage(FacesMessage.SEVERITY_ERROR, null, null), null);
+ }
+
+ protected FacesMessage getSourceComponentErrorMessage(A annotation, String summary, String detail)
+ {
+ return ExtValUtils.createFacesMessage(summary, detail);
+ }
+
+ protected FacesMessage getTargetComponentErrorMessage(A foundAnnotation, String summary, String detail)
+ {
+ return ExtValUtils.createFacesMessage(summary, detail);
+ }
+
+ protected String getErrorMessageSummary(A annotation, boolean isTargetComponent)
+ {
+ return resolveMessage(getValidationErrorMsgKey(annotation, isTargetComponent));
+ }
+
+ protected String getErrorMessageDetail(A annotation, boolean isTargetComponent)
+ {
+ try
+ {
+ String key = getValidationErrorMsgKey(annotation, isTargetComponent);
+ return (key != null) ? resolveMessage(key + DETAIL_MESSAGE_KEY_POSTFIX) : null;
+ }
+ catch (MissingResourceException e)
+ {
+ if(logger.isWarnEnabled())
+ {
+ logger.warn("couldn't find key " + getValidationErrorMsgKey(annotation, isTargetComponent)
+ + DETAIL_MESSAGE_KEY_POSTFIX, e);
+ }
+ }
+ return null;
+ }
+
+ protected final String getValidationErrorMsgKey(Annotation annotation)
+ {
+ return getValidationErrorMsgKey((A)annotation, false);
+ }
+
+ protected boolean handleTargetViolation(
+ CrossValidationStorageEntry entryOfSource,
+ CrossValidationStorageEntry entryOfTarget)
+ {
+ return entryOfTarget != null && entryOfTarget.getComponent() != null;
+ }
+
+ protected boolean handleSourceViolation(CrossValidationStorageEntry entryOfSource)
+ {
+ return true;
+ }
+
+ protected boolean useTargetComponentToDisplayErrorMsg(CrossValidationStorageEntry crossValidationStorageEntry)
+ {
+ return handleTargetViolation(crossValidationStorageEntry, null);
+ }
+
+ /*
+ * no target component (validation against the model) -> get reverse message for source component
+ */
+ protected String getReverseErrorMessageSummary(A annotation)
+ {
+ //if the message is neutral
+ return getErrorMessageSummary(annotation, true);
+ }
+
+ /*
+ * no target component (validation against the model) -> get reverse message for source component
+ */
+ protected String getReverseErrorMessageDetail(A annotation)
+ {
+ //if the message is neutral
+ return getErrorMessageDetail(annotation, true);
+ }
+
+ /*
+ * abstract methods
+ */
+
+ protected abstract String getValidationErrorMsgKey(A annotation, boolean isTargetComponent);
+
+ /*
+ * implements the specific validation logic
+ */
+
+ public abstract boolean isViolation(Object object1, Object object2, A annotation);
+
+ /*
+ * returns the referenced validation targets of the annotation
+ * e.g. @DateIs(type = DateIsType.before, value = "finalExam")
+ * -> method returns an array with one value ("finalExam")
+ */
+ public abstract String[] getValidationTargets(A annotation);
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/AbstractCrossValidationStrategy.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.strategy;
+
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.AbstractAnnotationValidationStrategy;
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorageEntry;
+import org.apache.myfaces.extensions.validator.util.CrossValidationUtils;
+import org.apache.myfaces.extensions.validator.util.ExtValUtils;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+public abstract class AbstractCrossValidationStrategy extends
+ AbstractAnnotationValidationStrategy implements CrossValidationStrategy
+{
+ //init cross-validation
+ public void processValidation(FacesContext facesContext,
+ UIComponent uiComponent, MetaDataEntry metaDataEntry, Object convertedObject) throws ValidatorException
+ {
+ CrossValidationStorageEntry entry =
+ getCrossValidationStorageEntry(facesContext, uiComponent, metaDataEntry, convertedObject);
+
+ CrossValidationUtils.getOrInitCrossValidationStorage().add(entry);
+ }
+
+ public CrossValidationStorageEntry getCrossValidationStorageEntry(
+ FacesContext facesContext, UIComponent uiComponent,
+ MetaDataEntry metaDataEntry, Object convertedObject)
+ {
+ CrossValidationStorageEntry entry = new CrossValidationStorageEntry();
+
+ entry.setMetaDataEntry(metaDataEntry);
+ entry.setComponent(uiComponent);
+ entry.setClientId(uiComponent.getClientId(facesContext));
+ entry.setConvertedObject(convertedObject);
+ entry.setValidationStrategy(this);
+
+ return entry;
+ }
+
+ @Override
+ protected final boolean processAfterValidatorException(FacesContext facesContext,
+ UIComponent uiComponent,
+ MetaDataEntry metaDataEntry,
+ Object convertedObject,
+ ValidatorException validatorException)
+ {
+ throw new IllegalStateException("not available for cross validation - use processAfterCrossValidatorException");
+ }
+
+ @Override
+ protected final String getLabel(FacesContext facesContext, UIComponent uiComponent, MetaDataEntry metaDataEntry)
+ {
+ throw new IllegalStateException("not available for cross validation");
+ }
+
+ @Override
+ protected final void initValidation(FacesContext facesContext,
+ UIComponent uiComponent,
+ MetaDataEntry metaDataEntry,
+ Object convertedObject)
+ {
+ //not available for cross validation - use initCrossValidation
+ }
+
+ protected void initCrossValidation(CrossValidationStorageEntry crossValidationStorageEntry)
+ {
+ //override if needed
+ }
+
+ //override if needed
+ protected boolean processAfterCrossValidatorException(CrossValidationStorageEntry crossValidationStorageEntry,
+ ValidatorException validatorException)
+ {
+ return ExtValUtils.executeAfterThrowingInterceptors(
+ crossValidationStorageEntry.getComponent(), crossValidationStorageEntry.getMetaDataEntry(),
+ crossValidationStorageEntry.getConvertedObject(), validatorException, this);
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationHelper.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationHelper.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationHelper.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationHelper.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.strategy;
+
+import org.apache.myfaces.extensions.validator.crossval.storage.ProcessedInformationStorageEntry;
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorageEntry;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.INTERNAL)
+class CrossValidationHelper
+{
+ public static void crossValidateCompareStrategy(AbstractCompareStrategy compareStrategy,
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ ProcessedInformationStorageEntry validationTargetEntry,
+ boolean isModelAwareValidation)
+ {
+ if (compareStrategy.isViolation(
+ crossValidationStorageEntry.getConvertedObject(),
+ validationTargetEntry.getConvertedValue(),
+ crossValidationStorageEntry.getMetaDataEntry().getValue(Annotation.class)))
+ {
+ //process after violation
+ //just add messages
+ if(!isModelAwareValidation)
+ {
+ processTargetAfterCrossComponentValidation(
+ compareStrategy, crossValidationStorageEntry, validationTargetEntry);
+ }
+ else
+ {
+ processTargetAfterModelAwareCrossValidation(
+ compareStrategy, crossValidationStorageEntry);
+ }
+
+ //thow exception
+ compareStrategy.processSourceComponentAfterViolation(crossValidationStorageEntry);
+ }
+ }
+
+ private static void processTargetAfterCrossComponentValidation(
+ AbstractCompareStrategy compareStrategy,
+ CrossValidationStorageEntry sourceCrossValidationStorageEntry,
+ ProcessedInformationStorageEntry validationTargetEntry)
+ {
+ CrossValidationStorageEntry targetCrossValidationStorageEntry = new CrossValidationStorageEntry();
+
+ if (compareStrategy.useTargetComponentToDisplayErrorMsg(sourceCrossValidationStorageEntry))
+ {
+ targetCrossValidationStorageEntry.setComponent(validationTargetEntry.getComponent());
+ targetCrossValidationStorageEntry.setClientId(validationTargetEntry.getClientId());
+ }
+ else
+ {
+ targetCrossValidationStorageEntry.setComponent(sourceCrossValidationStorageEntry.getComponent());
+ targetCrossValidationStorageEntry.setClientId(sourceCrossValidationStorageEntry.getClientId());
+ }
+
+ targetCrossValidationStorageEntry.setConvertedObject(validationTargetEntry.getConvertedValue());
+ targetCrossValidationStorageEntry.setValidationStrategy(compareStrategy);
+
+ //add message
+ compareStrategy.processTargetComponentAfterViolation(
+ sourceCrossValidationStorageEntry, targetCrossValidationStorageEntry);
+ }
+
+ private static void processTargetAfterModelAwareCrossValidation(
+ AbstractCompareStrategy compareStrategy,
+ CrossValidationStorageEntry crossValidationStorageEntry)
+ {
+ //no target - because there is no target component - value was validated against the model
+ compareStrategy.processTargetComponentAfterViolation(crossValidationStorageEntry, null);
+ }
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationStrategy.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationStrategy.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/CrossValidationStrategy.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.strategy;
+
+import org.apache.myfaces.extensions.validator.core.metadata.MetaDataEntry;
+import org.apache.myfaces.extensions.validator.core.validation.strategy.ValidationStrategy;
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorage;
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorageEntry;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.validator.ValidatorException;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@UsageInformation(UsageCategory.API)
+public interface CrossValidationStrategy extends ValidationStrategy
+{
+ CrossValidationStorageEntry getCrossValidationStorageEntry(
+ FacesContext facesContext, UIComponent uiComponent,
+ MetaDataEntry metaDataEntry, Object convertedObject);
+
+ void processCrossValidation(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorage crossValidationStorage)
+ throws ValidatorException;
+}
Added: myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java?rev=835712&view=auto
==============================================================================
--- myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java (added)
+++ myfaces/extensions/validator/branches/branch_for_jsf_2_0/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/strategy/DateIsStrategy.java Fri Nov 13 02:48:45 2009
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.extensions.validator.crossval.strategy;
+
+import org.apache.myfaces.extensions.validator.crossval.storage.CrossValidationStorageEntry;
+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIs;
+import org.apache.myfaces.extensions.validator.crossval.annotation.DateIsType;
+import org.apache.myfaces.extensions.validator.baseval.annotation.SkipValidationSupport;
+import org.apache.myfaces.extensions.validator.internal.UsageInformation;
+import org.apache.myfaces.extensions.validator.internal.UsageCategory;
+
+import javax.faces.context.FacesContext;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.MissingResourceException;
+
+/**
+ * @author Gerhard Petracek
+ * @since 1.x.1
+ */
+@SkipValidationSupport
+@UsageInformation(UsageCategory.INTERNAL)
+public class DateIsStrategy extends AbstractCompareStrategy<DateIs>
+{
+ protected static final String TOO_EARLY = "early";
+ protected static final String TOO_LATE = "late";
+ protected static final String NOT_EQUAL_DATE_TIME = "not equal";
+ protected static final String RESULT_KEY = "result";
+ protected static final String COMPARED_VALUE_KEY = "target value";
+ protected static final String REVERSE_COMPARED_VALUE_KEY = "reverse target value";
+
+ @Override
+ public boolean useTargetComponentToDisplayErrorMsg(
+ CrossValidationStorageEntry crossValidationStorageEntry)
+ {
+ return true;
+ }
+
+ //TODO test & remove
+ @Override
+ protected boolean handleSourceViolation(CrossValidationStorageEntry entryOfSource)
+ {
+ return false;
+ }
+
+ public boolean isViolation(Object object1, Object object2, DateIs annotation)
+ {
+ boolean violationFound;
+
+ if (annotation.type().equals(DateIsType.same))
+ {
+ violationFound = object1 != null && !object1.equals(object2);
+
+ if (violationFound)
+ {
+ this.violationResultStorage.put(RESULT_KEY, NOT_EQUAL_DATE_TIME);
+ }
+ }
+ else if (annotation.type().equals(DateIsType.before))
+ {
+ violationFound = object1 != null && object2 != null &&
+ (!new Date(((Date) object1).getTime()).before((Date) object2) || object1.equals(object2));
+
+ if (violationFound)
+ {
+ this.violationResultStorage.put(RESULT_KEY, TOO_LATE);
+ }
+ }
+ else
+ {
+ violationFound = object1 != null && object2 != null &&
+ (!new Date(((Date) object1).getTime()).after((Date) object2) || object1.equals(object2));
+
+ if (violationFound)
+ {
+ this.violationResultStorage.put(RESULT_KEY, TOO_EARLY);
+ }
+ }
+
+ if (violationFound)
+ {
+ this.violationResultStorage.put(COMPARED_VALUE_KEY, object1);
+ this.violationResultStorage.put(REVERSE_COMPARED_VALUE_KEY, object2);
+ }
+
+ return violationFound;
+ }
+
+ public String[] getValidationTargets(DateIs annotation)
+ {
+ return annotation.valueOf();
+ }
+
+ /*
+ * protected
+ */
+ protected String getValidationErrorMsgKey(DateIs annotation, boolean isTargetComponent)
+ {
+ String result = (String) this.violationResultStorage.get(RESULT_KEY);
+
+ if (!isTargetComponent)
+ {
+ result = reverseResult(result);
+ }
+
+ if (TOO_EARLY.equals(result))
+ {
+ return getNotAfterErrorMsgKey(annotation);
+ }
+ else if (TOO_LATE.equals(result))
+ {
+ return getNotBeforeErrorMsgKey(annotation);
+ }
+ else
+ {
+ return getNotEqualErrorMsgKey(annotation);
+ }
+ }
+
+ private String reverseResult(String result)
+ {
+ if (TOO_EARLY.equals(result))
+ {
+ return TOO_LATE;
+ }
+ else
+ {
+ return TOO_EARLY;
+ }
+ }
+
+ @Override
+ protected String getErrorMessageSummary(DateIs annotation, boolean isTargetComponent)
+ {
+ if (!isTargetComponent)
+ {
+ return super.getErrorMessageSummary(annotation, isTargetComponent);
+ }
+
+ return getErrorMessage(getValidationErrorMsgKey(annotation, isTargetComponent), annotation, isTargetComponent);
+ }
+
+ @Override
+ protected String getErrorMessageDetail(DateIs annotation, boolean isTargetComponent)
+ {
+ if (!isTargetComponent)
+ {
+ return super.getErrorMessageDetail(annotation, isTargetComponent);
+ }
+
+ try
+ {
+ return getErrorMessage(getValidationErrorMsgKey(annotation, isTargetComponent)
+ + DETAIL_MESSAGE_KEY_POSTFIX, annotation, isTargetComponent);
+ }
+ catch (MissingResourceException e)
+ {
+ if(logger.isWarnEnabled())
+ {
+ logger.warn("couldn't find key " + getValidationErrorMsgKey(annotation, isTargetComponent)
+ + DETAIL_MESSAGE_KEY_POSTFIX, e);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ protected String getReverseErrorMessageSummary(DateIs annotation)
+ {
+ return getErrorMessage(getValidationErrorMsgKey(annotation, false), annotation, false);
+ }
+
+ @Override
+ protected String getReverseErrorMessageDetail(DateIs annotation)
+ {
+ try
+ {
+ return getErrorMessage(getValidationErrorMsgKey(annotation, false)
+ + DETAIL_MESSAGE_KEY_POSTFIX, annotation, false);
+ }
+ catch (MissingResourceException e)
+ {
+ if(logger.isWarnEnabled())
+ {
+ logger.warn("couldn't find key " + getValidationErrorMsgKey(annotation)
+ + DETAIL_MESSAGE_KEY_POSTFIX, e);
+ }
+ }
+ return null;
+ }
+
+ protected String getErrorMessage(String key, DateIs annotation, boolean isTargetComponent)
+ {
+ String message = resolveMessage(key);
+
+ DateFormat dateFormat = DateFormat.getDateInstance(annotation.errorMessageDateStyle(),
+ FacesContext.getCurrentInstance().getViewRoot().getLocale());
+
+ String result;
+
+ if(isTargetComponent)
+ {
+ result = message.replace("{0}",
+ dateFormat.format((Date) this.violationResultStorage.get(COMPARED_VALUE_KEY)));
+ }
+ else
+ {
+ result = message.replace("{0}",
+ dateFormat.format((Date) this.violationResultStorage.get(REVERSE_COMPARED_VALUE_KEY)));
+ }
+
+ //replace placeholder with the value of the other component
+ return result;
+ }
+
+ /*
+ * private
+ */
+ private String getNotAfterErrorMsgKey(DateIs annotation)
+ {
+ if (annotation.validationErrorMsgKey().equals(""))
+ {
+ return annotation.notAfterErrorMsgKey();
+ }
+ return annotation.validationErrorMsgKey();
+ }
+
+ private String getNotBeforeErrorMsgKey(DateIs annotation)
+ {
+ if (annotation.validationErrorMsgKey().equals(""))
+ {
+ return annotation.notBeforeErrorMsgKey();
+ }
+ return annotation.validationErrorMsgKey();
+ }
+
+ private String getNotEqualErrorMsgKey(DateIs annotation)
+ {
+ if (annotation.validationErrorMsgKey().equals(""))
+ {
+ return annotation.notEqualErrorMsgKey();
+ }
+ return annotation.validationErrorMsgKey();
+ }
+}