User Tools

Site Tools


pracro:devas_corner

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
pracro:devas_corner [2010/08/02 14:30] devapracro:devas_corner [2011/01/14 14:49] (current) deva
Line 1: Line 1:
 ======Deva's corner====== ======Deva's corner======
 +=====Session sharing======
 +Client logon with (patientid, template) tupple.\\
 +Server makes lookup in active sessions for tupples matching the one supplied by the client.\\
 +If none matches, a new session is created and 'returned' to the client.\\
 +If a match exists, the client is queried if it want to take over the session.\\
 +The session state is to be stored with the session (open, closed_no_commit) so the client must actively notify the server when a session is closed without commit.\\
 +If a client is about to take over an active (not closed_no_committed) a warning should be issued, about possible race conditions happening.
  
 =====New Clientside Scripting System===== =====New Clientside Scripting System=====
Line 5: Line 12:
 <?xml version='1.0' encoding='UTF-8'?> <?xml version='1.0' encoding='UTF-8'?>
 <macro name="test_resume" version="1.0"> <macro name="test_resume" version="1.0">
-  <script> 
-    function foo() 
-      -- this: current widget (widget that triggered the event) 
-      -- this.value: current value 
-      -- this.name: current name 
-      -- this.type: current type (eg. 'checkbox') 
  
-      this.setChecked(true)+  <resume> 
 +    <script src="regexp.lua"/> 
 +    <script> 
 +      -- inline code 
 +      if(regexp('.+', '')) 
 +      then 
 +        return 'a string' 
 +      else 
 +        return 'another string' 
 +      end 
 +    </script> 
 +  </resume>
  
-      foo = getWidgetByName('test2')+  <scripts> 
 +    <script> 
 +      function foo(
 +        -- this: current widget (widget that triggered the event)
  
-      if ( foo && foo.type == 'lineedit'+        this:setChecked(true) 
-      then + 
-         foo.setValue('bleh')+        foo = widget('test2'
 + 
 +        if ( foo && foo:type() == 'lineedit'
 +        then 
 +          foo:setValue('bleh') 
 +        end
       end       end
-    end +    </script> 
-  </script>+  </scripts>
   <widgets caption="Test Resume"   <widgets caption="Test Resume"
           layout="vbox">           layout="vbox">
Line 32: Line 52:
 The script tag can either consist of inline code, or be a reference to a serverside file, that will be inserted in-place by the server before it is sent to the client. The script tag can either consist of inline code, or be a reference to a serverside file, that will be inserted in-place by the server before it is sent to the client.
 <code xml> <code xml>
-<script> +<scripts> 
---example +  <script src="foo.lua"/
-</script> +  <script> 
-<script file="foo.lua"/>+    --example 
 +  </script> 
 +</scripts>
 </code> </code>
 +
  
 ====The Widget Events==== ====The Widget Events====
Line 42: Line 65:
 Currently the script is referred by its name, and called whenever the widget changes its value.\\ Currently the script is referred by its name, and called whenever the widget changes its value.\\
 In the new system, the script attribute is removed and replaced by event attributes. The event attributes will themselves contain lua code and not simply a name. In order to call 'external' code, simply wrap it in a function and call it here.\\ In the new system, the script attribute is removed and replaced by event attributes. The event attributes will themselves contain lua code and not simply a name. In order to call 'external' code, simply wrap it in a function and call it here.\\
-The return values will no longer be used. Instead widget methods will be added to control the validation state of each widget, eg. setValid(true|false), setInvalid(), invalidate(), ...\\+The return values will no longer be used. Instead widget methods will be added to control the validation state of each widget, eg. ''setValid(true|false)''.\\
 Since it is no longer required (due to redundancy) the ''regexp'' attribute will be removed. Since it is no longer required (due to redundancy) the ''regexp'' attribute will be removed.
 +
  
 ====Event Handlers==== ====Event Handlers====
   * ''onChange'': triggered whenever the value of the widget is changed, either programmatically or by the user.   * ''onChange'': triggered whenever the value of the widget is changed, either programmatically or by the user.
-  * ''onUserChange'': triggered whenever the value of the widget is changed by the user. +  * more to come 
-  * and many more+ 
  
 ====The Widget Object==== ====The Widget Object====
 When in a lua function, invoked by an event handler, the calling object (the object invoking the event) will be made available through the value 'this'. When in a lua function, invoked by an event handler, the calling object (the object invoking the event) will be made available through the value 'this'.
-Other object can be retrieved using the ''getWidget('name')'' function.+Other object can be retrieved using the ''widget('name')'' function.
 <code lua> <code lua>
 function foo() function foo()
-   if (this.value == 'bar')+   if (this:value() == 'bar')
    then    then
-      this.setValue('dut')+      this:setValue('dut')
    end    end
  
-   bas = getWidget('mywdg'+   bas = widget('mywdg'
-   if (bas && bas.value == 'bar' )+   if (bas && bas:value() == 'bar' )
    then    then
-      bas.setValue('dims')+      bas:setValue('dims')
    end    end
 end end
 </code> </code>
 A small number of methods are common to all widget types. These include are: A small number of methods are common to all widget types. These include are:
-  * ''set/getValue'' +  * ''setValue(string)'', ''value()'' 
-  * ''set/getValid'' +  * ''setValid(boolean)'', ''valid()'' 
-  * ''set/getVisible'' +  * ''setVisible(boolean)'', ''visible()'' 
-  * ''set/getEnabled''+  * ''setEnabled(boolean)'', ''enabled()'' 
 +  * ''type()'' 
 +  * ''name()''
 Others are specific to certain widget types, such as (and many more): Others are specific to certain widget types, such as (and many more):
-  * ''set/getChekced'' (checkbox) +  * ''setChekced(boolean)''''checked()'' (checkbox)
-  * ''set/getSelection'' (listbox) +
-  * ''set/getCarriagePosition'' (lineedit)+
  
 =====New protocol===== =====New protocol=====
pracro/devas_corner.1280752245.txt.gz · Last modified: 2010/08/02 14:30 by deva