Hi,
My name Peter Yee and I am with Nexaweb.
Here is my feedback regarding the XAP embedded HTML:
1. In the HTML, there should be a standardized doc-type at the very
start of the page. Such as:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Or
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
Or
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
The reason for this is because browsers recognize doc-type declarations
and will render pages ever so "slightly" different in its browser object
model and tags/attributes. For example, each browser loads a different
version of its rendering engine based on a doc-type for like HTML 4.01
and XHTML 1.0. Furthermore, there are also differences between HTML
4.01 Transitional and HTML 4.01 Strict. Also certain tags and
attributes will or will not get recognized based on doc types. (e.g. the
<font> tag will not get recognized by XHMTL 1.0!)
Establishing a doc-type will also establish the basis for testing
consistency across different browsers (Mozilla/IE/Opera/Safari).
2. If the goal of XAP is to build the UI using only declarative XML and
for other tools not to have generated Javascript, then there should be
no inline Javascript such as the onload attribute of the <body> tag or
any script tags within the <body>.
Also users don't need to be concerned with which Dojo or other widget to
use.
<script type="text/javascript">
dojo.require("dojo.widget.*");
dojo.require("dojo.event.*");
dojo.require("dojo.widget.Button");
dojo.require("dojo.widget.FloatingPane");
</script>
I'm not sure yet how we can anticipate which widget will need to be
loaded ahead, unless all widgets are loaded leading to heavy memory
usage. Maybe a solution is to load each dojo widget as the parsing code
comes across a widget the first time.
But the solution for removing the inline scripting is to have a loading
mechanism at the end of the Xap.js file like:
window.onload = function() {
//todo: get configuration from document body's child comment nodes
Xap.bootstrap(CONFIG.BOOTSTRAP, true);
DBG = new AjxDebug(CONFIG.DEBUG, null, false);
}
Overall most importantly by taking out the inline Javascript, the
structure and behavior is truly separated.
3. Recommendation for a simplified standard template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<script type="text/javascript" src="../../src/dojo/dojo.js"></script>
<script type="text/javascript"
src="../../src/xap/util/Utils.js"></script>
<script type="text/javascript" src="../../src/xap/Xap.js"></script>
<script type="text/javascript" src="custom.js"></script>
<head>
<title>Conforming XHTML 1.0 Strict Template</title>
</head>
<body>
<!-- XAP_BOOTSTRAP_PATH=../.. -->
<!-- XAP_DEBUG_MODE=TRUE -->
<!-- XAP_DJ_PARSE_WIDGETS=TRUE -->
<!--
XAP_XAL=XAL HERE
-->
</body>
</html>
The HTML above will yield a conforming XHTML 1.0 Strict structured
document and pass W3C validation (http://validator.w3.org/)!
4. Other issues:
- Do we want to mix XAL on a page with user introduced HTML?
- Commenting: Please use only /* */ for comments and not // because if
we ever need to compress the JavaScript libraries by removing line
breaks and spacing, the code will not break.
That's all for now.
Peter Yee
-----Original Message-----
From: James Margaris [mailto:[EMAIL PROTECTED]
Sent: Friday, July 07, 2006 8:11 PM
To: [email protected]
Subject: XAP imbedded in HTML
So I checked in some test code, you can see it working in the dojo
widget example. The body of the html is the interesting part:
<body onLoad="Xap.scanPage()">
<script type="text/javascript">
DBG = new AjxDebug( AjxDebug.NONE, null, false );
</script>
SOME TEXT
<h1>SOME BIG TEXT</h1>
<div context="../../" appName="MyApp" src="dojoExample_0.xal"
toolkit="dojo" >
</div>
<!-- MyApp as the app name is a top-level alias for session
as this event handler illustrates -->
<button
onclick="alert(MyApp.getDocumentContainer().getUiDocument().toXml());">h
ello</button>
FOOTER TEXT
</body>
Things to note:
1: Setting up the application is done declaritively.
2: The application that is created from the .xal page lives under the
div. (This is a bit hard to tell by looking since the app has floating
things)
3: "MyApp" gets declared as a top-level alias for the created session.
You can see the regular HTML button using it as a standard Javascript
object.
I think ideally you could have the entire original XML in the HTML, but
this is tricky for technical reasons. This seems like a good start.
This is just my random stab at this, the individual attribute names and
such are just my wild guess and right now the scanning code only looks
for divs...it's just a proof of concept to get some feedback.
James Margaris