You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mk...@apache.org on 2006/03/01 22:28:50 UTC
svn commit: r382163 -
/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java
Author: mkienenb
Date: Wed Mar 1 13:28:47 2006
New Revision: 382163
URL: http://svn.apache.org/viewcvs?rev=382163&view=rev
Log:
Changed typecasts from UIInput to EditableValueHolder.
Throw informative error if typecast fails.
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java
URL: http://svn.apache.org/viewcvs/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java?rev=382163&r1=382162&r2=382163&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/equalvalidator/EqualValidator.java Wed Mar 1 13:28:47 2006
@@ -17,9 +17,9 @@
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
+import javax.faces.component.EditableValueHolder;
import javax.faces.component.StateHolder;
import javax.faces.component.UIComponent;
-import javax.faces.component.UIInput;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
@@ -69,17 +69,20 @@
return;
}
- UIInput foreignComp = (UIInput) uiComponent.getParent().findComponent(_for);
+ UIComponent foreignComp = uiComponent.getParent().findComponent(_for);
if(foreignComp==null)
throw new FacesException("Unable to find component '" + _for + "' (calling findComponent on component '" + uiComponent.getId() + "')");
+ if(false == foreignComp instanceof EditableValueHolder)
+ throw new FacesException("Component '" + foreignComp.getId() + "' does not implement EditableValueHolder");
+ EditableValueHolder foreignEditableValueHolder = (EditableValueHolder) foreignComp;
- if (foreignComp.isRequired() && foreignComp.getValue()== null ) {
+ if (foreignEditableValueHolder.isRequired() && foreignEditableValueHolder.getValue()== null ) {
return;
}
- Object[] args = {value.toString(),(foreignComp.getValue()==null) ? foreignComp.getId():foreignComp.getValue().toString()};
+ Object[] args = {value.toString(),(foreignEditableValueHolder.getValue()==null) ? foreignComp.getId():foreignEditableValueHolder.getValue().toString()};
- if(foreignComp.getValue()==null || !foreignComp.getValue().toString().equals(value.toString()) )
+ if(foreignEditableValueHolder.getValue()==null || !foreignEditableValueHolder.getValue().toString().equals(value.toString()) )
throw new ValidatorException(MessageUtils.getMessage(FacesMessage.SEVERITY_ERROR,EQUAL_MESSAGE_ID, args));
}