Announcement

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

    DateTimeItem: setValue() doesn't work as expected

    Hi Isomorphic,

    DateTimeItem.setValue() is not working as expected when it's used in "EditorExitHandler"

    SmartClient Version: v12.0p_2019-12-14/PowerEdition Deployment (built 2019-12-14)
    Google Chrome Version 79.0.3945.117 (Official Build) (64-bit)

    Click image for larger version

Name:	DateTimeItem setValue.gif
Views:	189
Size:	26.6 KB
ID:	260916

    Code:
    package com.smartgwt.sample.client;
    
    import java.util.Date;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.core.KeyIdentifier;
    import com.smartgwt.client.types.Alignment;
    import com.smartgwt.client.util.Page;
    import com.smartgwt.client.util.PageKeyHandler;
    import com.smartgwt.client.util.SC;
    import com.smartgwt.client.widgets.IButton;
    import com.smartgwt.client.widgets.Window;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.DateTimeItem;
    import com.smartgwt.client.widgets.form.fields.events.EditorExitEvent;
    import com.smartgwt.client.widgets.form.fields.events.EditorExitHandler;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class BuiltInDS extends VLayout implements EntryPoint {
        private IButton recreateBtn;
    
        public void onModuleLoad() {
            KeyIdentifier debugKey = new KeyIdentifier();
            debugKey.setCtrlKey(true);
            debugKey.setKeyName("D");
    
            Page.registerKey(debugKey, new PageKeyHandler() {
                public void execute(String keyName) {
                    SC.showConsole();
                }
            });
    
            setWidth100();
            setHeight100();
    
            recreateBtn = new IButton("Recreate");
            recreateBtn.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    new MyWindow().show();
                }
            });
            addMember(recreateBtn);
            new MyWindow().show();
            draw();
        }
    
        private class MyWindow extends Window {
            public MyWindow() {
                setWidth(400);
                setHeight(300);
                setMembersMargin(0);
                setModalMaskOpacity(70);
                setShowMinimizeButton(false);
                setIsModal(true);
                setShowModalMask(true);
                centerInPage();
    
                CustomDateTimeItem dti1 = new CustomDateTimeItem(true);
                dti1.setTitle("Exitor handler");
                CustomDateTimeItem dti2 = new CustomDateTimeItem(false);
                dti2.setTitle("Exitor handler not added");
                DynamicForm dF = new DynamicForm();
                dF.setFields(dti1, dti2);
                setMembers(dF);
            }
        }
    
        private class CustomDateTimeItem extends DateTimeItem {
            public CustomDateTimeItem(Boolean addExitorHandler) {
                if (addExitorHandler)
                    addEditorExitHandler(new EditorExitHandler() {
                        @Override
                        public void onEditorExit(EditorExitEvent event) {
                            event.getItem().setValue(new Date());
                        }
                    });
    
                setWidth("100%");
                setTitleColSpan(1);
                setTextAlign(Alignment.CENTER);
                setAlign(Alignment.LEFT);
                setShowPickerIcon(true);
                setUseTextField(true);
                setShowHintInField(true);
                setBrowserInputType("datetime");
            }
        }
    }
    Best regards
    Pavo

    #2
    A fix has been committed and will be available in nightly builds starting with Jan 31.

    Regards,
    Isomorphic Software

    Comment

    Working...
    X