nihad640 / smartgwt

Automatically exported from code.google.com/p/smartgwt
0 stars 0 forks source link

Exception on calling setHours or setMinutes on TimeItem #736

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When the setHours(int) or setMinutes(int) method of TimeItem is called, an 
exception is thrown. See the stacktrace below. Is there another way to set the 
time (as a work-around)?

Stacktrace:

google.gwt.core.client.JavaScriptException: (TypeError) 
@com.smartgwt.client.widgets.form.fields.TimeItem::setMinutes(I)([int: 22]): 
Object #<Object> has no method 'setMinutes'
    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.invokeNativeVoid(ModuleSpace.java:299)
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:107)
    at com.smartgwt.client.widgets.form.fields.TimeItem.setMinutes(TimeItem.java)

Original issue reported on code.google.com by sven.strohschein@googlemail.com on 28 Jan 2014 at 12:33

GoogleCodeExporter commented 9 years ago
Code which causes the problem:

    private static TimeItem createTimeItem(Integer aHours, Integer aMinutes) {
        final TimeItem theTimeItem = new TimeItem();
        theTimeItem.setShowTitle(false);
        theTimeItem.setUseTextField(false);
        theTimeItem.setShowHourItem(true);
        theTimeItem.setShowMinuteItem(true);
        theTimeItem.setShowSecondItem(false);
        theTimeItem.setShowMillisecondItem(false);
        theTimeItem.disable();
        if(aHours != null) {
            theTimeItem.setHours(aHours);
        }
        if(aMinutes != null) {
            theTimeItem.setMinutes(aMinutes);
        }
        return theTimeItem;
    }

Original comment by sven.strohschein@googlemail.com on 28 Jan 2014 at 12:35

GoogleCodeExporter commented 9 years ago
Use setValue() to set a value.  The crash above is happening because the value 
is currently null (we'll improve the error reporting).

Original comment by smartgwt...@gmail.com on 28 Jan 2014 at 5:22

GoogleCodeExporter commented 9 years ago
Ah, ok, that is working. Thank you for your fast support.

I would suggest to provide a better error message and to improve the 
documentation. I hadn't thought that it can be set with setValue, because the 
format isn't clear. Is there any documentation where it is described that the 
value can be set with setValue in combination with setInputFormat?

Original comment by sven.strohschein@googlemail.com on 28 Jan 2014 at 5:39

GoogleCodeExporter commented 9 years ago
There's no need to pass a String, setValue() has several signatures and one 
takes a Date.  However, be sure you have read the Date and Time Format and 
Storage overview so you correctly create the Date (with createLogicalTime()).

Original comment by smartgwt...@gmail.com on 28 Jan 2014 at 5:52