Results 1 to 3 of 3

Thread: Spring Js and custom dojo widgets

Hybrid View

  1. #1
    Join Date
    May 2006
    Posts
    112

    Default Spring Js and custom dojo widgets

    hello,

    Is there a way in

    Code:
    Spring.addDecoration(new Spring.ElementDecoration({
    elementId : "${def.code}",
    widgetType : "dijit.form.NumberTextBox",								widgetAttrs : {promptMessage: "Enter a number",
                         value:'10',
                         required: "true",
                         style:"width:150px;",
                         invalidMessage: "Invalid number"}
    }));
    to use custom widget types like for e.g. the OracleDateTextBox on the dojo site(http://dojotoolkit.org/book/dojo-boo...urrency-number)

    ~s.

  2. #2
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Thumbs up

    Absolutely. You should be able to use any Dojo widget type that is available in your current environment.

    The specific case of using the example OracleDateTextBox is a little trickier, because the Spring.ElementDecoration assumes you need to have a dojo.require statement before constructing an instance of the widgetType. But there is an optional widgetModule parameter that is used when you need to require something other than the given widgetType.

    So in this specific case, the brute force way would be to put the custom widget declaration:

    Code:
    dojo.require("dijit.form.DateTextBox");
           
    dojo.declare("OracleDateTextBox",[dijit.form.DateTextBox], {
          serialize: function(d, options) {
             return dojo.date.locale.format(d, {selector:'date', datePattern:'dd-MMM-yyyy'}).toLowerCase();
           }
    });
    of the OracleDateTextBox in the <head> section of the page. Then the decoration could be something like:

    Code:
    Spring.addDecoration(new Spring.ElementDecoration({
    	elementId : "checkoutDate",
    	widgetType : "OracleDateTextBox",
            widgetModule : "dijit.form.DateTextBox",
    	widgetAttrs : { value : dojo.date.locale.parse(dojo.byId("checkoutDate").value, {selector : "date", datePattern : "yyyy-MM-dd"}), required : true }
    }));
    In this case the dojo.require of the widgetModule type would end up being a no-op since you already required "dijit.form.DateTextBox" in the <head>.

    The better way would be to package OracleDateTextBox into its own module (as the linked dojo docs suggest) so that it can be dojo.required without the additional widgetModule parameter in the decoration.
    Jeremy Grelle

    Staff Engineer, Web Products Team
    SpringSource

  3. #3
    Join Date
    Jan 2010
    Posts
    15

    Default Dojo Spring

    I am using date text box on my page.i am actually trying to populate a date field from the database if it exists show it in the datetextbox and provide the user an option to edit the field by providing a datetextbox.but when the page loads the field appears empty( If i right click and try to view the source of the page the datetextbox actually holds the value).if i refresh the page again i can see the date field value.Not sure what the problem is.Any help will be appreciated.my code looks something like this:

    <script type="text/javascript">
    dojo.require("dojo.parser");
    dojo.require("dijit.form.DateTextBox");
    dojo.declare("myDatetextBox",[dijit.form.DateTextBox], {
    serialize: function(d, options) {
    return dojo.date.locale.format(d, {selector:'date', datePattern:'dd-MMM-yyyy'}).toLowerCase();
    }
    });
    </script>
    </head>

    <form>
    <input dojoType="myDatetextBox" name="mydate" />
    //logic to get the value from database--using spring bind tags
    <input type="submit" value="go"/>
    </form>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •