Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FormItem.setValidators JavaScriptException

    I'm trying to set a range validator of a FormItem after a fetch using values from DSResponse.getData(). I'm getting this exception when calling setValidators() though:
    Code:
    2011-08-10 14:28:36,156 [FATAL] Uncaught Exception:
    com.google.gwt.core.client.JavaScriptException:
    (TypeError): 'setValue' is null or not an object
     number: -2146823281
     description: 'setValue' is null or not an object
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:195)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:120)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:507)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:264)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:188)
        at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:157)
        at com.google.gwt.dev.shell.BrowserChannel.reactToMessages(BrowserChannel.java:1668)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:401)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:222)
        at java.lang.Thread.run(Thread.java:619)
    Here is my code:
    Code:
    public FloatRangeValidator newFloatRangeValidator(float min, float max) {
        FloatRangeValidator validator = new FloatRangeValidator();
        validator.setMin(min);
        validator.setMax(max);
        return validator;
    }
    
    ...
    // In fetch callback
    FormItem item = valuesManager.getItem("name");
    
    // Exception occurs here. Didn't work with values from response either
    item.setValidators(newFloatRangeValidator(0, 1));
    I get the same thing trying to calling item.setValidators(new RequiredIfValidator()) too.

    #2
    Not sure how this is ending up with an error about setValue(), but you can't change validators on a live FormItem. You should defer the construction of the form as a whole until after the fetch instead (or at least, only call setItems() after the fetch).

    Comment


      #3
      I needed to have the form constructed beforehand and the validators set dynamically. I was able to call setValidators if I had a direct reference to the FormItem rather than getting it from ValuesManager.getItem() though.

      Comment

      Working...
      X