i'm trying to create a custom checkbox that initializes based on some special 
xml. the logic is fairly simple and works if i implement the same logic inline. 
but if i extract it out into a class, i can't seem to get the variables to 
initialize and am not sure why. due to the number of checkboxes in the grid i 
want to present, it's really ugly inline.
 
 the xml (application specific) would look something like this:
 ...
 <fullName value='test'/>
 <datasourcesPrivileges>
   <datasource name='foo'/>
   <privilege name='bar'/>
 </datasourcePrivileges>
 ...
 
 then the custom checkbox would be included in a grid like:
 
 <dsCheckBox aDsName='foo' aPrivName='bar'/>
 
 the class declaration looks like:
 
 <library>
     <class name="dsCheckBox" extends="checkbox">
         <attribute name="hasdatasource" 
value="$path{'datasourcesPrivileges/datasourcePrivilege/[EMAIL PROTECTED] = 
'Xyz Data']'}"/>
         <attribute name="aDsName" type="string"/>
         <attribute name="aPrivName" type="string"/>
         <method event="ondata">
             i = 
datapath.xpathQuery('datasourcesPrivileges[1]/datasourcePrivilege/last()');
             Debug.write("looping thru " + i + " privs");
             Debug.write('NAME '+datapath.xpathQuery('fullName/@value'));
             setValue(false);
 
             Debug.write("LOOKING FOR "+aDsName + " , "+aPrivName);
             for (x=1; x&lt;=i;x++) {
                 Debug.write('===');
                 dsName = 
datapath.xpathQuery('datasourcesPrivileges[1]/datasourcePrivilege['+x+']/datasource/@name');
                 privName = 
datapath.xpathQuery('datasourcesPrivileges[1]/datasourcePrivilege['+x+']/privilege/@name');
 
                 Debug.write(dsName + ' ' +privName);
                 if (dsName==aDsName) {
                     if (privName==aPrivName) {
                         setValue(true);
                         Debug.write('SETTING VALUE TRUE');
                         break;
                     }
                 }
                 Debug.write('===');
             }
 
         </method>
     </class>
 </library>
 
 what i see happening when the data gets bound is the aDsName and aPrivName  
are printed out as being null in some cases but in other cases it seems that 
the values get bound (foo and bar in this case). is this some kind of race 
condition in which the instance variables are not assigned values before the 
ondata event fires?
 
 any ideas?
 
 btw, the "hasdatasource" attribute is a dummy i put in there as a hack so that 
the checkbox gets reinited when the datasource changes. seems to work.
 
 thanks!
 

_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user

Reply via email to