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/08/12 04:28:15 UTC
svn commit: r430969 - in /incubator/xap/trunk:
WebContent/examples/dojo/dateAndColorPickers.html src/xap/Xap.js
Author: mturyn
Date: Fri Aug 11 21:28:14 2006
New Revision: 430969
URL: http://svn.apache.org/viewvc?rev=430969&view=rev
Log:
Added code to allow one to define a Xap application algorithmically; it will be created, along with any sessions defined with non-standard tag attributes, later on. Example changed to test this.
Modified:
incubator/xap/trunk/WebContent/examples/dojo/dateAndColorPickers.html
incubator/xap/trunk/src/xap/Xap.js
Modified: incubator/xap/trunk/WebContent/examples/dojo/dateAndColorPickers.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/dojo/dateAndColorPickers.html?rev=430969&r1=430968&r2=430969&view=diff
==============================================================================
--- incubator/xap/trunk/WebContent/examples/dojo/dateAndColorPickers.html (original)
+++ incubator/xap/trunk/WebContent/examples/dojo/dateAndColorPickers.html Fri Aug 11 21:28:14 2006
@@ -56,7 +56,14 @@
<script language="JavaScript" src="datePickerHandler.js"> </script>
<script language="JavaScript" src="colorPickerHandler.js"> </script>
-
+<SCRIPT language="JavaScript">
+ Xap.defineSession("datePicker.xal",
+ "DatePicker",
+ "datePickerHome",
+ "../../",
+ "dojo"
+ ) ;
+</SCRIPT>
</head>
@@ -75,7 +82,7 @@
<tr><td><div id="dp"/><td/><td></td></tr>
<tr><td id="xapStat"></td>
<td><div xapContext="../../"
- xapId="DatePicker" xapSrc="datePicker.xal" xapToolkit="dojo">DatePicker's home-base.</div>
+ xapId="DatePicker" xapSrcc="datePicker.xal" xapToolkit="dojo">DatePicker's home-base.</div>
</td>
</tr>
<tr><td ><div id="displ"><b>Pick a day....</b></div><div height="5em" id="targetNode" valign="top" align="left"/>
Modified: incubator/xap/trunk/src/xap/Xap.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/Xap.js?rev=430969&r1=430968&r2=430969&view=diff
==============================================================================
--- incubator/xap/trunk/src/xap/Xap.js (original)
+++ incubator/xap/trunk/src/xap/Xap.js Fri Aug 11 21:28:14 2006
@@ -141,8 +141,13 @@
Xap.APPLICATION_SOURCE_ATTRIBUTE__NAME = "xapSrc" ;
Xap.APPLICATION_TOOLKIT_ATTRIBUTE__NAME = "xapToolkit" ;
+// Use this count to create xaplet i.d.'s if they're not supplied:
Xap.xapletCount = 0 ;
+Xap.getNextXapLabel = function(){
+ return "unlabelled_xaplet_"+ (++Xap.xapletCount) ;
+}
+
Xap.scanPage= function(){
var allPossibleContainerNodes = Xap._findAppElements() ;
@@ -176,7 +181,7 @@
if(! thisSessionsParameters.xapId ){
passedInId = false ;
- thisSessionsParameters.xapId = "xaplet_"+ (++Xap.xapletCount) ;
+ thisSessionsParameters.xapId = Xap.getNextXapLabel() ;
}
// What's the toolkit?---dojo?---defaults to zimbra if null
@@ -207,7 +212,15 @@
var src = thisSessionDef.xapSrc ;
var toolkit = thisSessionDef.xapToolkit ;
var context = thisSessionDef.xapContext ;
- var element = thisSessionDef.htmlElement ;
+ var element = thisSessionDef.htmlElement ;
+ if( element && typeof element == "string"){
+ element = document.getElementById(element) ;
+ }
+ if (!element){
+ element = document.body ;
+ }
+ thisSessionDef.htmlElement = element ;
+
var session = Xap.createSession(context, src, toolkit , element);
// these might be handy to keep around:
@@ -231,15 +244,28 @@
Xap.defineSession = function(src, xapletName,elementId,context,toolkit){
+ if( !src ){
+ throw new xap.util.Exception("No source (.xal) file given for this xap application.") ;
+ }
+
if( !Xap.predefinedSessions){
Xap.predefinedSessions = new Array( 0 ) ;
}
var newSess = new Object() ;
newSess.xapId = xapletName ;
- newSess.xapContext = context ;
+ if (!xapletName){
+ newSess.xapId = Xap.getNextXapLabel() ;
+ }
+ newSess.xapContext = Xap._sourceRootDir ;
+ if( context ){
+ newSess.xapContext = context ;
+ }
newSess.xapSrc = src ;
newSess.xapToolkit = toolkit ;
- newSess.htmlElement = document.getElementId(elementId) ;
+ newSess.htmlElement = elementId ;
+ if( !newSess.htmlElement ){
+ newSess.htmlElement = document.body ;
+ }
Xap.predefinedSessions.push(newSess) ;
@@ -284,6 +310,7 @@
}
Xap.createSession = function( context, startPage,toolkitType , element) {
+
var session = new xap.session.ClientSession( context,toolkitType ,element );
session._start( startPage );
return session;