2

I have my own wicket(1.5.x) Custom String loader loaded on appliation startup which fetches data from a dictionary table in my database.

Now when I use this loader despite of loading of default string loader;in my validation text, it does not show the ${component} label like username/password. It comes like "the field '' is required" where the filed name remains empty. How could I fix this?

I have tried one solution.Here are my codes:

1) I have loader my String loader like this in my Application class:

  getResourceSettings().getStringResourceLoaders().add(0,
            new ClassStringResourceLoader(MyApplication.class));

    getResourceSettings().getStringResourceLoaders()
       .add(1, new DictionaryLoader((IDicitureService)
        applicationContext.getBean(IDicitureService.class)));

here DictionaryLoader is just an implementation of IStringResourceLoader.

2) In my login form I have added my username and password field like this:

    final FeedbackPanel feedback = new FeedbackPanel("feedback");
    feedback.setOutputMarkupId(true);
    form.add(feedback);
    form.add(new FormComponentFeedbackBorder("username_border")
            .add(new RequiredTextField("username",String.class)
                    .setLabel(new StringResourceModel("COMP:0:0", this, null))));
    form.add(new FormComponentFeedbackBorder("password_border").
            add(new PasswordTextField("password")
                    .setLabel(new StringResourceModel("COMP:1:0", this, null))));
    add(form);

wherenew StringResourceModel("COMP:1:0", this, null) just returns a string like username ... password etc.

Now if I check my page it replaces the validator content with my provided text when I use TextField.setLabel() which in fact is for validator label. But I am not using ${label} here.

Is this a good way to do that? Or it can be done in other way.

thanks.

1 Answer 1

0

Can you post the values for 'COMP:0:0' and 'COMP:1:0' message keys?

You should use the same syntax as wicket does by default:

Required=Field '${label}' is required.

${label} is either an actual label (if you set one) or field ID (if you didn't set the label).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.