views:

356

answers:

1

I am taking a prototype of a web page and implementing it. The prototype makes heavy use of DOJO for some fancy UI elements. The application is built using Struts 2.1.8.1 with the DOJO plugin enabled. I am able to use the dojo specific tags within struts but I can't get the any of the dijit widgets to work.

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<html xmlns="\&quot;http://www.w3.org/1999/xhtml\&amp;quot;" xml:lang="\&quot;en\&quot;" lang="\&quot;en\&quot;">

<head>
    <sx:head parseContent="true" />
    <script type="text/javascript"> 
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
dojo.require("dijit.form.TextBox");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.form.TimeTextBox");
dojo.require("dijit.form.Slider");
dojo.require("dijit.Menu");
       dojo.require("dijit.layout.AccordionContainer");    
       dojo.require("dojox.charting.Chart2D");
       dojo.require("dojox.charting.themes.PlotKit.blue");
       dojo.require("dojox.charting.themes.PlotKit.orange");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.SplitContainer");
dojo.require("dijit.form.DateTextBox");
dojo.require("dijit.Tooltip");
   </script>

The error I'm getting is:

GET http://localhost:9080/quickstart/struts/dijit/Dialog.js
GET http://localhost:9080/quickstart/struts/dijit/Dialog.js 
404 Not Found

struts_dojo.js (line 769)
GET http://localhost:9080/quickstart/struts/dijit.js
GET http://localhost:9080/quickstart/struts/dijit.js
404 Not Found

struts_dojo.js (line 769)
ParamsHeadersPostPutResponseCacheHTML
Error 404: Error reported: 404

GET http://localhost:9080/quickstart/struts/dojo/__package__.js
GET http://localhost:9080/quickstart/struts/dojo/__package__.js
404 Not Found

struts_dojo.js (line 769)
ParamsHeadersPostPutResponseCacheHTML
Error 404: Error reported: 404

Could not load 'dijit.Dialog'; last tried '__package__.js'
[Break on this error] throw _13||Error(_12); 

Do I need to make a special build of Dojo to get access to these dijit widgets?

+1  A: 

The answer is because struts, as late as Struts 2.1.8.1 which is the most recent version as I am writing this, includes DOJO 0.4. Dijit seems to have been introduced sometime after Dojo 1.0. (Current version is 1.4).

The widget library to use with Struts is Dojo.widget which gets loaded by default with struts.

Kyle Boon
Dojo 0.4 is something like 3 years old. You should definitely try to use Dijit. If you avoid Struts outdated Dojo integration, you can probably just include Dojo directly (but you cannot use both due to namespace conflicts)
peller
I decided to include dojo directly and not use any of the struts ajax tags and just write all my own javascript.
Kyle Boon