You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Thierry Leveque <tl...@gmail.com> on 2009/04/20 17:30:51 UTC

Strange java.util.MissingResourceException on form validation

Hi

I have a really strange MissingResourceException when running my
application.

I have implemented my own IFormValidator.
When I find an error I use this code:

*lFormComponent.error( lFormComponent.getString( "DuplicatePorts", new
Model( new DuplicatePortsMessage( lFormComponent.getRawInput() ) ) ) );

...
private static class DuplicatePortsMessage implements Serializable
    {
        private String port = "";

        private DuplicatePortsMessage( final String iPort )
        {
            port = iPort;
        }
    }

*
It is working fine on the first Submit. The correct message is displayed in
my Feedback panel.
But if I submit my form again with the same error or another one, I am
getting this exception:

*

WicketMessage: Method onFormSubmitted of interface
org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
[MarkupContainer [Component id = configForm]] threw an exception

Root cause:

java.util.MissingResourceException: Unable to find resource:
DuplicatePortOnNode for component: listenerPort
[class=org.apache.wicket.markup.html.form.TextField]
at org.apache.wicket.Localizer.getString(Localizer.java:266)
at org.apache.wicket.Localizer.getString(Localizer.java:116)
at org.apache.wicket.Component.getString(Component.java:1806)
at
com.voiceage.spotxde.admin.config.modules.lbx.PortsValidator.validate(PortsValidator.java:72)
*I really don't understand that one. Why is the resource is found the first
time, but not the second time???

Thierry
Sent from Montreal, Quebec, Canada

Re: Strange java.util.MissingResourceException on form validation

Posted by Thierry Leveque <tl...@gmail.com>.
Forget it!

I found my problem!

It was because I was dynamically adding the validator in my "validate"
method of my form. The new validators were added at every request without
being removed from the validators collection.
The old validator was then called with null reference to the component....

Thierry
Sent from Montreal, Quebec, Canada

On Mon, Apr 20, 2009 at 11:30, Thierry Leveque <tl...@gmail.com> wrote:

> Hi
>
> I have a really strange MissingResourceException when running my
> application.
>
> I have implemented my own IFormValidator.
> When I find an error I use this code:
>
> *lFormComponent.error( lFormComponent.getString( "DuplicatePorts", new
> Model( new DuplicatePortsMessage( lFormComponent.getRawInput() ) ) ) );
>
> ...
> private static class DuplicatePortsMessage implements Serializable
>     {
>         private String port = "";
>
>         private DuplicatePortsMessage( final String iPort )
>         {
>             port = iPort;
>         }
>     }
>
> *
> It is working fine on the first Submit. The correct message is displayed in
> my Feedback panel.
> But if I submit my form again with the same error or another one, I am
> getting this exception:
>
> *
>
> WicketMessage: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
> [MarkupContainer [Component id = configForm]] threw an exception
>
> Root cause:
>
> java.util.MissingResourceException: Unable to find resource:
> DuplicatePortOnNode for component: listenerPort
> [class=org.apache.wicket.markup.html.form.TextField]
> at org.apache.wicket.Localizer.getString(Localizer.java:266)
> at org.apache.wicket.Localizer.getString(Localizer.java:116)
> at org.apache.wicket.Component.getString(Component.java:1806)
> at
> com.voiceage.spotxde.admin.config.modules.lbx.PortsValidator.validate(PortsValidator.java:72)
> *I really don't understand that one. Why is the resource is found the
> first time, but not the second time???
>
> Thierry
> Sent from Montreal, Quebec, Canada