You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Erinc Arikan <er...@gmail.com> on 2011/10/14 22:41:50 UTC

Can not locate error messages from property messages

Hi;

I am using a really simple property file, to display some validation errors,
it used to work fine, but it stopped working, now I can't even get the
simplest example to work. and I am receiving an Could not locate error
message for component:


Here's the code that I am using(directly from cookbook), and I have
PasswordPolicyValidator.properties file in the same folder
package cookbook;

import java.util.regex.Pattern;

import org.apache.wicket.validation.IValidatable;
import org.apache.wicket.validation.IValidator;
import org.apache.wicket.validation.ValidationError;

public class PasswordPolicyValidator implements IValidator<String> {

private static final Pattern UPPER = Pattern.compile("[A-Z]");
private static final Pattern LOWER = Pattern.compile("[a-z]");
private static final Pattern NUMBER = Pattern.compile("[0-9]");

public void validate(IValidatable<String> validatable) {
final String password = validatable.getValue();

if (!NUMBER.matcher(password).find()) {
error(validatable, "no-digit");
}

if (!LOWER.matcher(password).find()) {
error(validatable, "no-lower");
}

if (!UPPER.matcher(password).find()) {
error(validatable, "no-upper");
}
}

private void error(IValidatable<String> validatable, String errorKey) {
ValidationError error = new ValidationError();
error.addMessageKey(getClass().getSimpleName() + "." + errorKey);
validatable.error(error);
}

}

PasswordPolicyValidator.no-digit=${label} must contain at least one digit
PasswordPolicyValidator.no-lower=${label} must contain at least one lower
case letter
PasswordPolicyValidator.no-upper=${label} must contain at least one upper
case letter

Erinc

Re: Can not locate error messages from property messages

Posted by Erinc Arikan <er...@gmail.com>.
Sorry for the late response, It does generate the valid key bundle, there
should be something I am missing and overlooking since I just started a
clean quickstart and it's also happening there.

Erinc

On Sat, Oct 15, 2011 at 9:05 AM, Andrea Del Bene <an...@gmail.com>wrote:

> Hi,
>
> are you sure that code
>
>  'getClass().getSimpleName() + "." + errorKey'
>
> generates a valid key bundle?
>
>  Hi;
>>
>> I am using a really simple property file, to display some validation
>> errors,
>> it used to work fine, but it stopped working, now I can't even get the
>> simplest example to work. and I am receiving an Could not locate error
>> message for component:
>>
>>
>> Here's the code that I am using(directly from cookbook), and I have
>> PasswordPolicyValidator.**properties file in the same folder
>> package cookbook;
>>
>> import java.util.regex.Pattern;
>>
>> import org.apache.wicket.validation.**IValidatable;
>> import org.apache.wicket.validation.**IValidator;
>> import org.apache.wicket.validation.**ValidationError;
>>
>> public class PasswordPolicyValidator implements IValidator<String>  {
>>
>> private static final Pattern UPPER = Pattern.compile("[A-Z]");
>> private static final Pattern LOWER = Pattern.compile("[a-z]");
>> private static final Pattern NUMBER = Pattern.compile("[0-9]");
>>
>> public void validate(IValidatable<String>  validatable) {
>> final String password = validatable.getValue();
>>
>> if (!NUMBER.matcher(password).**find()) {
>> error(validatable, "no-digit");
>> }
>>
>> if (!LOWER.matcher(password).**find()) {
>> error(validatable, "no-lower");
>> }
>>
>> if (!UPPER.matcher(password).**find()) {
>> error(validatable, "no-upper");
>> }
>> }
>>
>> private void error(IValidatable<String>  validatable, String errorKey) {
>> ValidationError error = new ValidationError();
>> error.addMessageKey(getClass()**.getSimpleName() + "." + errorKey);
>> validatable.error(error);
>> }
>>
>> }
>>
>> PasswordPolicyValidator.no-**digit=${label} must contain at least one
>> digit
>> PasswordPolicyValidator.no-**lower=${label} must contain at least one
>> lower
>> case letter
>> PasswordPolicyValidator.no-**upper=${label} must contain at least one
>> upper
>> case letter
>>
>> Erinc
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@wicket.**apache.org<us...@wicket.apache.org>
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Can not locate error messages from property messages

Posted by Andrea Del Bene <an...@gmail.com>.
Hi,

are you sure that code

  'getClass().getSimpleName() + "." + errorKey'

generates a valid key bundle?
> Hi;
>
> I am using a really simple property file, to display some validation errors,
> it used to work fine, but it stopped working, now I can't even get the
> simplest example to work. and I am receiving an Could not locate error
> message for component:
>
>
> Here's the code that I am using(directly from cookbook), and I have
> PasswordPolicyValidator.properties file in the same folder
> package cookbook;
>
> import java.util.regex.Pattern;
>
> import org.apache.wicket.validation.IValidatable;
> import org.apache.wicket.validation.IValidator;
> import org.apache.wicket.validation.ValidationError;
>
> public class PasswordPolicyValidator implements IValidator<String>  {
>
> private static final Pattern UPPER = Pattern.compile("[A-Z]");
> private static final Pattern LOWER = Pattern.compile("[a-z]");
> private static final Pattern NUMBER = Pattern.compile("[0-9]");
>
> public void validate(IValidatable<String>  validatable) {
> final String password = validatable.getValue();
>
> if (!NUMBER.matcher(password).find()) {
> error(validatable, "no-digit");
> }
>
> if (!LOWER.matcher(password).find()) {
> error(validatable, "no-lower");
> }
>
> if (!UPPER.matcher(password).find()) {
> error(validatable, "no-upper");
> }
> }
>
> private void error(IValidatable<String>  validatable, String errorKey) {
> ValidationError error = new ValidationError();
> error.addMessageKey(getClass().getSimpleName() + "." + errorKey);
> validatable.error(error);
> }
>
> }
>
> PasswordPolicyValidator.no-digit=${label} must contain at least one digit
> PasswordPolicyValidator.no-lower=${label} must contain at least one lower
> case letter
> PasswordPolicyValidator.no-upper=${label} must contain at least one upper
> case letter
>
> Erinc
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org