Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Bug in RadioGroupItem.setDefaultValue(Enum) (with minimal testcase)

$
0
0
Hi Isomorphic,

I'm using RadioGroupItem with a valuemap with an enum as key. This works very well. But if I try to set a defaultvalue, I get an exception with very little details.
I'm using v9.0p_2014-01-13/EVAL Deployment and Development Mode from Eclipse with GWT 2.5.1 (tested with 2.6.1-rc3, too).

Please change the builtInDs example as follows to reproduce:
Code:

package com.smartgwt.sample.client;

import java.util.LinkedHashMap;

import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.core.KeyIdentifier;
import com.smartgwt.client.util.KeyCallback;
import com.smartgwt.client.util.Page;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
import com.smartgwt.client.widgets.layout.VStack;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class BuiltInDS implements EntryPoint {
        private DynamicForm boundForm;
        private LinkedHashMap<MyEnum, String> optionMap;

        public void onModuleLoad() {
                KeyIdentifier debugKey = new KeyIdentifier();
                debugKey.setCtrlKey(true);
                debugKey.setKeyName("D");

                Page.registerKey(debugKey, new KeyCallback() {
                        public void execute(String keyName) {
                                SC.showConsole();
                        }
                });

                VStack vStack = new VStack();
                vStack.setLeft(175);
                vStack.setTop(75);
                vStack.setWidth("70%");
                vStack.setMembersMargin(20);

                boundForm = new DynamicForm() {
                        {
                                optionMap = new LinkedHashMap<MyEnum, String>();
                                optionMap.put(MyEnum.O1, "Option 1");
                                optionMap.put(MyEnum.O2, "Option 2");
                                optionMap.put(MyEnum.O3, "Option 3");

                                final RadioGroupItem myRGI = new RadioGroupItem() {
                                        {
                                                setName("Three_options");
                                                setTitle("Three_options");
                                                setColSpan("*");
                                                setRequired(true);
                                                setVertical(false);
                                                setRedrawOnChange(true);
                                                setWidth100();
                                                setValueMap(optionMap);
                                                // This line causes an exception:
                                                setDefaultValue(MyEnum.O1);
                                        }
                                };

                                myRGI.addChangedHandler(new ChangedHandler() {
                                        @Override
                                        public void onChanged(ChangedEvent event) {
                                                MyEnum selectedOption = (MyEnum) myRGI.getValue();
                                                SC.say(selectedOption.getValue());
                                        }
                                });

                                setFields(myRGI);
                        }
                };
                vStack.addMember(boundForm);
                vStack.draw();
        }

        public enum MyEnum {
                O1("One"), O2("Two"), O3("Three");

                private String value;

                MyEnum(String value) {
                        this.value = value;
                }

                public String getValue() {
                        return this.value;
                }
        }
}


Exception:
Code:

11:59:59.389 [ERROR] [builtinds] Unable to load module entry point class com.smartgwt.sample.client.BuiltInDS (see associated exception for details)
com.google.gwt.core.client.JavaScriptException: (null) @com.smartgwt.client.widgets.form.DynamicForm::create()([]): null
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
    at com.smartgwt.client.widgets.form.DynamicForm.create(DynamicForm.java)
    at com.smartgwt.client.widgets.BaseWidget.getOrCreateJsObj(BaseWidget.java:443)
    at com.smartgwt.client.widgets.layout.Layout.addMember(Layout.java:1267)
    at com.smartgwt.sample.client.BuiltInDS.onModuleLoad(BuiltInDS.java:73)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:406)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Unknown Source)

Best regards,
Blama

Viewing all articles
Browse latest Browse all 4756

Trending Articles