You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by mt...@apache.org on 2006/09/04 06:32:35 UTC
svn commit: r439949 - in /incubator/xap/trunk/WebContent/examples/basic:
dom0.html dom0.xal dom0Handler.js
Author: mturyn
Date: Sun Sep 3 23:32:34 2006
New Revision: 439949
URL: http://svn.apache.org/viewvc?view=rev&rev=439949
Log:
Much-improved DomNodeBridge, with proper event handling, and an example illustrating it with a text field sensitised to clicks and mouseovers, and with a method which converts lower-case characters to upper-case.
Modified:
incubator/xap/trunk/WebContent/examples/basic/dom0.html
incubator/xap/trunk/WebContent/examples/basic/dom0.xal
incubator/xap/trunk/WebContent/examples/basic/dom0Handler.js
Modified: incubator/xap/trunk/WebContent/examples/basic/dom0.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/basic/dom0.html?view=diff&rev=439949&r1=439948&r2=439949
==============================================================================
--- incubator/xap/trunk/WebContent/examples/basic/dom0.html (original)
+++ incubator/xap/trunk/WebContent/examples/basic/dom0.html Sun Sep 3 23:32:34 2006
@@ -15,6 +15,7 @@
parseWidgets: false
};
</script>
+
<script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
@@ -42,35 +43,12 @@
<script language="JavaScript" src="dom0.js"> </script>
<script language="JavaScript" src="dom0Handler.js"> </script>
-
-
- <script>
-
-dojo.require('dojo.event.*');
-
-document.onAnotherEvent = function(){
-// Put something here so we can put a breakpoint on that line, if need be:
- var foo = "bar" ;
-}
-
-
-var iii=0 ;
-// A simple test of dojo attachment, independent of Xap:
-document.attachOurEvent = function(){
- var displayer = document.getElementById("mouseOverDisplayer") ;
- displayer.lastCallInChain = function(){
- displayer.innerHTML = "<b> Mouse over/off transitions: <font color=\"#660000\">"+ (++iii) +"</font>.</b>" ;
- }
- dojo.event.connect(document,"onAnotherEvent",displayer,"lastCallInChain") ;
-}
-
-
- </script>
-
+<!-- Do this as late as possible---brings in script tags: -->
+<script> Xap._loadDebuggables();</script>
</head>
- <body onLoad="document.attachOurEvent();Xap.createAllPredefinedSessions();if(xap.showStatus){xap.showStatus();};document.attachOurEvent();">
+ <body onLoad="Xap.createAllPredefinedSessions();if(xap.showStatus){xap.showStatus();};">
<h1>Wrapped DIV managed by a xaplet embedded in another table cell:</h1>
<table id="bigtable" border="4px" borderColor="#8866AA" width="80%" height="80%"
@@ -84,7 +62,12 @@
xapId="MyApp" xapSrc="dom0.xal" xapToolkit="dojo">This cell is the xap ClientSession "MyApp"'s home-base.</div>
</td>
</tr>
- <tr><td height="5em" valign="top" align="left" onmouseover="javascript:document.onAnotherEvent()" id="targetNode"> target was here</div> </td>
+ <tr>
+ <td>
+ <div id="textInputFieldHolder">
+ <input type="text" size="50" height="5em" valign="top" align="left" id="targetNode"/>
+ </div>
+ </td>
<td id="mouseOverDisplayer" valign="middle"><b> Mouse over/off transitions: <font color="#660000">0</font>.<td/>
</tr>
</table>
@@ -95,7 +78,6 @@
<button onclick="alert(MyApp.getDocumentContainer().getUiDocument().toXml());">hello</button>
<div id="foot">FOOTER TEXT</dev>
-<!-- Do this as late as possible---brings in script tags: -->
-<script> Xap._loadDebuggables();</script>
+
</body>
</html>
Modified: incubator/xap/trunk/WebContent/examples/basic/dom0.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/basic/dom0.xal?view=diff&rev=439949&r1=439948&r2=439949
==============================================================================
--- incubator/xap/trunk/WebContent/examples/basic/dom0.xal (original)
+++ incubator/xap/trunk/WebContent/examples/basic/dom0.xal Sun Sep 3 23:32:34 2006
@@ -13,21 +13,24 @@
<xm:append select="/xal">
<dom xmlns="http://www.dojotoolkit.org/"
wrappedNodeId="targetNode"
- bgColor="#eeddFF"
- color="#ffeeff"
- innerHTML="<b>Mouse over this cell...</b>"
- valign="middle"
- align="center"
+ displayerId="textInputFieldHolder"
+ backgroundColor="#eeddFF"
+ color="#112200"
+ value="Mouse over, click on, or type in this field."
+ verticalAlign="middle"
+ onMouseover="mco:handler.mouseOverHandler()"
+ onCommand="mco:handler.clickHandler(this)"
+ onKeyup="mco:handler.keyupHandler(this,event)"
/>
</xm:append>
<xm:append select="/xal">
<button xmlns="http://www.dojotoolkit.org/"
- text="Button in middle of the application."
+ text="Button in the application home."
color="#aa0000"
id="button0"
backgroundColor="#00aaaa"
- onCommand="mco:handler.onClick(this)"
+ onCommand="mco:handler.clickHandler(this)"
/>
</xm:append>
Modified: incubator/xap/trunk/WebContent/examples/basic/dom0Handler.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/basic/dom0Handler.js?view=diff&rev=439949&r1=439948&r2=439949
==============================================================================
--- incubator/xap/trunk/WebContent/examples/basic/dom0Handler.js (original)
+++ incubator/xap/trunk/WebContent/examples/basic/dom0Handler.js Sun Sep 3 23:32:34 2006
@@ -9,7 +9,7 @@
"<font color='#000000'>"
];
-dom0Handler.prototype.onClick = function (srcNode) {
+dom0Handler.prototype.clickHandler = function (srcNode) {
//xap.util.Utils.interrogate(srcNode) ;
var attributes = srcNode.attributes;
@@ -18,7 +18,7 @@
var i2 = (i0+2)%3 ;
var resultString = "<br/><br/>"+dom0Handler.colours[i0]
- +"An MCO call got the attributes of the XAP button: " ;
+ +"An MCO from a XAP component got its attributes: " ;
if(!attributes){
resultString += "<br/><NONE>" ;
} else {
@@ -34,5 +34,35 @@
xap.showStatus() ;
var ticker = document.getElementById("xapStat") ;
ticker.innerHTML = ticker.innerHTML + resultString ;
-
-}
\ No newline at end of file
+}
+
+
+
+
+dom0Handler.prototype.moCount=0 ;
+
+dom0Handler.prototype.mouseOverHandler = function(){
+ var displayer = document.getElementById("mouseOverDisplayer") ;
+ if(!displayer){
+ return ;
+ }
+ displayer.innerHTML = "<b> Mouse over/off transitions: <font color=\"#660000\">"+ (++this.moCount) +"</font>.</b>" ;
+}
+
+
+dom0Handler.prototype.firstKeyUp = true ;
+dom0Handler.prototype.keyupHandler = function(){
+ var bridge = arguments[1].session.getUiDocumentHandler().getHandlerForElement( arguments[0] );
+ var peer = bridge.getPeer() ;
+ // Erase first message:
+ if ( this.firstKeyUp ){
+ peer.value="" ;
+ this.firstKeyUp = false ;
+ }
+ var charCode = arguments[1].eventObject.keyCode ;
+ if ( charCode < 65 || charCode>123 ){
+ return ;
+ }
+ var charr = String.fromCharCode(charCode).toUpperCase() ;
+ peer.value = peer.value.substring(0,peer.value.length -1) + charr ;
+}