You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2008/07/31 20:27:52 UTC
svn commit: r681431 [2/3] - in
/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules:
./ property-validation/
property-validation/src/main/java/org/apache/myfaces/extensions/validator/
property-validation/src/main/java/org/apac...
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationPhaseListener.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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;
@@ -32,55 +32,87 @@
/**
* @author Gerhard Petracek
*/
-public class CrossValidationPhaseListener implements PhaseListener {
+public class CrossValidationPhaseListener implements PhaseListener
+{
private boolean isInitialized = false;
- public void afterPhase(PhaseEvent event) {
+ public void afterPhase(PhaseEvent event)
+ {
- try {
- CrossValidationStorage crossValidationStorage = CrossValidationUtils.getOrInitCrossValidationStorage();
- for (CrossValidationStorageEntry entry : crossValidationStorage.getCrossValidationStorageEntries()) {
- try {
- entry.getValidationStrategy().processCrossValidation(entry, crossValidationStorage);
- } catch (ValidatorException e) {
+ try
+ {
+ CrossValidationStorage crossValidationStorage = CrossValidationUtils
+ .getOrInitCrossValidationStorage();
+ for (CrossValidationStorageEntry entry : crossValidationStorage
+ .getCrossValidationStorageEntries())
+ {
+ try
+ {
+ entry.getValidationStrategy().processCrossValidation(entry,
+ crossValidationStorage);
+ }
+ catch (ValidatorException e)
+ {
FacesMessage facesMessage = e.getFacesMessage();
- if (facesMessage != null && facesMessage.getSummary() != null && facesMessage.getDetail() != null) {
+ if (facesMessage != null
+ && facesMessage.getSummary() != null
+ && facesMessage.getDetail() != null)
+ {
UIComponent component = entry.getComponent();
String clientId = null;
//TODO
- if (component != null) {
- clientId = component.getClientId(event.getFacesContext());
+ if (component != null)
+ {
+ clientId = component.getClientId(event
+ .getFacesContext());
}
- event.getFacesContext().addMessage(clientId, facesMessage);
+ event.getFacesContext().addMessage(clientId,
+ facesMessage);
}
event.getFacesContext().renderResponse();
- } catch (MissingResourceException e) {
- event.getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "custom validation message not found", e.toString()));
+ }
+ catch (MissingResourceException e)
+ {
+ event.getFacesContext().addMessage(
+ null,
+ new FacesMessage(FacesMessage.SEVERITY_ERROR,
+ "custom validation message not found", e
+ .toString()));
event.getFacesContext().renderResponse();
throw e;
}
}
- } finally {
+ }
+ finally
+ {
CrossValidationUtils.resetCrossValidationStorage();
}
}
- public void beforePhase(PhaseEvent event) {
- if (!isInitialized) {
- if (WebXmlParameter.DEACTIVATE_CROSSVALIDATION != null && WebXmlParameter.DEACTIVATE_CROSSVALIDATION.equalsIgnoreCase("true")) {
+ public void beforePhase(PhaseEvent event)
+ {
+ if (!isInitialized)
+ {
+ if (WebXmlParameter.DEACTIVATE_CROSSVALIDATION != null
+ && WebXmlParameter.DEACTIVATE_CROSSVALIDATION
+ .equalsIgnoreCase("true"))
+ {
ExtValUtils.deregisterPhaseListener(this);
- } else {
+ }
+ else
+ {
isInitialized = true;
}
}
}
- public PhaseId getPhaseId() {
+ public PhaseId getPhaseId()
+ {
return PhaseId.ANY_PHASE;
}
}
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorage.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorage.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorage.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorage.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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;
@@ -24,18 +24,24 @@
/**
* @author Gerhard Petracek
*/
-public class CrossValidationStorage {
- private List<CrossValidationStorageEntry> crossValidationStorageEntries = new ArrayList<CrossValidationStorageEntry>();
+public class CrossValidationStorage
+{
+ private List<CrossValidationStorageEntry> crossValidationStorageEntries =
+ new ArrayList<CrossValidationStorageEntry>();
- public void add(CrossValidationStorageEntry entry) {
+ public void add(CrossValidationStorageEntry entry)
+ {
this.crossValidationStorageEntries.add(entry);
}
- public List<CrossValidationStorageEntry> getCrossValidationStorageEntries() {
+ public List<CrossValidationStorageEntry> getCrossValidationStorageEntries()
+ {
return crossValidationStorageEntries;
}
- public void setCrossValidationStorageEntries(List<CrossValidationStorageEntry> crossValidationStorageEntries) {
+ public void setCrossValidationStorageEntries(
+ List<CrossValidationStorageEntry> crossValidationStorageEntries)
+ {
this.crossValidationStorageEntries = crossValidationStorageEntries;
}
}
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/CrossValidationStorageEntry.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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;
@@ -26,7 +26,8 @@
/**
* @author Gerhard Petracek
*/
-public class CrossValidationStorageEntry {
+public class CrossValidationStorageEntry
+{
private AnnotationEntry annotationEntry;
//for complex components (e.g. a table) stores the object of entry (#{entry.property})
private Object bean;
@@ -34,43 +35,53 @@
private Object convertedObject;
private CrossValidationStrategy validationStrategy;
- public AnnotationEntry getAnnotationEntry() {
+ public AnnotationEntry getAnnotationEntry()
+ {
return annotationEntry;
}
- public void setAnnotationEntry(AnnotationEntry annotationEntry) {
+ public void setAnnotationEntry(AnnotationEntry annotationEntry)
+ {
this.annotationEntry = annotationEntry;
}
- public Object getBean() {
+ public Object getBean()
+ {
return bean;
}
- public void setBean(Object bean) {
+ public void setBean(Object bean)
+ {
this.bean = bean;
}
- public UIComponent getComponent() {
+ public UIComponent getComponent()
+ {
return component;
}
- public void setComponent(UIComponent component) {
+ public void setComponent(UIComponent component)
+ {
this.component = component;
}
- public Object getConvertedObject() {
+ public Object getConvertedObject()
+ {
return convertedObject;
}
- public void setConvertedObject(Object convertedObject) {
+ public void setConvertedObject(Object convertedObject)
+ {
this.convertedObject = convertedObject;
}
- public CrossValidationStrategy getValidationStrategy() {
+ public CrossValidationStrategy getValidationStrategy()
+ {
return validationStrategy;
}
- public void setValidationStrategy(CrossValidationStrategy validationStrategy) {
+ public void setValidationStrategy(CrossValidationStrategy validationStrategy)
+ {
this.validationStrategy = validationStrategy;
}
}
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/WebXmlParameter.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/WebXmlParameter.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/WebXmlParameter.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/WebXmlParameter.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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;
@@ -25,6 +25,8 @@
*
* @author Gerhard Petracek
*/
-public interface WebXmlParameter {
- static final String DEACTIVATE_CROSSVALIDATION = WebXmlUtils.getInitParameter("DEACTIVATE_CROSSVALIDATION");
+public interface WebXmlParameter
+{
+ static final String DEACTIVATE_CROSSVALIDATION = WebXmlUtils
+ .getInitParameter("DEACTIVATE_CROSSVALIDATION");
}
\ No newline at end of file
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIs.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.annotation;
@@ -28,10 +28,11 @@
/**
* @author Gerhard Petracek
*/
-@Target({METHOD, FIELD})
+@Target( { METHOD, FIELD })
@Retention(RUNTIME)
//TODO DateIsEntry (value, type)
-public @interface DateIs {
+public @interface DateIs
+{
String[] valueOf();
/*
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/DateIsType.java Thu Jul 31 11:27:50 2008
@@ -1,26 +1,28 @@
/*
- * 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.
+ * 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.annotation;
/**
* @author Gerhard Petracek
*/
-public enum DateIsType {
- before, after, same //TODO: beforeOrSame, afterOrSame
+public enum DateIsType
+{
+ before, after, same
+ //TODO: beforeOrSame, afterOrSame
}
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/Equals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/Equals.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/Equals.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/Equals.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.annotation;
@@ -27,9 +27,10 @@
/**
* @author Gerhard Petracek
*/
-@Target({METHOD, FIELD})
+@Target( { METHOD, FIELD })
@Retention(RUNTIME)
-public @interface Equals {
+public @interface Equals
+{
String[] value();
String validationErrorMsgKey() default "duplicated_content_required";
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/NotEquals.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/NotEquals.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/NotEquals.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/NotEquals.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.annotation;
@@ -27,9 +27,10 @@
/**
* @author Gerhard Petracek
*/
-@Target({METHOD, FIELD})
+@Target( { METHOD, FIELD })
@Retention(RUNTIME)
-public @interface NotEquals {
+public @interface NotEquals
+{
String[] value();
String validationErrorMsgKey() default "duplicated_content_denied";
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIf.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIf.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIf.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIf.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.annotation;
@@ -27,10 +27,11 @@
/**
* @author Gerhard Petracek
*/
-@Target({METHOD, FIELD})
+@Target( { METHOD, FIELD })
@Retention(RUNTIME)
//TODO DateIsEntry (value, type)
-public @interface RequiredIf {
+public @interface RequiredIf
+{
String[] valueOf();
/*
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/RequiredIfType.java Thu Jul 31 11:27:50 2008
@@ -1,26 +1,27 @@
/*
- * 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.
+ * 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.annotation;
/**
* @author Gerhard Petracek
*/
-public enum RequiredIfType {
+public enum RequiredIfType
+{
empty, not_empty
}
\ No newline at end of file
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/TargetAlias.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/TargetAlias.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/TargetAlias.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/TargetAlias.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.annotation;
@@ -27,8 +27,9 @@
/**
* @author Gerhard Petracek
*/
-@Target({METHOD, FIELD})
+@Target( { METHOD, FIELD })
@Retention(RUNTIME)
-public @interface TargetAlias {
+public @interface TargetAlias
+{
String value() default "";
}
\ No newline at end of file
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/extractor/DefaultValueBindingScanningAnnotationExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/extractor/DefaultValueBindingScanningAnnotationExtractor.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/extractor/DefaultValueBindingScanningAnnotationExtractor.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/annotation/extractor/DefaultValueBindingScanningAnnotationExtractor.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.annotation.extractor;
@@ -34,12 +34,17 @@
*
* @author Gerhard Petracek
*/
-public class DefaultValueBindingScanningAnnotationExtractor extends DefaultComponentAnnotationExtractor {
+public class DefaultValueBindingScanningAnnotationExtractor extends
+ DefaultComponentAnnotationExtractor
+{
@Override
- public List<AnnotationEntry> extractAnnotations(FacesContext facesContext, Object object) {
+ public List<AnnotationEntry> extractAnnotations(FacesContext facesContext,
+ Object object)
+ {
//should never occur
- if (!(object instanceof String)) {
+ if (!(object instanceof String))
+ {
return new ArrayList<AnnotationEntry>();
}
@@ -47,40 +52,54 @@
List<AnnotationEntry> annotationEntries = new ArrayList<AnnotationEntry>();
- Class entity = ELUtils.getTypeOfValueBindingForExpression(facesContext, valueBindingExpression);
+ Class entity = ELUtils.getTypeOfValueBindingForExpression(facesContext,
+ valueBindingExpression);
- if (entity != null) {
+ if (entity != null)
+ {
//find and add annotations
- addPropertyAccessAnnotations(entity, annotationEntries, valueBindingExpression);
- addFieldAccessAnnotations(entity, annotationEntries, valueBindingExpression);
+ addPropertyAccessAnnotations(entity, annotationEntries,
+ valueBindingExpression);
+ addFieldAccessAnnotations(entity, annotationEntries,
+ valueBindingExpression);
}
return annotationEntries;
}
- protected void addPropertyAccessAnnotations(Class entity, List<AnnotationEntry> annotationEntries, String valueBindingExpression) {
+ protected void addPropertyAccessAnnotations(Class entity,
+ List<AnnotationEntry> annotationEntries,
+ String valueBindingExpression)
+ {
AnnotationEntry templateEntry;
- for (Method method : entity.getDeclaredMethods()) {
+ for (Method method : entity.getDeclaredMethods())
+ {
templateEntry = new AnnotationEntry();
templateEntry.setEntityClass(entity.getClass());
templateEntry.setValueBindingExpression(valueBindingExpression);
templateEntry.setBoundTo("[method]:" + method.getName());
- addAnnotationToAnnotationEntries(annotationEntries, Arrays.asList(method.getAnnotations()), templateEntry);
+ addAnnotationToAnnotationEntries(annotationEntries, Arrays
+ .asList(method.getAnnotations()), templateEntry);
}
}
- protected void addFieldAccessAnnotations(Class entity, List<AnnotationEntry> annotationEntries, String valueBindingExpression) {
+ protected void addFieldAccessAnnotations(Class entity,
+ List<AnnotationEntry> annotationEntries,
+ String valueBindingExpression)
+ {
AnnotationEntry templateEntry;
- for (Field field : entity.getDeclaredFields()) {
+ for (Field field : entity.getDeclaredFields())
+ {
templateEntry = new AnnotationEntry();
templateEntry.setEntityClass(entity.getClass());
templateEntry.setValueBindingExpression(valueBindingExpression);
templateEntry.setBoundTo("[field]:" + field.getName());
- addAnnotationToAnnotationEntries(annotationEntries, Arrays.asList(field.getAnnotations()), templateEntry);
+ addAnnotationToAnnotationEntries(annotationEntries, Arrays
+ .asList(field.getAnnotations()), templateEntry);
}
}
}
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/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/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/message/resolver/DefaultValidationErrorMessageResolver.java Thu Jul 31 11:27:50 2008
@@ -1,35 +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.
+ * 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;
/**
* @author Gerhard Petracek
*/
-public class DefaultValidationErrorMessageResolver extends org.apache.myfaces.extensions.validator.core.validation.message.resolver.DefaultValidationErrorMessageResolver {
- private static String BASE_NAME = null;
+public class DefaultValidationErrorMessageResolver
+ extends
+ org.apache.myfaces.extensions.validator.core.validation.message.resolver.DefaultValidationErrorMessageResolver
+{
+ private static String baseName = null;
@Override
- protected String getBaseName() {
- if (BASE_NAME == null) {
- BASE_NAME = super.getBaseName();
+ protected String getBaseName()
+ {
+ if (baseName == null)
+ {
+ baseName = super.getBaseName();
}
- return BASE_NAME;
+ return baseName;
}
}
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractAliasCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractAliasCompareStrategy.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractAliasCompareStrategy.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractAliasCompareStrategy.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.referencing.strategy;
@@ -25,7 +25,8 @@
import org.apache.myfaces.extensions.validator.crossval.CrossValidationStorage;
import org.apache.myfaces.extensions.validator.crossval.CrossValidationStorageEntry;
import org.apache.myfaces.extensions.validator.crossval.annotation.TargetAlias;
-import org.apache.myfaces.extensions.validator.crossval.annotation.extractor.DefaultValueBindingScanningAnnotationExtractor;
+import org.apache.myfaces.extensions.validator.crossval.annotation.extractor.
+ DefaultValueBindingScanningAnnotationExtractor;
import org.apache.myfaces.extensions.validator.crossval.strategy.AbstractCompareStrategy;
import org.apache.myfaces.extensions.validator.util.ELUtils;
@@ -40,55 +41,91 @@
*
* @author Gerhard Petracek
*/
-public class AbstractAliasCompareStrategy implements ReferencingStrategy {
+public class AbstractAliasCompareStrategy implements ReferencingStrategy
+{
protected final Log logger = LogFactory.getLog(getClass());
- public boolean evalReferenceAndValidate(CrossValidationStorageEntry crossValidationStorageEntry, CrossValidationStorage crossValidationStorage, String validationTarget, AbstractCompareStrategy compareStrategy) {
- if (validationTarget.startsWith("@")) {
- tryToValidateWithAlias(crossValidationStorageEntry, crossValidationStorage, validationTarget.substring(1), compareStrategy);
+ public boolean evalReferenceAndValidate(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorage crossValidationStorage,
+ String validationTarget, AbstractCompareStrategy compareStrategy)
+ {
+ if (validationTarget.startsWith("@"))
+ {
+ tryToValidateWithAlias(crossValidationStorageEntry,
+ crossValidationStorage, validationTarget.substring(1),
+ compareStrategy);
return true;
- } else if (validationTarget.contains(":@*")) {
- if (validateBindingFormatWithAlias(validationTarget)) {
- tryToValidateBindingWithAlias(crossValidationStorageEntry, validationTarget, crossValidationStorage, compareStrategy, false);
+ }
+ else if (validationTarget.contains(":@*"))
+ {
+ if (validateBindingFormatWithAlias(validationTarget))
+ {
+ tryToValidateBindingWithAlias(crossValidationStorageEntry,
+ validationTarget, crossValidationStorage,
+ compareStrategy, false);
return true;
}
- } else if (validationTarget.contains(":@")) {
- if (validateBindingFormatWithAlias(validationTarget)) {
- tryToValidateBindingWithAlias(crossValidationStorageEntry, validationTarget, crossValidationStorage, compareStrategy, true);
+ }
+ else if (validationTarget.contains(":@"))
+ {
+ if (validateBindingFormatWithAlias(validationTarget))
+ {
+ tryToValidateBindingWithAlias(crossValidationStorageEntry,
+ validationTarget, crossValidationStorage,
+ compareStrategy, true);
return true;
}
}
return false;
}
- protected void tryToValidateWithAlias(CrossValidationStorageEntry crossValidationStorageEntry, CrossValidationStorage crossValidationStorage, String validationTarget, AbstractCompareStrategy compareStrategy) {
+ protected void tryToValidateWithAlias(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorage crossValidationStorage,
+ String validationTarget, AbstractCompareStrategy compareStrategy)
+ {
boolean validationExecuted = false;
boolean useModelValue = true;
- if (validationTarget.startsWith("*")) {
+ if (validationTarget.startsWith("*"))
+ {
useModelValue = false;
validationTarget = validationTarget.substring(1);
}
//search for TargetAlias annotations
- for (CrossValidationStorageEntry entry : crossValidationStorage.getCrossValidationStorageEntries()) {
-
- if (entry.getAnnotationEntry().getAnnotation() instanceof TargetAlias) {
- validationExecuted = validateTargetWithAlias(validationTarget, crossValidationStorageEntry, entry, useModelValue, compareStrategy);
+ for (CrossValidationStorageEntry entry : crossValidationStorage
+ .getCrossValidationStorageEntries())
+ {
+
+ if (entry.getAnnotationEntry().getAnnotation() instanceof TargetAlias)
+ {
+ validationExecuted = validateTargetWithAlias(validationTarget,
+ crossValidationStorageEntry, entry, useModelValue,
+ compareStrategy);
}
- if (validationExecuted) {
+ if (validationExecuted)
+ {
break;
}
}
}
- protected boolean tryToValidateBindingWithAlias(CrossValidationStorageEntry crossValidationStorageEntry, String targetProperty, CrossValidationStorage crossValidationStorage, AbstractCompareStrategy compareStrategy, boolean useModelValue) {
+ protected boolean tryToValidateBindingWithAlias(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ String targetProperty,
+ CrossValidationStorage crossValidationStorage,
+ AbstractCompareStrategy compareStrategy, boolean useModelValue)
+ {
String[] crossEntityReferenceWithBinding = extractCrossEntityReferenceWithBinding(targetProperty);
FacesContext facesContext = FacesContext.getCurrentInstance();
- if (!ELUtils.isExpressionValid(facesContext, crossEntityReferenceWithBinding[0])) {
+ if (!ELUtils.isExpressionValid(facesContext,
+ crossEntityReferenceWithBinding[0]))
+ {
return false;
}
@@ -99,35 +136,59 @@
int aliasStartIndex;
- if (useModelValue) {
+ if (useModelValue)
+ {
aliasStartIndex = crossEntityReferenceWithBinding[1].indexOf('@') + 1;
- } else {
+ }
+ else
+ {
aliasStartIndex = crossEntityReferenceWithBinding[1].indexOf('@') + 2;
}
- String targetAliasName = crossEntityReferenceWithBinding[1].substring(aliasStartIndex);
- for (AnnotationEntry entry : extractor.extractAnnotations(facesContext, crossEntityReferenceWithBinding[0])) {
- if (entry.getAnnotation() instanceof TargetAlias) {
+ String targetAliasName = crossEntityReferenceWithBinding[1]
+ .substring(aliasStartIndex);
+ for (AnnotationEntry entry : extractor.extractAnnotations(facesContext,
+ crossEntityReferenceWithBinding[0]))
+ {
+ if (entry.getAnnotation() instanceof TargetAlias)
+ {
alias = ((TargetAlias) entry.getAnnotation()).value();
- if (targetAliasName.equals(alias)) {
+ if (targetAliasName.equals(alias))
+ {
foundAnnotationEntry = entry;
break;
}
}
}
- if (foundAnnotationEntry == null) {
+ if (foundAnnotationEntry == null)
+ {
return false;
}
Object referencedBean = null;
Object validationTargetObject = null;
- if (useModelValue) {
- referencedBean = ELUtils.getValueOfExpression(facesContext, crossEntityReferenceWithBinding[0]);
- validationTargetObject = getValidationTargetObject(crossValidationStorageEntry, foundAnnotationEntry, referencedBean, crossValidationStorage);
- } else {
- for (CrossValidationStorageEntry entry : crossValidationStorage.getCrossValidationStorageEntries()) {
- if (foundAnnotationEntry.getAnnotation() instanceof TargetAlias && entry.getAnnotationEntry().getAnnotation() != null && entry.getAnnotationEntry().getAnnotation() instanceof TargetAlias) {
- if (((TargetAlias) foundAnnotationEntry.getAnnotation()).value().equals(((TargetAlias) entry.getAnnotationEntry().getAnnotation()).value())) {
+ if (useModelValue)
+ {
+ referencedBean = ELUtils.getValueOfExpression(facesContext,
+ crossEntityReferenceWithBinding[0]);
+ validationTargetObject = getValidationTargetObject(
+ crossValidationStorageEntry, foundAnnotationEntry,
+ referencedBean, crossValidationStorage);
+ }
+ else
+ {
+ for (CrossValidationStorageEntry entry : crossValidationStorage
+ .getCrossValidationStorageEntries())
+ {
+ if (foundAnnotationEntry.getAnnotation() instanceof TargetAlias
+ && entry.getAnnotationEntry().getAnnotation() != null
+ && entry.getAnnotationEntry().getAnnotation() instanceof TargetAlias)
+ {
+ if (((TargetAlias) foundAnnotationEntry.getAnnotation())
+ .value().equals(
+ ((TargetAlias) entry.getAnnotationEntry()
+ .getAnnotation()).value()))
+ {
validationTargetObject = entry.getConvertedObject();
break;
}
@@ -135,13 +196,22 @@
}
}
- validateFoundEntry(crossValidationStorageEntry, foundAnnotationEntry, referencedBean, crossValidationStorage, validationTargetObject, compareStrategy);
+ validateFoundEntry(crossValidationStorageEntry, foundAnnotationEntry,
+ referencedBean, crossValidationStorage, validationTargetObject,
+ compareStrategy);
return true;
}
- protected Object getValidationTargetObject(CrossValidationStorageEntry crossValidationStorageEntry, AnnotationEntry foundAnnotationEntry, Object referencedBean, CrossValidationStorage crossValidationStorage) {
- if (foundAnnotationEntry == null || foundAnnotationEntry.getBoundTo() == null || foundAnnotationEntry.getBoundTo().indexOf(":") < 0) {
+ protected Object getValidationTargetObject(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ AnnotationEntry foundAnnotationEntry, Object referencedBean,
+ CrossValidationStorage crossValidationStorage)
+ {
+ if (foundAnnotationEntry == null
+ || foundAnnotationEntry.getBoundTo() == null
+ || foundAnnotationEntry.getBoundTo().indexOf(":") < 0)
+ {
//TODO logging
return null;
}
@@ -149,88 +219,142 @@
Object validationTargetObject = null;
String boundTo = foundAnnotationEntry.getBoundTo();
String name = boundTo.substring(boundTo.indexOf(":") + 1);
- if (boundTo.startsWith("[method]")) {
- String baseValueBindingExpression = foundAnnotationEntry.getValueBindingExpression();
-
- String targetValueBindingExpression = baseValueBindingExpression.substring(0, baseValueBindingExpression.length() - 1) + "." + name + "}";
+ if (boundTo.startsWith("[method]"))
+ {
+ String baseValueBindingExpression = foundAnnotationEntry
+ .getValueBindingExpression();
+
+ String targetValueBindingExpression = baseValueBindingExpression
+ .substring(0, baseValueBindingExpression.length() - 1)
+ + "." + name + "}";
FacesContext facesContext = FacesContext.getCurrentInstance();
- if (ELUtils.isExpressionValid(facesContext, targetValueBindingExpression)) {
- validationTargetObject = ELUtils.getValueOfExpression(facesContext, targetValueBindingExpression);
+ if (ELUtils.isExpressionValid(facesContext,
+ targetValueBindingExpression))
+ {
+ validationTargetObject = ELUtils.getValueOfExpression(
+ facesContext, targetValueBindingExpression);
}
- } else if (boundTo.startsWith("[field]")) {
- try {
+ }
+ else if (boundTo.startsWith("[field]"))
+ {
+ try
+ {
Field foundField;
- try {
- foundField = referencedBean.getClass().getDeclaredField(name);
+ try
+ {
+ foundField = referencedBean.getClass().getDeclaredField(
+ name);
foundField.setAccessible(true);
validationTargetObject = foundField.get(referencedBean);
- } catch (NoSuchFieldException e) {
- foundField = referencedBean.getClass().getDeclaredField("_" + name);
+ }
+ catch (NoSuchFieldException e)
+ {
+ foundField = referencedBean.getClass().getDeclaredField(
+ "_" + name);
foundField.setAccessible(true);
validationTargetObject = foundField.get(referencedBean);
}
- } catch (Exception e) {
- logger.warn("couldn't access field " + name + " details: boundTo=" + boundTo, e);
+ }
+ catch (Exception e)
+ {
+ logger.warn("couldn't access field " + name
+ + " details: boundTo=" + boundTo, e);
}
}
return validationTargetObject;
}
- protected void validateFoundEntry(CrossValidationStorageEntry crossValidationStorageEntry, AnnotationEntry foundAnnotationEntry, Object referencedBean, CrossValidationStorage crossValidationStorage, Object validationTargetObject, AbstractCompareStrategy compareStrategy) {
+ protected void validateFoundEntry(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ AnnotationEntry foundAnnotationEntry, Object referencedBean,
+ CrossValidationStorage crossValidationStorage,
+ Object validationTargetObject,
+ AbstractCompareStrategy compareStrategy)
+ {
boolean violationFound = false;
- if (compareStrategy.isViolation(crossValidationStorageEntry.getConvertedObject(), validationTargetObject, crossValidationStorageEntry.getAnnotationEntry().getAnnotation())) {
- compareStrategy.handleTargetViolation(crossValidationStorageEntry, null);
+ if (compareStrategy.isViolation(crossValidationStorageEntry
+ .getConvertedObject(), validationTargetObject,
+ crossValidationStorageEntry.getAnnotationEntry()
+ .getAnnotation()))
+ {
+ compareStrategy.handleTargetViolation(crossValidationStorageEntry,
+ null);
violationFound = true;
}
- if (violationFound) {
- compareStrategy.processSourceComponentAfterViolation(crossValidationStorageEntry);
+ if (violationFound)
+ {
+ compareStrategy
+ .processSourceComponentAfterViolation(crossValidationStorageEntry);
}
}
//TODO
- protected boolean validateTargetWithAlias(String validationTarget, CrossValidationStorageEntry crossValidationStorageEntry, CrossValidationStorageEntry entry, boolean useModelValue, AbstractCompareStrategy compareStrategy) {
+ protected boolean validateTargetWithAlias(String validationTarget,
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorageEntry entry, boolean useModelValue,
+ AbstractCompareStrategy compareStrategy)
+ {
boolean validationExecuted = false;
boolean violationFound = false;
- if (validationTarget.equals(((TargetAlias) entry.getAnnotationEntry().getAnnotation()).value())) {
+ if (validationTarget.equals(((TargetAlias) entry.getAnnotationEntry()
+ .getAnnotation()).value()))
+ {
//get an object to store all results
Object validationTargetObject;
- if (useModelValue) {
- validationTargetObject = ELUtils.getValueOfExpression(FacesContext.getCurrentInstance(), entry.getAnnotationEntry().getValueBindingExpression());
- } else {
+ if (useModelValue)
+ {
+ validationTargetObject = ELUtils.getValueOfExpression(
+ FacesContext.getCurrentInstance(), entry
+ .getAnnotationEntry()
+ .getValueBindingExpression());
+ }
+ else
+ {
validationTargetObject = entry.getConvertedObject();
}
- if (compareStrategy.isViolation(crossValidationStorageEntry.getConvertedObject(), validationTargetObject, crossValidationStorageEntry.getAnnotationEntry().getAnnotation())) {
+ if (compareStrategy.isViolation(crossValidationStorageEntry
+ .getConvertedObject(), validationTargetObject,
+ crossValidationStorageEntry.getAnnotationEntry()
+ .getAnnotation()))
+ {
violationFound = true;
- compareStrategy.handleTargetViolation(crossValidationStorageEntry, entry);
+ compareStrategy.handleTargetViolation(
+ crossValidationStorageEntry, entry);
}
validationExecuted = true;
}
- if (violationFound) {
- compareStrategy.processSourceComponentAfterViolation(crossValidationStorageEntry);
+ if (violationFound)
+ {
+ compareStrategy
+ .processSourceComponentAfterViolation(crossValidationStorageEntry);
}
return validationExecuted;
}
- protected boolean validateBindingFormatWithAlias(String targetProperty) {
+ protected boolean validateBindingFormatWithAlias(String targetProperty)
+ {
int bindingStartIndex = targetProperty.indexOf("#{");
int bindingEndIndex = targetProperty.indexOf("}");
int separatorIndex = targetProperty.indexOf(":@");
- return (bindingStartIndex > -1 && bindingEndIndex > -1 && separatorIndex > -1 && bindingStartIndex < bindingEndIndex && bindingEndIndex < separatorIndex);
+ return (bindingStartIndex > -1 && bindingEndIndex > -1
+ && separatorIndex > -1 && bindingStartIndex < bindingEndIndex && bindingEndIndex < separatorIndex);
}
- protected String[] extractCrossEntityReferenceWithBinding(String targetProperty) {
+ protected String[] extractCrossEntityReferenceWithBinding(
+ String targetProperty)
+ {
String[] result = new String[2];
result[0] = targetProperty.substring(0, targetProperty.indexOf(":"));
Modified: myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractELCompareStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractELCompareStrategy.java?rev=681431&r1=681430&r2=681431&view=diff
==============================================================================
--- myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractELCompareStrategy.java (original)
+++ myfaces/extensions/validator/branches/trunk_layout_myfaces/validation-modules/property-validation/src/main/java/org/apache/myfaces/extensions/validator/crossval/referencing/strategy/AbstractELCompareStrategy.java Thu Jul 31 11:27:50 2008
@@ -1,20 +1,20 @@
/*
- * 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.
+ * 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.referencing.strategy;
@@ -36,59 +36,89 @@
*
* @author Gerhard Petracek
*/
-public class AbstractELCompareStrategy implements ReferencingStrategy {
+public class AbstractELCompareStrategy implements ReferencingStrategy
+{
protected final Log logger = LogFactory.getLog(getClass());
- public boolean evalReferenceAndValidate(CrossValidationStorageEntry crossValidationStorageEntry, CrossValidationStorage crossValidationStorage, String validationTarget, AbstractCompareStrategy compareStrategy) {
- if (validationTarget.startsWith("#{") && validationTarget.endsWith("}") && validateValueBindingFormat(validationTarget)) {
- tryToValidateValueBinding(crossValidationStorageEntry, validationTarget, crossValidationStorage, compareStrategy);
+ public boolean evalReferenceAndValidate(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ CrossValidationStorage crossValidationStorage,
+ String validationTarget, AbstractCompareStrategy compareStrategy)
+ {
+ if (validationTarget.startsWith("#{") && validationTarget.endsWith("}")
+ && validateValueBindingFormat(validationTarget))
+ {
+ tryToValidateValueBinding(crossValidationStorageEntry,
+ validationTarget, crossValidationStorage, compareStrategy);
return true;
}
return false;
}
- protected boolean tryToValidateValueBinding(CrossValidationStorageEntry crossValidationStorageEntry, String validationTarget, CrossValidationStorage crossValidationStorage, AbstractCompareStrategy compareStrategy) {
+ protected boolean tryToValidateValueBinding(
+ CrossValidationStorageEntry crossValidationStorageEntry,
+ String validationTarget,
+ CrossValidationStorage crossValidationStorage,
+ AbstractCompareStrategy compareStrategy)
+ {
boolean violationFound = false;
FacesContext facesContext = FacesContext.getCurrentInstance();
- if (!ELUtils.isExpressionValid(facesContext, validationTarget)) {
+ if (!ELUtils.isExpressionValid(facesContext, validationTarget))
+ {
return false;
}
- if (compareStrategy.isViolation(crossValidationStorageEntry.getConvertedObject(), ELUtils.getValueOfExpression(facesContext, validationTarget), crossValidationStorageEntry.getAnnotationEntry().getAnnotation())) {
+ if (compareStrategy.isViolation(crossValidationStorageEntry
+ .getConvertedObject(), ELUtils.getValueOfExpression(
+ facesContext, validationTarget), crossValidationStorageEntry
+ .getAnnotationEntry().getAnnotation()))
+ {
ProcessedInformationEntry validationTargetEntry;
- Map<String, ProcessedInformationEntry> valueBindingConvertedValueMapping = ExtValUtils.getOrInitValueBindingConvertedValueMapping();
+ Map<String, ProcessedInformationEntry> valueBindingConvertedValueMapping = ExtValUtils
+ .getOrInitValueBindingConvertedValueMapping();
- validationTargetEntry = valueBindingConvertedValueMapping.get(validationTarget);
+ validationTargetEntry = valueBindingConvertedValueMapping
+ .get(validationTarget);
CrossValidationStorageEntry tmpCrossValidationStorageEntry = null;
- if (validationTargetEntry != null) {
+ if (validationTargetEntry != null)
+ {
tmpCrossValidationStorageEntry = new CrossValidationStorageEntry();
- tmpCrossValidationStorageEntry.setComponent(validationTargetEntry.getComponent());
- tmpCrossValidationStorageEntry.setConvertedObject(validationTargetEntry.getConvertedValue());
- tmpCrossValidationStorageEntry.setValidationStrategy(compareStrategy);
+ tmpCrossValidationStorageEntry
+ .setComponent(validationTargetEntry.getComponent());
+ tmpCrossValidationStorageEntry
+ .setConvertedObject(validationTargetEntry
+ .getConvertedValue());
+ tmpCrossValidationStorageEntry
+ .setValidationStrategy(compareStrategy);
}
- compareStrategy.handleTargetViolation(crossValidationStorageEntry, tmpCrossValidationStorageEntry);
+ compareStrategy.handleTargetViolation(crossValidationStorageEntry,
+ tmpCrossValidationStorageEntry);
violationFound = true;
}
- if (violationFound) {
- compareStrategy.processSourceComponentAfterViolation(crossValidationStorageEntry);
+ if (violationFound)
+ {
+ compareStrategy
+ .processSourceComponentAfterViolation(crossValidationStorageEntry);
}
return true;
}
- protected boolean validateValueBindingFormat(String targetProperty) {
+ protected boolean validateValueBindingFormat(String targetProperty)
+ {
int bindingStartIndex = targetProperty.indexOf("#{");
int bindingEndIndex = targetProperty.indexOf("}");
int separatorIndex = targetProperty.indexOf(".");
- return (bindingStartIndex > -1 && bindingEndIndex > -1 && separatorIndex > -1 && bindingStartIndex < bindingEndIndex && bindingEndIndex > separatorIndex);
+ return (bindingStartIndex > -1 && bindingEndIndex > -1
+ && separatorIndex > -1 && bindingStartIndex < bindingEndIndex && bindingEndIndex > separatorIndex);
}
}
\ No newline at end of file