« Return to Thread: ajax and datepicker on 2m4

Re: ajax and datepicker on 2m4

by Jason Thrasher :: Rate this Message:

Reply to Author | View in Thread

I have the datepicker working on 2.0-M4 (modular Struts2) after adding dojo v0.4.2 files to the web module.  Here's what I had to do:

1) Unzip dojo js files into myproject/web/src/main/webapp/scripts/dojo/.
The "dojo.js" and the dojo "src" directory should be there at a minimum.

2) Add an excludes pattern to the decorators.xml:
<pattern>/scripts/dojo/*</pattern>

3) Add djConfig and reference the dojo.js file from the default decorator file:
edit: myproject/web/src/main/webapp/decorators/default.jsp

add this inside the <head> content:
<script type="text/javascript">
var djConfig = {
        "isDebug":true,
        "debugContainerId":"dojoDebugOutput",
        "baseRelativePath":"<c:url value='/scripts/dojo/'/>",
        "preventBackButtonFix":false
// "parseWidgets":false
// "locale":"en-us"
// ,"baseScriptUri":"/scripts/dojo/"
        }
</script>
<script type="text/javascript" src="<c:url value='/scripts/dojo/dojo.js'/>"></script>

4) Add the s:datetimepicker tag to your file (like signup.jsp, to get the birthdate) as:

    <s:datetimepicker key="user.birthdate" required="true" toggleType="wipe" toggleDuration="300"
     displayFormat="MM/dd/yyyy" cssClass="text large"/>

5) Add the appropriate setXXX method to your Action or Model class as needed (User.setBirthdate(Date)).

hope it helps,
Jason

 « Return to Thread: ajax and datepicker on 2m4