Dojo with application/xml+xhtml content-type

659 views Asked by At

How can I get Dojo Dijits (1.5.0, currently) to work with XHTML as application/xml+xhtml? It works if sent as text/html, but application/xml+xhtml is required.

This seems to be tied to dijit.form.DatePicker and a few others.

This isn't a matter of validating against W3C, it just plain doesn't work, at all.

Error: mismatched tag. Expected: </br>.
Source File: 
Line: 5, Column: 54
Source Code:
  ><div class="dijitReset dijitValidationIcon"><br></div

JavaScript execution stops because of this error.

Obviously, I can recompile Dojo, and fix all of these individually, but this is a lot of work, and does not fix everything.

Once again, it works with text/html, but application/xml+xhtml is required.

3

There are 3 answers

0
Anh-Kiet Ngo On BEST ANSWER

I asked about the server side in case you were serving up your own build. Anyway, I know you don't want to do individual patches and rebuilds, but I think there is a solution where you can "patch" yet don't have to rebuild. Since the build internalizes the string into the function constructor, you can change it by using the extend functionality. In this case, for ValidationTextBox, you can do

dijit.form.ValidationTextBox.extend({
    templateString: "<div>apple sauce</div>"
});

This will get all future instantiation of dijit.form.ValidationTextBox to use the new template string. Though this might not be ideal, but it might be the only way for you to fix this without rebuilding the entire thing. Probably something in the form of,

dojo.require("dijit.form.ValidationTextBox");
dojo.require("my.ValidationTextBoxFix");

Good luck.

3
Tom Trenka On

This was fixed with the upcoming (as in this week) release of the Dojo Toolkit 1.5, but if you find the corresponding Dijit template in question, you can just change it to
without any side effects.

Hope that helps.

2
irreputable On

in xhtml you should have

<br/>

or

<br></br>

but I'm curious: who requires xhtml and for what?