czw., 14 sty 2021 o 16:25 Günter Paul <gu.paul...@googlemail.com.invalid> napisał(a): > > In Germany we can use domaine-names like "münchen.de". > The struts validators URLValidator and EmailIdnValidator can't handle such > name with umlaut. > The domaine is valide but not for the validator. > > Is it possible to change this behavior? > > I overwrite the classes and it works for me. > But I think it's better to change the standard classes, > > Here my solution: > > import com.opensymphony.xwork2.validator.ValidationException; > import com.opensymphony.xwork2.validator.validators.URLValidator; > > import java.net.IDN; > import java.util.Objects; > > public class URLIdnValidator extends URLValidator > { > @Override > public Object getFieldValue(String name, Object object) throws > ValidationException > { > Object fieldValue = super.getFieldValue(name, object); > > if (fieldValue != null) > { > fieldValue = IDN.toASCII(Objects.toString(fieldValue, "")); // need > Java 1.6 > } > > return fieldValue; > } > }
Thanks for sharing your solution, the problem is that we also need to support ClientSide validation and we are using exactly the same RegEx on both sides. Your solution is valid but just in case of ServerSide validation. There is a ticket to fix EmailValidator, yet I still don't know how to do it properly on both sides. https://issues.apache.org/jira/browse/WW-4395 Regards -- Łukasz + 48 606 323 122 http://www.lenart.org.pl/ --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org