This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes Struts and the fly likes Struts 2 and Dojo (dojo undefined error) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 and Dojo (dojo undefined error)" Watch "Struts 2 and Dojo (dojo undefined error)" New topic

Struts 2 and Dojo (dojo undefined error)

Casey Cox

Joined: Nov 28, 2008
Posts: 14
Hi, I am trying to learn struts2, and what I want to do is display a datetimepicker on a jsp. From tutorials, it seems like I can use dojo to do it. But when I display the page, I get a "dojo is undefined" error, and sure enough, firebug tells me it is not able to locate the dojo js files.

This is how I am doing it. Can you please point me towards what I am missing.

1. jsp page:
In the HEAD section: <s:head theme="ajax" />
In the BODY section:
<s atetimepicker name="deliveryDate" displayFormat="yyyy-MM-dd"/>

2. in web.xml:

3. I have struts2-core-2.0.12.jar in the build path, which seems to contain all the js files that the jsp looks for, but I dont know why they don't get read. In desperation, I tried extracting the jars into the path that firebug showed me eg: /MyProject/struts/ajax/dojo/dojo.js, but I was just getting other errors, and I gave it up because that didnt seem to be right solution anyways.

It seems so simple on the tutorial site, but I have spent an unbelievable amount of time trying to get it to work. Any and all help greatly appreciated. Thanks much.
David Newton

Joined: Sep 29, 2008
Posts: 12617

IIRC there's a know issue w/ 2.0.12; try upgrading.
Casey Cox

Joined: Nov 28, 2008
Posts: 14
Thanks for the idea. I will give it a try.
Casey Cox

Joined: Nov 28, 2008
Posts: 14
It turns out my web application's structure was not entirely ideal. There wasn't a webroot folder housing the web-inf and other folders. Once I rearranged the project, dojo starting work properly. Whew!!

Thanks all!
Have you checked out Aspose?
subject: Struts 2 and Dojo (dojo undefined error)
It's not a secret anymore!