my dog learned polymorphism*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 and Dojo (dojo undefined error)" Watch "Struts 2 and Dojo (dojo undefined error)" New topic
Author

Struts 2 and Dojo (dojo undefined error)

Casey Cox
Greenhorn

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:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

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
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

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

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!
 
 
subject: Struts 2 and Dojo (dojo undefined error)