Topic
  • 20 replies
  • Latest Post - ‏2013-10-04T17:35:18Z by EGLcoder
M_F
M_F
53 Posts

Pinned topic DojoDateTextBox and MVC

‏2010-01-18T15:52:17Z |

Is there any known issue using DojoDateTextBox in a MVC form?
I can use DojoDateTextBox stand alone (even with the wrong format MM/dd/yyyy but at least it's working). When I include the widget in a Form I can see only the labels but not the fields (see attached image).
TIA
MarcoF


Attachments:
DojoDateTextBox.JPG
Updated on 2010-01-20T16:50:28Z at 2010-01-20T16:50:28Z by M_F
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-18T16:14:38Z  
    Hi,

    We don't know of any known problems like that. Can you provide some more information and upload your egl code?

    Thanks,
    George
  • M_F
    M_F
    53 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-18T17:40:44Z  
    Hi,

    We don't know of any known problems like that. Can you provide some more information and upload your egl code?

    Thanks,
    George

    A simplified version:
    package ProveMvc;

    import com.ibm.egl.rui.mvc.Controller;
    import com.ibm.egl.rui.mvc.FormField;
    import com.ibm.egl.rui.mvc.ValidatingForm;
    import com.ibm.egl.rui.mvc.mvc;
    import com.ibm.egl.rui.widgets.Button;
    import com.ibm.egl.rui.widgets.TextField;
    import com.ibm.egl.rui.widgets.TextLabel;
    import com.ibm.egl.rui.widgets.Box;
    import dojo.widgets.DojoDateTextBox;

    // RUI Handler
    //
    //
    handler ProvaMVCDate type RUIhandler {initialUI = Box ,onConstructionFunction = initialization, cssFile="css/TestVari.css"}
    Box Box{ padding=8,
    children = Form_Test, Load, Check ,
    columns = 1 };
    Load Button{ text = "Load", onClick ::= LoadForm };
    Check Button{ text = "Ok", onClick ::= CheckForm };
    Myr Myrecord{};
    f_Field1 TextField{};
    f_DATA1 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date" };
    f_DATA2 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date" };
    f_Field2 TextField{};
    c_Field1 Controller {
    @MVC { model=Myr.r_Field1 , view=f_Field1 as Widget }
    };
    c_DATA1 Controller {
    @MVC { model=Myr.r_DATA1 , view=f_DATA1 as Widget }
    };
    c_DATA2 Controller {
    @MVC { model=Myr.r_DATA2 , view=f_DATA2 as Widget }
    };
    c_Field2 Controller {
    @MVC { model=Myr.r_Field2 , view=f_Field2 as Widget }
    };
    entryFields FormField[] =[
    new FormField{displayName = "Field1: " ,controller = c_Field1},
    new FormField{displayName = "Date1: " ,controller = c_DATA1},
    new FormField{displayName = "Date2: " ,controller = c_DATA2},
    new FormField{displayName = "Field2: ", controller = c_Field2}
    ];
    Form_Test ValidatingForm{entries = entryFields};

    function initialization()
    end
    function LoadForm(e Event in)
    myr.r_Field1 = "Test1";
    myr.r_Field2 = "Test2";
    myr.r_DATA1 = 10/21/2009;
    myr.r_DATA2 = 08/15/2010;
    Form_Test.publish();
    end
    function CheckForm(e Event in)
    if (Form_Test.isValid() == true)
    Form_Test.commit();
    SysLib.writeStdout("Date1 is " + myr.r_DATA1);
    else;
    SysLib.writeStdout("Not valid");
    end
    end
    end
    record Myrecord type BasicRecord
    r_Field1 string;
    r_DATA1 date;
    r_DATA2 date;
    r_Field2 string;
    end
    at runtime:
    http://www-949.ibm.com/software/rational/cafe/servlet/JiveServlet/downloadImage/1834/DojoDateTextBox1.JPG
    TIA
    MarcoF!file:///C:/Users/Marco/Pictures/DojoDateTextBox1.JPG!
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-18T19:08:43Z  
    • M_F
    • ‏2010-01-18T17:40:44Z

    A simplified version:
    package ProveMvc;

    import com.ibm.egl.rui.mvc.Controller;
    import com.ibm.egl.rui.mvc.FormField;
    import com.ibm.egl.rui.mvc.ValidatingForm;
    import com.ibm.egl.rui.mvc.mvc;
    import com.ibm.egl.rui.widgets.Button;
    import com.ibm.egl.rui.widgets.TextField;
    import com.ibm.egl.rui.widgets.TextLabel;
    import com.ibm.egl.rui.widgets.Box;
    import dojo.widgets.DojoDateTextBox;

    // RUI Handler
    //
    //
    handler ProvaMVCDate type RUIhandler {initialUI = Box ,onConstructionFunction = initialization, cssFile="css/TestVari.css"}
    Box Box{ padding=8,
    children = Form_Test, Load, Check ,
    columns = 1 };
    Load Button{ text = "Load", onClick ::= LoadForm };
    Check Button{ text = "Ok", onClick ::= CheckForm };
    Myr Myrecord{};
    f_Field1 TextField{};
    f_DATA1 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date" };
    f_DATA2 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date" };
    f_Field2 TextField{};
    c_Field1 Controller {
    @MVC { model=Myr.r_Field1 , view=f_Field1 as Widget }
    };
    c_DATA1 Controller {
    @MVC { model=Myr.r_DATA1 , view=f_DATA1 as Widget }
    };
    c_DATA2 Controller {
    @MVC { model=Myr.r_DATA2 , view=f_DATA2 as Widget }
    };
    c_Field2 Controller {
    @MVC { model=Myr.r_Field2 , view=f_Field2 as Widget }
    };
    entryFields FormField[] =[
    new FormField{displayName = "Field1: " ,controller = c_Field1},
    new FormField{displayName = "Date1: " ,controller = c_DATA1},
    new FormField{displayName = "Date2: " ,controller = c_DATA2},
    new FormField{displayName = "Field2: ", controller = c_Field2}
    ];
    Form_Test ValidatingForm{entries = entryFields};

    function initialization()
    end
    function LoadForm(e Event in)
    myr.r_Field1 = "Test1";
    myr.r_Field2 = "Test2";
    myr.r_DATA1 = 10/21/2009;
    myr.r_DATA2 = 08/15/2010;
    Form_Test.publish();
    end
    function CheckForm(e Event in)
    if (Form_Test.isValid() == true)
    Form_Test.commit();
    SysLib.writeStdout("Date1 is " + myr.r_DATA1);
    else;
    SysLib.writeStdout("Not valid");
    end
    end
    end
    record Myrecord type BasicRecord
    r_Field1 string;
    r_DATA1 date;
    r_DATA2 date;
    r_Field2 string;
    end
    at runtime:
    http://www-949.ibm.com/software/rational/cafe/servlet/JiveServlet/downloadImage/1834/DojoDateTextBox1.JPG
    TIA
    MarcoF!file:///C:/Users/Marco/Pictures/DojoDateTextBox1.JPG!
    Hi,

    There is a bug in DojoDateTextBox. Thanks for this, we've opened a defect and this will be fixed in the next release. For now you'll have to put "value = NULL" as a property.

    Take care,
    George
  • M_F
    M_F
    53 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-19T09:42:04Z  
    Hi,

    There is a bug in DojoDateTextBox. Thanks for this, we've opened a defect and this will be fixed in the next release. For now you'll have to put "value = NULL" as a property.

    Take care,
    George

    Thanks George, that means I can't use DojoDateTextBox with MVC till the new release?
    I made some tests and indeed the widget (used outside an MVC) it's working, i can assign a date to the widget.value and back from widget to date using mydatefield = datetimelib.dateValue(Mydojodatetexbox.value as string);
    I tried the same in a MVC scenario (assuming that the helpers get and return strings) but it's not working.
    Any idea?
    TIA
    MarcoF
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-19T12:08:37Z  
    • M_F
    • ‏2010-01-19T09:42:04Z

    Thanks George, that means I can't use DojoDateTextBox with MVC till the new release?
    I made some tests and indeed the widget (used outside an MVC) it's working, i can assign a date to the widget.value and back from widget to date using mydatefield = datetimelib.dateValue(Mydojodatetexbox.value as string);
    I tried the same in a MVC scenario (assuming that the helpers get and return strings) but it's not working.
    Any idea?
    TIA
    MarcoF
    You can still use Dojo data text boxes with MVC. Sure. In the declaration of your date text box, just say "value=null".

    In DojoDataTextBox.egl, the "value" field is declared as a @JavaScriptProperty. This means it has getter and setter functions in JavaScript. We use the "setValue" setter function in the JavaScript implementation of our EGL wrapper as a trigger to actually create the real Dojo widget. If you do not set any value, the actual Dojo widget is not created.

    Here is an example:

    f_DATA2 DojoDateTextBox{ 
        formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, 
        errorMessage = "Wrong date",
        value = null
    };
    


    As George said, this will be fixed in the next release of our Dojo widgets. We will make sure the actual Dojo widget is created even when the text box does not get an initial value.

    Chris
    Updated on 2014-03-25T05:22:48Z at 2014-03-25T05:22:48Z by iron-man
  • M_F
    M_F
    53 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-19T13:59:39Z  
    You can still use Dojo data text boxes with MVC. Sure. In the declaration of your date text box, just say "value=null".

    In DojoDataTextBox.egl, the "value" field is declared as a @JavaScriptProperty. This means it has getter and setter functions in JavaScript. We use the "setValue" setter function in the JavaScript implementation of our EGL wrapper as a trigger to actually create the real Dojo widget. If you do not set any value, the actual Dojo widget is not created.

    Here is an example:

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr">f_DATA2 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date", value = null }; </pre>

    As George said, this will be fixed in the next release of our Dojo widgets. We will make sure the actual Dojo widget is created even when the text box does not get an initial value.

    Chris

    Hi Chris, thanks for the clarification but indeed I already set the value to null and the text box appears (with the current date even if the record's date is empty).
    What is not working (?) is the MVC, I mean if I set the record's fields e try to publish I don't get the dates as for the original record. When commit also get back wrong dates.
    Probably I'm just making a stupid error but I can't see it.
    Here is the code:
    package ProveMvc;

    import com.ibm.egl.rui.mvc.Controller;
    import com.ibm.egl.rui.mvc.FormField;
    import com.ibm.egl.rui.mvc.ValidatingForm;
    import com.ibm.egl.rui.mvc.mvc;
    import com.ibm.egl.rui.widgets.Button;
    import com.ibm.egl.rui.widgets.TextField;
    import com.ibm.egl.rui.widgets.TextLabel;
    import com.ibm.egl.rui.widgets.Box;
    import dojo.widgets.DojoDateTextBox;

    // RUI Handler
    //
    //
    handler ProvaMVCDateII type RUIhandler {initialUI = Box ,onConstructionFunction = initialization, cssFile="css/TestVari.css"}
    Box Box{ padding=8,
    children = Form_Test, Load, Check ,
    columns = 1 };
    Load Button{ text = "Load", onClick ::= LoadForm };
    Check Button{ text = "Ok", onClick ::= CheckForm };
    Myr Myrecord{};
    f_Field1 TextField{};
    f_DATA1 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date", value = null };
    f_DATA2 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date", value = null };
    f_Field2 TextField{};
    c_Field1 Controller {@MVC { model=Myr.r_Field1 , view=f_Field1 as Widget }};
    c_DATA1 Controller {@MVC { model=Myr.r_DATA1 , view=f_DATA1 as Widget }};
    c_DATA2 Controller {@MVC { model=Myr.r_DATA2 , view=f_DATA2 as Widget }};
    c_Field2 Controller {@MVC { model=Myr.r_Field2 , view=f_Field2 as Widget }};
    entryFields FormField[] =[
    new FormField{displayName = "Field1: " ,controller = c_Field1},
    new FormField{displayName = "Date1: " ,controller = c_DATA1},
    new FormField{displayName = "Date2: " ,controller = c_DATA2},
    new FormField{displayName = "Field2: ", controller = c_Field2}
    ];
    Form_Test ValidatingForm{entries = entryFields};

    function initialization()
    end
    function LoadForm(e Event in)
    SysLib.writeStdout("Load");
    myr.r_Field1 = "Test1";
    myr.r_Field2 = "Test2";
    myr.r_DATA1 = datetimelib.dateValue("10/08/2010");
    myr.r_DATA2 = datetimelib.dateValue("04/22/2009");
    Form_Test.publish();
    end
    function CheckForm(e Event in)
    SysLib.writeStdout("Check");
    if (Form_Test.isValid() == true)
    Form_Test.commit();
    SysLib.writeStdout("Date1 is " + myr.r_DATA1);
    SysLib.writeStdout("f_Date1 is " + f_DATA1.value);
    else;
    SysLib.writeStdout("Not valid");
    end
    end
    end

    record Myrecord type BasicRecord
    r_Field1 string;
    r_DATA1 date;
    r_DATA2 date;
    r_Field2 string;
    end
    and attached you can see:
    1 - the initial screen (the record is empty)
    2 - record with values and form published
    3 - the first date changed and the form committed.
    TIA
    MarcoF
    Attachments:
    DojoDateTextBox03.JPG
    DojoDateTextBox02.JPG
    DojoDateTextBox01.JPG
  • M_F
    M_F
    53 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-20T11:07:59Z  
    Sorry Marco, I did not really take a close enough look at your sample. You were missing some MVC helper functions. See F1 and search for MVC, and then scroll down to the section mentioning "helper".

    See also http://www-949.ibm.com/software/rational/cafe/markuphelpfull.jspa for tips on how to format your code snippets in forum posts (it will make them easier to read for others :-) )

    Anyway, I enclosed a working sample that uses 2 Dojo date text boxes and that adds validation to the form also.

    See the helper functions below:

    
    package mvc;

    import com.ibm.egl.rui.mvc.Controller;
    import com.ibm.egl.rui.mvc.FormField;
    import com.ibm.egl.rui.mvc.MVC;
    import com.ibm.egl.rui.mvc.ValidatingForm;
    import com.ibm.egl.rui.widgets.Div;
    import com.ibm.egl.rui.widgets.HTML;
    import com.ibm.egl.rui.widgets.TextField;
    import egl.ui.rui.Event;
    import egl.ui.rui.Widget;
    import dojo.widgets.DojoButton;
    import dojo.widgets.DojoDateTextBox;
    import dojo.widgets.DojoDialog;


    record MyRecord type BasicRecord
    title string { @inputRequired, InputRequiredMsgKey = "title", validationPropertiesLibrary = WorkItemFormMessages };
    startDate date { @inputRequired };
    endDate date { @inputRequired };
    note string { @inputRequired, InputRequiredMsgKey = "note", validationPropertiesLibrary = WorkItemFormMessages };
    end

    handler mvc type RUIhandler{initialUI = ui }

    model MyRecord{ };

    title TextField{
    marginBottom = 9, marginLeft = 9, width = 360
    };
    startDate DojoDateTextBox {
    marginBottom = 9, marginLeft = 9,
    formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG,
    errorMessage = "Invalid start date"
    };
    endDate DojoDateTextBox{
    marginBottom = 9, marginLeft = 9,
    formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG,
    errorMessage = "Invalid end date"
    };
    note TextField{
    marginBottom = 9, marginLeft = 9, width = 360
    };

    titleController Controller {
    @MVC{model = model.title, view = title as Widget}
    };
    startDateController Controller {
    // define the four helpers before we set the view and model
    retrieveViewHelper = getStartDateValue,
    publishHelper = setStartDateValue,
    // set the model and view after setting up the helpers
    @MVC{model = model.startDate, view = startDate as Widget}
    };
    endDateController Controller {
    // define the four helpers before we set the view and model
    retrieveViewHelper = getEndDateValue,
    publishHelper = setEndDateValue,
    validators = checkEndDate ,
    // set the model and view after setting up the helpers
    @MVC{model = model.endDate, view = endDate as Widget}
    };
    noteController Controller {
    @MVC{model = model.note, view = note as Widget }
    };

    entryFields FormField[] =[
    new FormField { displayName = "Title: ", controller = titleController },
    new FormField { displayName = "Start date: ", controller = startDateController },
    new FormField { displayName = "End date: ", controller = endDateController },
    new FormField { displayName = "Note: ", controller = noteController }
    ];

    validatingForm ValidatingForm {
    entries = entryFields
    };

    ui Div { padding = 8, children = [
    new HTML { marginBottom = 7, text = "
    <h1>MVC Demo with Dojo widgets</h1>"},
    new DojoButton {
    text = "Load", onClick ::= loadForm
    },
    new Div {
    padding = 9, marginTop = 9, marginBottom = 9, paddingTop = 7,
    width = 530, backgroundColor = "lightyellow",
    borderWidth = 2, borderColor = "grey", borderStyle = "solid", children = [
    validatingForm
    ]
    },
    new DojoButton {
    text = "Submit", onClick ::= submitForm
    }
    ]};

    function loadForm(e Event in)
    model.title = "Work Item 33245: Manufacturing";
    model.note = "Specifications offered by the Acme corporation";
    model.startDate = datetimelib.dateValue("10/08/2010");
    model.endDate = datetimelib.dateValue("10/07/2010");
    validatingForm.publish();
    end

    message HTML { padding = 13, color = "white" };
    dialog DojoDialog {
    title = "Form Validation", children = message
    };

    function submitForm(e Event in)
    if (validatingForm.isValid() == true)
    validatingForm.commit();
    message.text = "Validation was successful.

    " +
    "Start date for " + model.title + " is " + model.startDate + ".
    " +
    "Should be finished by " + model.endDate + ".

    " +
    "Note = " + model.note;
    message.background = "green";
    else
    message.text = "Validation was unsuccessful.

    Invalid values entered by user.";
    message.background = "red";
    end
    dialog.showDialog();
    end

    function checkEndDate(value String in) returns(String?)
    if (startDate.value >= endDate.value)
    return (WorkItemFormMessages.invalidDate); // should use RUIPropertyLibrary
    end
    end

    //
    // The following functions teach MVC about unknown widgets, in this case DojoDateTextBox
    //
    function setStartDateValue(value string in)
    startDate.value = value;
    end
    function getStartDateValue() returns(string)
    return (startDate.value);
    end
    function setEndDateValue(value string in)
    endDate.value = value;
    end
    function getEndDateValue() returns(string)
    return (endDate.value);
    end

    end


    Hope this helps,

    Chris
    Attachments:
    mvc.zip

    Hi Chris, thanks the example was very clear but I'm afraid there is something not working on my RBD installation since what I get is:
    DojoDateTextBox11.JPG
    I added values = null in the DOjoDateTextBox declaration but it's the same.
    TIA
    MarcoF
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-20T13:17:22Z  
    • M_F
    • ‏2010-01-20T11:07:59Z

    Hi Chris, thanks the example was very clear but I'm afraid there is something not working on my RBD installation since what I get is:
    DojoDateTextBox11.JPG
    I added values = null in the DOjoDateTextBox declaration but it's the same.
    TIA
    MarcoF
    You are right. Doh... I forgot to add a fix to DojoDateTextBox. Please try again with the enclosed mvc.zip.

    Chris
    Attachments:
    mvc.zip
    Updated on 2010-01-20T13:17:22Z at 2010-01-20T13:17:22Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    6195 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-20T13:18:00Z  
    • M_F
    • ‏2010-01-19T13:59:39Z

    Hi Chris, thanks for the clarification but indeed I already set the value to null and the text box appears (with the current date even if the record's date is empty).
    What is not working (?) is the MVC, I mean if I set the record's fields e try to publish I don't get the dates as for the original record. When commit also get back wrong dates.
    Probably I'm just making a stupid error but I can't see it.
    Here is the code:
    package ProveMvc;

    import com.ibm.egl.rui.mvc.Controller;
    import com.ibm.egl.rui.mvc.FormField;
    import com.ibm.egl.rui.mvc.ValidatingForm;
    import com.ibm.egl.rui.mvc.mvc;
    import com.ibm.egl.rui.widgets.Button;
    import com.ibm.egl.rui.widgets.TextField;
    import com.ibm.egl.rui.widgets.TextLabel;
    import com.ibm.egl.rui.widgets.Box;
    import dojo.widgets.DojoDateTextBox;

    // RUI Handler
    //
    //
    handler ProvaMVCDateII type RUIhandler {initialUI = Box ,onConstructionFunction = initialization, cssFile="css/TestVari.css"}
    Box Box{ padding=8,
    children = Form_Test, Load, Check ,
    columns = 1 };
    Load Button{ text = "Load", onClick ::= LoadForm };
    Check Button{ text = "Ok", onClick ::= CheckForm };
    Myr Myrecord{};
    f_Field1 TextField{};
    f_DATA1 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date", value = null };
    f_DATA2 DojoDateTextBox{ formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG, errorMessage = "Wrong date", value = null };
    f_Field2 TextField{};
    c_Field1 Controller {@MVC { model=Myr.r_Field1 , view=f_Field1 as Widget }};
    c_DATA1 Controller {@MVC { model=Myr.r_DATA1 , view=f_DATA1 as Widget }};
    c_DATA2 Controller {@MVC { model=Myr.r_DATA2 , view=f_DATA2 as Widget }};
    c_Field2 Controller {@MVC { model=Myr.r_Field2 , view=f_Field2 as Widget }};
    entryFields FormField[] =[
    new FormField{displayName = "Field1: " ,controller = c_Field1},
    new FormField{displayName = "Date1: " ,controller = c_DATA1},
    new FormField{displayName = "Date2: " ,controller = c_DATA2},
    new FormField{displayName = "Field2: ", controller = c_Field2}
    ];
    Form_Test ValidatingForm{entries = entryFields};

    function initialization()
    end
    function LoadForm(e Event in)
    SysLib.writeStdout("Load");
    myr.r_Field1 = "Test1";
    myr.r_Field2 = "Test2";
    myr.r_DATA1 = datetimelib.dateValue("10/08/2010");
    myr.r_DATA2 = datetimelib.dateValue("04/22/2009");
    Form_Test.publish();
    end
    function CheckForm(e Event in)
    SysLib.writeStdout("Check");
    if (Form_Test.isValid() == true)
    Form_Test.commit();
    SysLib.writeStdout("Date1 is " + myr.r_DATA1);
    SysLib.writeStdout("f_Date1 is " + f_DATA1.value);
    else;
    SysLib.writeStdout("Not valid");
    end
    end
    end

    record Myrecord type BasicRecord
    r_Field1 string;
    r_DATA1 date;
    r_DATA2 date;
    r_Field2 string;
    end
    and attached you can see:
    1 - the initial screen (the record is empty)
    2 - record with values and form published
    3 - the first date changed and the form committed.
    TIA
    MarcoF
    Attachments:
    DojoDateTextBox03.JPG
    DojoDateTextBox02.JPG
    DojoDateTextBox01.JPG
    Sorry Marco, I did not really take a close enough look at your sample. You were missing some MVC helper functions. See F1 and search for MVC, and then scroll down to the section mentioning "helper".

    See also http://www-949.ibm.com/software/rational/cafe/markuphelpfull.jspa for tips on how to format your code snippets in forum posts (it will make them easier to read for others :-) )

    Anyway, I enclosed a working sample that uses 2 Dojo date text boxes and that adds validation to the form also.

    See the helper functions below:

    package mvc;

    import com.ibm.egl.rui.mvc.Controller;
    import com.ibm.egl.rui.mvc.FormField;
    import com.ibm.egl.rui.mvc.MVC;
    import com.ibm.egl.rui.mvc.ValidatingForm;
    import com.ibm.egl.rui.widgets.Div;
    import com.ibm.egl.rui.widgets.HTML;
    import com.ibm.egl.rui.widgets.TextField;
    import egl.ui.rui.Event;
    import egl.ui.rui.Widget;
    import dojo.widgets.DojoButton;
    import dojo.widgets.DojoDateTextBox;
    import dojo.widgets.DojoDialog;


    record MyRecord type BasicRecord
    title string { @inputRequired, InputRequiredMsgKey = "title", validationPropertiesLibrary = WorkItemFormMessages };
    startDate date { @inputRequired };
    endDate date { @inputRequired };
    note string { @inputRequired, InputRequiredMsgKey = "note", validationPropertiesLibrary = WorkItemFormMessages };
    end

    handler mvc type RUIhandler{initialUI = ui }

    model MyRecord{ };

    title TextField{
    marginBottom = 9, marginLeft = 9, width = 360
    };
    startDate DojoDateTextBox {
    marginBottom = 9, marginLeft = 9,
    formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG,
    errorMessage = "Invalid start date"
    };
    endDate DojoDateTextBox{
    marginBottom = 9, marginLeft = 9,
    formatLength = dojo.widgets.DojoLib.DATEBOX_FORMAT_LONG,
    errorMessage = "Invalid end date"
    };
    note TextField{
    marginBottom = 9, marginLeft = 9, width = 360
    };

    titleController Controller {
    @MVC{model = model.title, view = title as Widget}
    };
    startDateController Controller {
    // define the four helpers before we set the view and model
    retrieveViewHelper = getStartDateValue,
    publishHelper = setStartDateValue,
    // set the model and view after setting up the helpers
    @MVC{model = model.startDate, view = startDate as Widget}
    };
    endDateController Controller {
    // define the four helpers before we set the view and model
    retrieveViewHelper = getEndDateValue,
    publishHelper = setEndDateValue,
    validators = checkEndDate ,
    // set the model and view after setting up the helpers
    @MVC{model = model.endDate, view = endDate as Widget}
    };
    noteController Controller {
    @MVC{model = model.note, view = note as Widget }
    };

    entryFields FormField[] =[
    new FormField { displayName = "Title: ", controller = titleController },
    new FormField { displayName = "Start date: ", controller = startDateController },
    new FormField { displayName = "End date: ", controller = endDateController },
    new FormField { displayName = "Note: ", controller = noteController }
    ];

    validatingForm ValidatingForm {
    entries = entryFields
    };

    ui Div { padding = 8, children = [
    new HTML { marginBottom = 7, text = "
    <h1>MVC Demo with Dojo widgets</h1>"},
    new DojoButton {
    text = "Load", onClick ::= loadForm
    },
    new Div {
    padding = 9, marginTop = 9, marginBottom = 9, paddingTop = 7,
    width = 530, backgroundColor = "lightyellow",
    borderWidth = 2, borderColor = "grey", borderStyle = "solid", children = [
    validatingForm
    ]
    },
    new DojoButton {
    text = "Submit", onClick ::= submitForm
    }
    ]};

    function loadForm(e Event in)
    model.title = "Work Item 33245: Manufacturing";
    model.note = "Specifications offered by the Acme corporation";
    model.startDate = datetimelib.dateValue("10/08/2010");
    model.endDate = datetimelib.dateValue("10/07/2010");
    validatingForm.publish();
    end

    message HTML { padding = 13, color = "white" };
    dialog DojoDialog {
    title = "Form Validation", children = message
    };

    function submitForm(e Event in)
    if (validatingForm.isValid() == true)
    validatingForm.commit();
    message.text = "Validation was successful.

    " +
    "Start date for " + model.title + " is " + model.startDate + ".
    " +
    "Should be finished by " + model.endDate + ".

    " +
    "Note = " + model.note;
    message.background = "green";
    else
    message.text = "Validation was unsuccessful.

    Invalid values entered by user.";
    message.background = "red";
    end
    dialog.showDialog();
    end

    function checkEndDate(value String in) returns(String?)
    if (startDate.value >= endDate.value)
    return (WorkItemFormMessages.invalidDate); // should use RUIPropertyLibrary
    end
    end

    //
    // The following functions teach MVC about unknown widgets, in this case DojoDateTextBox
    //
    function setStartDateValue(value string in)
    startDate.value = value;
    end
    function getStartDateValue() returns(string)
    return (startDate.value);
    end
    function setEndDateValue(value string in)
    endDate.value = value;
    end
    function getEndDateValue() returns(string)
    return (endDate.value);
    end

    end


    Hope this helps,

    Chris
    Attachments:
    mvc.zip
    Updated on 2010-01-20T13:18:00Z at 2010-01-20T13:18:00Z by SystemAdmin
  • M_F
    M_F
    53 Posts

    Re: DojoDateTextBox and MVC

    ‏2010-01-20T16:50:28Z  
    You are right. Doh... I forgot to add a fix to DojoDateTextBox. Please try again with the enclosed mvc.zip.

    Chris
    Attachments:
    mvc.zip

    Hi Chris, it's working (as desinged !http://www-949.ibm.com/software/rational/cafe/images/emoticons/wink.gif!) now. Just the last question: what about null dates? Any kind of support in DojoDateTextBox? I modified in LoadForm "model.startDate = null;" but the published date is the current one. Of course I also need to clear a date field to set the record date to null.
    TIA
    MarcoF
  • EGLcoder
    EGLcoder
    19 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-09-27T19:33:25Z  
    • M_F
    • ‏2010-01-20T16:50:28Z

    Hi Chris, it's working (as desinged !http://www-949.ibm.com/software/rational/cafe/images/emoticons/wink.gif!) now. Just the last question: what about null dates? Any kind of support in DojoDateTextBox? I modified in LoadForm "model.startDate = null;" but the published date is the current one. Of course I also need to clear a date field to set the record date to null.
    TIA
    MarcoF

    Did you ever receive a solution to the issue of support of null dates using the DojoDateTextBox?  I need to be able to enter a null date and want to use the DojoDateTextBox.

     

    Thanks,

    Rosanne

     

  • M_F
    M_F
    53 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-09-29T16:37:36Z  
    • EGLcoder
    • ‏2013-09-27T19:33:25Z

    Did you ever receive a solution to the issue of support of null dates using the DojoDateTextBox?  I need to be able to enter a null date and want to use the DojoDateTextBox.

     

    Thanks,

    Rosanne

     

    Hi, no I didn't receive a working solution about null date.

     

    HTH

    MarcoF

  • M Groeneweg
    M Groeneweg
    80 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-09-30T05:33:10Z  

    We had trouble with nullable dates and MVC too. For RBD 8.5.1 there is a testfix. I have not yet installed 8.5.1.1 but I assume it will be included.

     

    Marcel

  • canutri
    canutri
    354 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-01T12:12:12Z  

    We had trouble with nullable dates and MVC too. For RBD 8.5.1 there is a testfix. I have not yet installed 8.5.1.1 but I assume it will be included.

     

    Marcel

    Hi Marcel,

    Do you have an id for the RBD 8.5.1 testfix?  I think we may end up needing it for our project and would like to request it from IBM Support and verify it is compatible with RBD 8.5.1.1

    Thanks,

    Daron

  • markevans
    markevans
    2807 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-01T14:09:41Z  
    • canutri
    • ‏2013-10-01T12:12:12Z

    Hi Marcel,

    Do you have an id for the RBD 8.5.1 testfix?  I think we may end up needing it for our project and would like to request it from IBM Support and verify it is compatible with RBD 8.5.1.1

    Thanks,

    Daron

    Marcel,

    I have looked but cannot identify the specific fixtest you received.  If you can provide the name or APAR, then I can look it up and see if it is in 8.5.1.1.

     

    Mark

     

  • M Groeneweg
    M Groeneweg
    80 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-01T18:17:33Z  
    • markevans
    • ‏2013-10-01T14:09:41Z

    Marcel,

    I have looked but cannot identify the specific fixtest you received.  If you can provide the name or APAR, then I can look it up and see if it is in 8.5.1.1.

     

    Mark

     

    It appears I got a fix outside a PMR traject.

    Apart from the fix, you need to explicitly set inputRequired=false on the widget.

    Maybe this already got included in 8511, but this is the answer I got:

     

    Try to change the following functions in com.ibm.egl.rui.dojo.widgets_2.1.2/WebContent/dojo/widgets/DojoDateTextBox.js 
        "getValueAsText" : function(){ 
                    var date = this.getValue(); 
                    return date ? egl.egl.core.$StrLib.formatDate(date) : ""
            }, 
            "setValueAsText" : function(date){ 
                  this.setValue(date ? egl.egl.core.$DateTimeLib.dateValue(date) : null); 
            }

  • markevans
    markevans
    2807 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-01T18:51:49Z  

    It appears I got a fix outside a PMR traject.

    Apart from the fix, you need to explicitly set inputRequired=false on the widget.

    Maybe this already got included in 8511, but this is the answer I got:

     

    Try to change the following functions in com.ibm.egl.rui.dojo.widgets_2.1.2/WebContent/dojo/widgets/DojoDateTextBox.js 
        "getValueAsText" : function(){ 
                    var date = this.getValue(); 
                    return date ? egl.egl.core.$StrLib.formatDate(date) : ""
            }, 
            "setValueAsText" : function(date){ 
                  this.setValue(date ? egl.egl.core.$DateTimeLib.dateValue(date) : null); 
            }

    Marcel,

    Thanks.

    I took a look at the 8.5.1.1 DojoDateTextBox.js and the changes you listed above are included. ..

    So looks like they are there.

  • EGLcoder
    EGLcoder
    19 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-04T17:22:45Z  
    • markevans
    • ‏2013-10-01T18:51:49Z

    Marcel,

    Thanks.

    I took a look at the 8.5.1.1 DojoDateTextBox.js and the changes you listed above are included. ..

    So looks like they are there.

    Mark,

    I noticed that the DojoDateTextBox.js fix was included in the latest version of dojo.widgets_2.1.4  with v8.5.1.1, however, I am getting the following errors and my inputRequired on the DojoDateTextBox is false:

    [CRRUI1083E] An error occurred while the click browser event was being handled.
    [CRRUI2017E] The value "" of type string cannot be converted to type date
    [CRRUI2094E] Here are the EGL function calls leading to this error:

        DateTimeLib.DateTimeLib.dateValue() [native JavaScript]
        DojoDateTextBox.DojoDateTextBox.setText() [native JavaScript]
        EditRegistration.loadData() [native JavaScript]
        InfoBus.publish() [native JavaScript]
        RegistrationMaintenance.itemRegistration_ui_onClick() [native JavaScript]
        DataGrid.notifySelectionChangeListeners() [native JavaScript]
        DataGrid.clickGrid() [native JavaScript]
        Div.Widget.runEventHandlers() [native JavaScript]
        Event click() [native JavaScript]

     


     

  • markevans
    markevans
    2807 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-04T17:30:11Z  
    • EGLcoder
    • ‏2013-10-04T17:22:45Z

    Mark,

    I noticed that the DojoDateTextBox.js fix was included in the latest version of dojo.widgets_2.1.4  with v8.5.1.1, however, I am getting the following errors and my inputRequired on the DojoDateTextBox is false:

    [CRRUI1083E] An error occurred while the click browser event was being handled.
    [CRRUI2017E] The value "" of type string cannot be converted to type date
    [CRRUI2094E] Here are the EGL function calls leading to this error:

        DateTimeLib.DateTimeLib.dateValue() [native JavaScript]
        DojoDateTextBox.DojoDateTextBox.setText() [native JavaScript]
        EditRegistration.loadData() [native JavaScript]
        InfoBus.publish() [native JavaScript]
        RegistrationMaintenance.itemRegistration_ui_onClick() [native JavaScript]
        DataGrid.notifySelectionChangeListeners() [native JavaScript]
        DataGrid.clickGrid() [native JavaScript]
        Div.Widget.runEventHandlers() [native JavaScript]
        Event click() [native JavaScript]

     


     

    I would suggest you go ahead and open a PMR.   I will also forward this to the developer.

  • EGLcoder
    EGLcoder
    19 Posts

    Re: DojoDateTextBox and MVC

    ‏2013-10-04T17:35:18Z  
    • markevans
    • ‏2013-10-04T17:30:11Z

    I would suggest you go ahead and open a PMR.   I will also forward this to the developer.

    Thank you Mark, I will do that.