Jugal wrote:
Thanks for your reply Jeromy..
I have made changes according to the inputs provided by you... After change
my JSP looks something like this...

<head>
        <s:head theme="simple" debug="true"/>

I recommend using the ajax theme until everything works, then step backwards to simple. It's too easy to miss something if you do it by hand. Try to minimize the possible causes of errors.
        
        <script type="text/javascript">
                dojo.require("dojo.widget.*");
                dojo.require("dojo.event.*");
        </script>
        
        <script type="text/javascript">         
function init() {
                   var datePicker = dojo.widget.byId("leasingStartDate");
                   dojo.event.connect(datePicker, "onchange", 
"calculateEndDate");
                }
                
As per my original email, I'm quite certain the event's called onValueChanged in this version. onchange is actually a DOM event whereas connect is using dojo's AOP's features to intercept a call to the onValueChanged function of the widget. Big difference.

So you're back to this:

                function calculateEndDate() {
                        alert("Calculating...");
                        startDate = 
document.forms[0].elements['leasingStartDate.value'].value;
                        alert(startDate);
                }               

                function init() {
                   var datePicker = dojo.widget.byId("leasingStartDate");
                  dojo.event.connect(datePicker, "onValueChanged", 
calculateEndDate);
                }

Note I've used a function reference rather than "calculateEndDate".

If you're using Struts2.0.x you are using Dojo 0.40. If you're using Struts2.1.x you're using Dojo 0.43 The event API for 0.43 (similar to 0.40) is at http://download.dojotoolkit.org/release-0.4.3/dojo-0.4.3-src/api/#dojo.event
You'll find more examples by googling the Dojo Datepicker.

While we're on the topic, you may prefer to read the value from the widget rather than try to get it from a form element:
replace:

startDate = document.forms[0].elements['leasingStartDate.value'].value;

with:

var datePicker = dojo.widget.byId("leasingStartDate");

startDate = datePicker.getValue(); // or datePicker.getDate() if you want a Javacript date rather an a string

But still I am not able to invoke an onchage event on datetimepicker... Also
when i set the dojo in debug mode.. I get the following error.. FATAL
exception raised: Could not load 'dojo.debug'; last tried '__package__.js'

That probably means a file is still missing. It's best to use s:head theme=ajax until it works and then try to convert it to simple. Use Firebug to debug these errors. It'll show the 404 and/or the source of the javascript error.

regards,
Jeromy Evans


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to