FAQ

Requirement

Java6 or higher

Does mixer2 depends on servlet-api ?

NO. Dependencies page shows the dependency to servlet-api but please take notice of "optional" flag. You need servlet-api if you use Mixer2XhtmlView class with SpringMVC framework.

xhtml version, tag and property

xhtml1.0-transitional, xhtml1.0-strict, html5 with xml syntax. The spec of html5 is May 2011 version.

Mixer2 is also compatible for data-*, aria-* properties of html5. Mixer2 can't understand orignal tag like <foo>bar</foo> . If you use original tag on template, mixer2 will delete it.

no support for frameset document type

The xhtml1-transitional doctype and xhtml1-frameset doctype are different. Mixer2 does not support xhtml1-frameset. So, mixer2 ignore <frame> and <frameset> tag but support <iframe> tag.

write correct xhtml

Mixer2 does NOT validate html when load(unmarshal) template html and save(marshal) to html.

For example, case like below.

template:

<b> aaa <div>bbb</div> ccc </b>

load by mixer2, do nothing, and saveToString():

<b>aaa   ccc</b>

b tag cannot include div tag because b tag is inline element but div tag is block element. This is NG on xhtml specification.

Mixer2 ignore these invalid tags and no warning.

The other case nelow.

template.

<div id="a">xxx</div>
<div id="a">yyy</div>

This template is NG because one web page can not have tags that has same id property. But mixer2 ignore this.

load by mixer2, do nothing, and saveToString():

<div id="a">xxx</div>
<div id="a">yyy</div>

You should use syntax check function of web authoring tool (ex. Dreamweaver) or htmllint when you write html template.

DOCTYPE declaration will be deleted

Mixer2 forget any DOCTYPE declareation at the front of template. If JAXB-API detect DOCTYPE declaration on the way of analyzing template, JAXB-API access the URI and it leads heavy overhead.

If the output of your application needs DOCTYPE declaration, you should add it manually on your code.

html comment wil be deleted

<!-- comment... -->
<!--[if IE]>
<link rel="stylesheet" href="layout_ie.css" type="text/css" />
<![endif]-->

All the html comment on template will be deleted. This is a feature of Unmarshaller class of Java6 JAXB-API. By reason of this, The conditional comment - http://msdn.microsoft.com/en-us/library/ms537512 - will be deleted also.

JavaScript

JavaScript shuold be external file.

template:

<script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

output of mixer2:

<script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"> </script>

The one white space in script tag is expected behavior. Transofrmer class rewrite the tag that has only property but no content to like this <script type="text/javascript" src="foo.js" /> . For example Firefox can't run script tag like this.

JavaScript (Inline)

If you feel a strong need to write inline javascript on xhtml, use CDATA and // (comment out) on template.

template:

<script type="text/javascript">
//<![CDATA[
var foo = 1;
var bar = 2;
if (foo > bar || foo < bar) {
    var bar = 3;
}
//]]></script>

output by mixer2:

<script type="text/javascript">
//<![CDATA[

var foo = 1;
var bar = 2;
if (foo > bar || foo < bar) {
    var bar = 3;
}

//]]>
</script>

IDREF(S) property (ex. "for" property of label tag)

You should handle "IDREF(S)" property with care. Typical case is label tag like <label for="foo"> .

For example, loading template like below.

<label id="barInputLabel" for="barInput">input bar:</label>
<input id="barInput" type="text" name="barInput" />

Object obj = html.getById("barInputLabel", Label.class).getFor()

"obj" is not "barInput" String. It is instance of Input class having id="barInput" .

If you set "for" property to label tag object with the code like label.setFor("barInput") , you get exception.

Input barInput = html.getById("barInput", Input.class);
html.getById("barInputLabel", Label.class).setFor(barInput);

So, you need to pass the object having the id property to the setFor() method.

Thread safe

Most class of mixer2 is thread save. If the class is not thread safe, the javadoc is written like this "this class is not thread safe".

Initialize Mixer2Engine as singleton

To instantiate Mixer2Engine is high cost. You shuold instantiate mixer2engine as singleton and inject it to DI container.

Security

Mixer2 has an advantage for security. For example, to make <script> tag, It must be exists on template or you must write code "Script script = new Script();" explicitly.

chaching

All the tag class of mixer2 implements java.io.Seralizable and have copy() method. You can implements original caching function by combination of general caching framework.

See also Mixer2-Cacheable project.

Use Maven through proxy

Sample application or maven archetype of mixer2 uses maven. Maven will download java libraries with http(s) from central repository on internet automatically.

In some cases, you need web proxy authentication to internet access. Here is document of it on maven official site.

How to contact you

See team page or mailing list page