<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PannonRex &#187; Code</title>
	<atom:link href="http://www.pannonrex.com/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.pannonrex.com</link>
	<description>Solutions that Work</description>
	<lastBuildDate>Sun, 07 Mar 2010 01:45:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Morfik Tip: Calling JavaScript form Morfik Take #2</title>
		<link>http://www.pannonrex.com/2007/03/10/morfik-tip-calling-javascript-form-morfik-take-2/</link>
		<comments>http://www.pannonrex.com/2007/03/10/morfik-tip-calling-javascript-form-morfik-take-2/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 23:48:12 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=58</guid>
		<description><![CDATA[It was almost a year ago that I wrote about calling JavaScript from Morfik (in Morfik Tips: How to integrate JavaScript into the client code). That method is still valid and especially suitable for larger bodies of JavaScript (like libraries), but there is now an easier way of doing this. Let&#8217;s see an example for [...]]]></description>
			<content:encoded><![CDATA[<p>It was almost a year ago that I wrote about calling JavaScript from Morfik (in <a href="http://www.pannonrex.com/blog/?p=18" title="Morfik Tips: How to integrate JavaScript into the client code" target="_blank">Morfik Tips: How to integrate JavaScript into the client code</a>). That method is still valid and especially suitable for larger bodies of JavaScript (like libraries), but there is now an easier way of doing this.</p>
<p><span id="more-58"></span>Let&#8217;s see an example for the new way:<br />
<code>function setOpacity(element:THTML_ElementExt; opacity: Integer); ['Obfuscate=false']; JavaScript; (*!<br />
    var object = element.style;    object.opacity = (opacity / 100);<br />
    object.MozOpacity = (opacity / 100);<br />
    object.KhtmlOpacity = (opacity / 100);<br />
    object.filter = "alpha(opacity=" + opacity + ")";<br />
*)</p>
<p>function getOpacity(element:THTML_ElementExt): Integer; ['Obfuscate=false']; JavaScript; (*!<br />
    var object = element.style;<br />
    return (object.opacity);<br />
*)<br />
</code></p>
<p>You can simply copy the above function into your Pascal source file (browser side;-) and then you can call it passing the DOMHandle of any visual control together with an opacity value (in the range of 0-100) to set the element&#8217;s opacity, regardless of browser.</p>
<p>Let&#8217;s look at the syntax:</p>
<ul>
<li>The function declaration part can be pretty much the same as with any ordinary Morfik function (in the Pascal dialect you can use &#8220;function&#8221; instead of &#8220;procedure&#8221;, if you wish).</li>
<li>Then we have the <strong>['Obfuscate=false'];</strong> <em>annotation</em> that will direct the code generator to not obfuscate the function.</li>
<li>Then we have the <strong>JavaScript;</strong> <em>directive</em> that tells the compiler that this is a JavaScript routine.</li>
<li>Then comes the actual JavaScript, enclosed in the special comment  tag <strong>(*!  &#8230;  *)</strong>.</li>
<li>You can return the result of the function with the standard JavaScript <strong>return</strong> statement.</li>
</ul>
<p>It is very simple to call JavaScript this way from our code, but please keep in mind that the compiler cannot check the JavaScript code, so keep as much as possible in Pascal/Basic/C#/Java and use these techniques only when absolutely needed. Fortunately, as the Morfik Framework matures there are fewer and fewer cases when you have to&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/03/10/morfik-tip-calling-javascript-form-morfik-take-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Morfik: Weekly Calendar notes</title>
		<link>http://www.pannonrex.com/2007/03/09/morfik-weekly-calendar-notes/</link>
		<comments>http://www.pannonrex.com/2007/03/09/morfik-weekly-calendar-notes/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 11:26:49 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=57</guid>
		<description><![CDATA[I had a few additional explanations and thoughts about Calendar that I put into writing for your pleasure: You can add new items by simply dragging on empty space (or Shift-dragging on events) You can move events by dragging (in the caption) or make them longer/shorter by dragging the bottom of the events. If you [...]]]></description>
			<content:encoded><![CDATA[<p>I had a few additional explanations and thoughts about Calendar that I put into writing for your pleasure:</p>
<ul>
<li>You can add new items by simply dragging on empty space (or Shift-dragging on events)</li>
<li>You can move events by dragging (in the caption) or make them longer/shorter by dragging the bottom of the events.</li>
<li>If you schedule multiple events at the same time on the same day, they will split the cell width nicely (better than Outlook, IMHO;-).</li>
<li>While you are making the edits, they are sent to the server in the background for storage, without interrupting your work, in a true AJAX fashion (in demo mode after validation we throw away the changes, to make our life of keeping the demo in shape easier).</li>
<li>As a future feature, I plan to combine this with my Chat demo to create a collaborative event scheduling calendar where if one party edits an event, those changes will be reflected immediately on the other parties&#8217; screen. Will also add month view, etc.</li>
<li>The architecture is so that the client side interfaces through Web Services (SOAP) with the server, so it should be simple for other applications to integrate with the Calendar (will also create a demo).</li>
<li>The browser-server communication language is iCalendar, so other calendars will be able to import our events (tested manually with Google Calendar so far) and we will also be able to consume other iCalendar-compatible events.</li>
</ul>
<p>Having almost 20 years of software development experience, of course, this does not seem such a big deed for me, still in the web space there are not that many really polished Calendars around (again, Google Calendar being a big example). Now taking into consideration the time it took me to get so far with the demo with relatively little hands-on web development experience (I was mostly envisioning/designing/managing our web projects, not coding) we can see what tools like Morfik can do with the web:</p>
<ol>
<li>they can enable software engineers who avoided weakly object-oriented scripting languages thus far to create powerful solutions that can exceed their desktop equivalents in many ways and</li>
<li>they can enable small shops that were coding in MSAccess, FoxPro, Paradox, Visual Basic, etc.,  to become first-class, fully buzzword-compliant web developers without first learning (X)HTML, DOM, JavaScript, SOAP, XML, AJAX, Apache admin, etc. (they will eventually, IMHO, but it is not an up-front cost;-)</li>
</ol>
<p>So in the end we can hope for more powerful and more productive web applications to come :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/03/09/morfik-weekly-calendar-notes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Morfik Tip: Calling Morfik functions or methods from JavaScript</title>
		<link>http://www.pannonrex.com/2007/03/09/morfik-tips-calling-morfik-functions-or-methods-from-javascript/</link>
		<comments>http://www.pannonrex.com/2007/03/09/morfik-tips-calling-morfik-functions-or-methods-from-javascript/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 11:11:16 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=56</guid>
		<description><![CDATA[From time to time you will want to drop to JavaScript to perform various operations (like when you use a third-party JavaScript library). In those cases you may want to call a Morfik function or method. How can it be done? Let’s see first how Morfik functions (and procedures) can be called: function AFunctionToCall(x, y: [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time you will want to drop to JavaScript to perform various operations (like when you use a third-party JavaScript library). In those cases you may want to call a Morfik function or method. How can it be done?<br />
<span id="more-56"></span><br />
Let’s see first how Morfik functions (and procedures) can be called:</p>
<pre>
function AFunctionToCall(x, y: Integer; s: String) : Integer; ['Obfuscate=false'];
Begin
  Result := x+y;
End;

Procedure DefeatTheOptimizer;
// Make sure you call THIS procedure somewhere
// (e.g. in FormReady, or in Initialization)
Begin
  Exit;

  // call all functions here that you don’t
  // want the optimizer to eliminate
  AFunctionToCall(0,0,””);
End;

function GetFuncResult: Integer; JavaScript; (*!
  return AFunctionToCall(34, 26, "hello");
*)</pre>
<p>Very simple. Arman Mirkazemi has a few instructions, though:</p>
<blockquote><p> It is possible to call Morfik functions from JavaScript. You need to make sure that the compiler does not obfuscate the function name by placing a compiler tag <strong>['Obfuscate=false'];</strong> in front of your function declaration.<br />
Secondly, the JavaScript optimizer is designed to remove code that does not get called anywhere in the application. When turned on, the JavaScript optimizer produces a lighter weight JavaScript code to send to the browser.<br />
To stop the optimizer from taking your function out you must call it from another Function. In this case your application may not need to call &#8220;myMorfikFunction&#8221; anywhere, thus to get around that you could call it from one of your methods after an Exit; statement.</p></blockquote>
<p>OK. Now let’s see Morfik methods. They are a bit different, since you have to make sure that self/this is set up properly:</p>
<pre>
Type
  TTestClass = Class(TObject)
    s: String;
    i: Integer;
    f: Double;

    constructor Create;
    function GetIMultipliedBy(x, y, z: Integer): Integer;
  end; ['Obfuscate=false'];

constructor TTestClass.Create;
begin
  s := 'apple';
  i := 42;
  f := 3.1415926;
end;

function TTestClass.GetIMultipliedBy(x, y, z: Integer): Integer;
begin
  Result := i * x * y * z;
end;

function GetMethodResult(p: Pointer): Integer; JavaScript; (*!
  return p(2,10,100);
*)

function getSimpleMethodPointer(o,m: Pointer): Pointer; JavaScript; (*!
  if(m)
    return function(){
      return m.apply(o, arguments);
    }
  else
    return null;
*)

Procedure Index.ButtonTestClick(Event: TDOMEvent);
Var
  tc: TTestClass;
  s: String;
Begin
  salamon := 'hello world';
  tc := TTestClass.Create;
  s := tc.s + '';
  s := s + TJObject(tc).toString + '';
  s := s + tc.ClassName + '';
  s := s + IntToStr(GetMethodResult(
      getSimpleMethodPointer(tc, @tc.GetIMultipliedBy)
    ));
  tlTC.Caption := s;
End;</pre>
<p>The tricky part is getSimpleMethodPointer(). It will return a pointer to the method instance (technically it creates an anonymous function that calls the function on the class with all the parameters it was called with). Please note that there is a similar Morfik function called getMethodPointer(), but that does not handle multiple parameters at the moment and is also fiddling with the bandindex that takes CPU cycles, so I prefer to use this one, if I know I’m not on a continuous form. And it cannot work on normal functions or class methods either (see later).</p>
<p>BTW with this solution you do not need to turn off Obfuscation, since you will pass the actual (obfuscated) name of the object and method to the function at runtime, as opposed to the previous function call, where the compiler will not replace inside the JavaScript routine the name of the Morfik function with the obfuscated version (wow! Simple, is it!?;-). So you could do a similar trick with non-method functions by doing this: getSimpleMethodPointer(Nil, AFunctionToCall); This would also eliminate the need for the DefeatTheOptimizer function, since you do refer to the function-to-be-called-from-JavaScript, so the optimizer will not eliminate it. Of course, you have to alter the JavaScript function to take the function-to-be-called-from-JavaScript as a parameter. You can call class methods (ones that don&#8217;t need an instance) the same way, by passing Nil as the first parameter.</p>
<p><strong>Update &#8211; getSimpleMethodPointer() explanation</strong></p>
<p>It turned out that I skipped some details on the parameters of getSimpleMethodPointer(), so let&#8217;s remedy that now:</p>
<ul>
<li><strong>o</strong> is an <em>object instance</em> (address) upon which you want to call the method and</li>
<li><strong>m</strong> is the <em>method</em> (address) of the object you want to call (always use the address-of (@) operator to play on the safe side).</li>
</ul>
<p>First this seems straightforward, but! Let&#8217;s see a confusing example:</p>
<pre>
procedure AJavaScriptFunction(s : string; cb: pointer); JavaScript; (*!
  cb(s);
*)

procedure Index.CallTheJavaScriptFunction;
begin
  AJavaScriptFunction('Morfik rulez', getSimpleMethodPointer(<strong>Self</strong>, @SendMessage));
end;</pre>
<pre>procedure Index.SendMessage(sMsg: String);
begin
  ...
end;</pre>
<p>The important part is the getSimpleMethodPointer() call&#8217;s first parameter: Self. One could first simply put Index instead of Self here, but that would be wrong. Why? because Index represents the <em>class</em> (technically it will become (the name of) a JavaScript constructor function) and we need instead an <em>object instance</em> here, which in our case is stored in Self. That&#8217;s why in my original example I used tc (which is an object instance) instead of TTestClass (which is the class). Hope this helps&#8230;</p>
<p>BTW (for Delphi chaps) it would be more prudent to use the semi-Hungarian naming convention for forms, because then Index would be called TIndex, and no one would mistake it for an instance variable (Var Index: TIndex, anyone?). Aren&#8217;t all good things invented by Hungarians? ;-) Quiz question: why is it called the <em>Hungarian</em> naming convention?</p>
<p>One word on the address-of operator (@): if the function does have parameters then you don&#8217;t have to use it, because the compiler can tell that you want to get the address of the function, but if your function has no parameters, then (in Pascal) the compiler will guess that you want to <em>call</em> the function, and getSimpleMethodPointer() will get the <em>return value</em> of the function, which is not what we wanted. So play on the safe side and use the address-of operator.</p>
<p>Enjoy! Comments appreciated…</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/03/09/morfik-tips-calling-morfik-functions-or-methods-from-javascript/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Morfik: Weekly Calendar Demo</title>
		<link>http://www.pannonrex.com/2007/03/05/morfik-weekly-calendar-demo/</link>
		<comments>http://www.pannonrex.com/2007/03/05/morfik-weekly-calendar-demo/#comments</comments>
		<pubDate>Mon, 05 Mar 2007 14:50:51 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Calendar]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=54</guid>
		<description><![CDATA[Once again, we are back with a new demo app done in Morfik! Now it is a weekly calendar view (similar to what you can see in Microsoft Outlook or Google Calendar) with drag-and-drop capability. You can take a look at the application here (it may take Morfik some time to post it, so check [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pannonrex.com/blog/wp-content/uploads/2007/03/labs_calendar.jpg" target="_blank" title="Calendar demo"><img src="http://www.pannonrex.com/blog/wp-content/uploads/2007/03/labs_calendar.jpg" title="Calendar demo" alt="Calendar demo" align="left" hspace="10" vspace="10" /></a>Once again, we are back with a new demo app done in Morfik! Now it is a weekly calendar view (similar to what you can see in Microsoft Outlook or Google Calendar) with drag-and-drop capability. You can take a look at the application <a href="http://calendar.labs.morfik.com/" target="_blank" title="Calendar in Morfik Labs">here</a> (it may take Morfik some time to post it, so check back if first you are not successful). At this time the source code is not available (read on to learn more).</p>
<p>This demo was created with Morfik technology within cca. one engineer-week&#8217;s time. Some notes on features and limitations:</p>
<ul>
<li>The edits to the events are sent to and are validated by the server, but they are not saved in this demo (to help us maintain the demo:-)</li>
<li>The demo will always show the same week (start of March, 2007) again, to help us maintain the demo.</li>
<li>You cannot add all-day events in this demo.</li>
<li>This started out as proof of concept to see how easy it was to develop a complex control in Morfik. You can judge it for yourself: for one week&#8217;s time it is quite polished, IMHO :-).</li>
<li>We have frozen the feature set of the demo so there are many functions missing, but we are continuing the development of the Calendar control itself, so please <a href="mailto:calendar.support@pannonrex.com?subject=Calendar%20control%20%28piBlog%29" title="Mail to Calendar Support" target="_blank">contact us</a>, if you need a production quality full featured solution (including back-end logic).</li>
</ul>
<p>PLEASE NOTE: this version of the calendar is NOT secured, there are gaping holes and can be mistreated quite easily, so DO NOT use it for production purposes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/03/05/morfik-weekly-calendar-demo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Morfik Tip: Pretty up the ‘Loading…’ message &#8211; Take #2</title>
		<link>http://www.pannonrex.com/2007/03/04/morfik-tip-pretty-up-the-%e2%80%98loading%e2%80%a6%e2%80%99-message-take-2/</link>
		<comments>http://www.pannonrex.com/2007/03/04/morfik-tip-pretty-up-the-%e2%80%98loading%e2%80%a6%e2%80%99-message-take-2/#comments</comments>
		<pubDate>Sun, 04 Mar 2007 17:40:56 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=52</guid>
		<description><![CDATA[As predicted, Morfik acted switftly upon my note about the (inability of the) customization of the &#8220;Loading&#8230;&#8221; message. So from 0.9.17.7 on you have a much cleaner solution. It is&#8230; &#8230;simple. Now you can create a server-side application event (i.e. an event of your application object) called OnPrintLoadingMessage() that will be called exactly before the [...]]]></description>
			<content:encoded><![CDATA[<p>As predicted, Morfik acted switftly upon my note about the (inability of the) customization of the &#8220;Loading&#8230;&#8221; message. So from 0.9.17.7 on you have a much cleaner solution. It is&#8230;<span id="more-52"></span></p>
<p>&#8230;simple. Now you can create a server-side application event (i.e. an event of your application object) called OnPrintLoadingMessage() that will be called exactly before the default &#8220;Loading&#8230;&#8217; message is going to be printed, so you can print your own message, and by setting the var parameter Print to False you can prevent the Framework from printing its own message, thus you can completely control the appearance of the &#8220;splash screen&#8221;.</p>
<p>To enter the following example, do the following:</p>
<ul>
<li>Go to the Project (top) tab.</li>
<li>Select the Server (bottom) tab.</li>
<li>Press F11 to bring up the Properties sheet.</li>
<li>Double-click on OnPrintLoadingMessage.</li>
<li>Paste in the following code:</li>
</ul>
<pre>
Procedure &lt;YourAppNameHere&gt;XApp.XAppPrintLoadingMessage(Response: THTTPResponse; Var Print: Boolean);
Begin
  // -------- start of copy only this part --------
  Response.WritelnString(' &lt;div id="__LoadingText" '+
    'style="left:48%;top:45%;position:absolute;font-weight:bold;'+
    'text-align:center;font-size:12px;font-family:verdana,serif;'+
    'background-color:#f0f0f0;padding:10px 14px 10px 14px;border:1px dotted gray;'+
    'color:red;"&gt;');
  Response.WritelnString(' Loading...');
  Response.WritelnString(' &lt;/div&gt;');
  Print := False;
  // -------- end of copy only this part --------
End;</pre>
<p>You will also find other interesting events here that may control the genration of the initial bootstrap &#8220;code&#8221;: look at Procedure TFormServer.GenerateMainHTMLPage; in FrameWork\SystemServerDocForm.mmd for more details.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/03/04/morfik-tip-pretty-up-the-%e2%80%98loading%e2%80%a6%e2%80%99-message-take-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Morfik Tip: Pretty up the &#8216;Loading&#8230;&#8217; message</title>
		<link>http://www.pannonrex.com/2007/02/14/morfik-tip-pretty-up-the-loading-message/</link>
		<comments>http://www.pannonrex.com/2007/02/14/morfik-tip-pretty-up-the-loading-message/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 22:04:14 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=49</guid>
		<description><![CDATA[I got bored with the ugly &#8216;Loading&#8230;&#8217; message in the upper left corner while my users are patiently (?) waiting for my app to launch, so I dug a little into the Framework source code and came up with the following. In SystemServerDocForm, in the Browser code, in TFormServer.GenerateMainHTMLPage, replace line 595 with the following: [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pannonrex.com/blog/wp-content/uploads/2007/02/morfikloading.jpg" title="Loading hack"><img src="http://www.pannonrex.com/blog/wp-content/uploads/2007/02/morfikloading.jpg" title="Loading hack" alt="Loading hack" align="left" hspace="10" /></a>I got bored with the ugly &#8216;Loading&#8230;&#8217; message in the upper left corner while my users are patiently (?) waiting for my app to launch, so I dug a little into the Framework source code and came up with the following.</p>
<p>In SystemServerDocForm, in the Browser code,  in TFormServer.GenerateMainHTMLPage, replace line 595 with the following:</p>
<pre>
// !PI! Added a little style to the "Loading" message
Response.WritelnString('    &lt;div id="__LoadingText" '+
 'style="left:40%;top:50%;position:absolute;font-weight:bold;'+
 'text-align:center;font-size:12px;font-family:verdana,serif;'+
 'background-color:#f0f0f0;padding:10px 14px 10px 14px;'+
 'border:1px dotted gray;color:red;"&gt;');</pre>
<p>This is valid for 0.9.16.1 &#8212; if you have a different version, your mileage may vary somewhat.</p>
<p>This is a quickie, and I suppose will be outdated pretty soon, as Morfik will do something better about it (e.g. put a class on this DIV, and make it possible to have an external stylesheet to customize), but for the time being it is a good fix. Of course, you may want to adjust the settings to your liking. Can also add some logo, change the text itself, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/02/14/morfik-tip-pretty-up-the-loading-message/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Morfik Tip: How to return the value of any class member field as a string</title>
		<link>http://www.pannonrex.com/2007/02/14/morfik-tip-how-to-return-the-value-of-any-class-member-field-as-a-string/</link>
		<comments>http://www.pannonrex.com/2007/02/14/morfik-tip-how-to-return-the-value-of-any-class-member-field-as-a-string/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 21:48:48 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=48</guid>
		<description><![CDATA[We are building a generic framework to do data transfers/data binding efficiently (and some other wonders;) in Morfik and we had this issue today that we wanted to get a field&#8217;s value when we knew the field&#8217;s name. So we cooked up the following little Pascal function that will return the string equivalent of the [...]]]></description>
			<content:encoded><![CDATA[<p>We are building a generic framework to do data transfers/data binding efficiently (and some other wonders;) in Morfik and we had this issue today that we wanted to get a field&#8217;s value when we knew the field&#8217;s name.</p>
<p>So we cooked up the following little Pascal function that will return the string equivalent of the value of filed &#8216;v&#8217; of class &#8216;c&#8217;. This is a first cut, some tests should be done (and will be for our production lib) but it is a good start, if you happen to stumble upon the same problem.</p>
<pre>
function GetValue(c:Pointer; v:String):String; JavaScript; (*!
{
  return c[v];
}*)</pre>
<p>Among other things this demonstrates how you can call JavaScript code from within the Pascal code without using external .js files. This is a relatively new syntax (from around the 0.9.1x.x branch AFAIS) but is way cool.</p>
<p>If you happen to have to drop to JavaScript, some of my advices:</p>
<ul>
<li>do NOT do that, unless you know what you are doing &#8212; if you are new to JavaScript, it will be an interesting experience;</li>
<li>in Project / Project Options / Compiler,  switch off &#8220;Obfuscate JavaScript&#8221; (and &#8220;Optimize JavaScript&#8221;, for that matter) to make your life easier when you are debugging;</li>
<li>install the Microsoft Script debugger as described in Appendix &#8216;G&#8217; (if I recall correctly).</li>
</ul>
<p>Happy sailing!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/02/14/morfik-tip-how-to-return-the-value-of-any-class-member-field-as-a-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chat example full of Morfik insight</title>
		<link>http://www.pannonrex.com/2007/02/07/chat-example-full-of-morfik-insight/</link>
		<comments>http://www.pannonrex.com/2007/02/07/chat-example-full-of-morfik-insight/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 23:29:57 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Chat]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=45</guid>
		<description><![CDATA[Yours truly has done it again! Instead of finally getting to writing about Analog Clock I created another Morfik Labs sample application, a simple chat thingy. You can take a look at the application here and download the source code in the Morfik Labs. Telling the truth, I created the original chat app almost a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pannonrex.com/blog/wp-content/uploads/2007/02/labs_mfkchat.jpg" title="Chat example"><img src="http://www.pannonrex.com/blog/wp-content/uploads/2007/02/labs_mfkchat.jpg" title="Chat example" alt="Chat example" align="left" /></a>Yours truly has done it again! Instead of finally getting to writing about Analog Clock I created another Morfik Labs sample application, a simple chat thingy.</p>
<p>You can take a look at the application <a href="http://chat.labs.morfik.com/" target="_blank" title="Chat in Morfik Labs">here</a> and download the source code in the <a href="http://www.morfik.com/mChat.zip?cls=Blob&amp;ds=tblXApps&amp;cn=Xappfiles&amp;kn=MFK%24GUID&amp;kv=1A05C43D34B4-B4D4-7A1B-55C5D72999F4" title="Chat code in the Morfik Labs" target="_blank">Morfik Labs</a>.</p>
<p>Telling the truth, I created the original chat app almost a year ago (February, 2006) and now due to interest in the Morfik forums I dusted it off and updated to the latest version of Morfik WebOS AppsBuilder (0.9.16.1). I thought originally it would be a two-three hours exercise, and man I was wrong! It took me two days to tidy up a few hundred lines of code :-) The reason was that the original version used subforms for displaying the messages, but that was tooo sloooow, so I decided to wander a little bit into the wonderland of DOM programming.</p>
<p>So some details (shamelessly copied form the readme.txt): the Basic Chat example application is the innermost prototypical core of a chat engine and still it can provide some insight into areas of Morfik programming. A few examples:</p>
<p>- using web methods<br />
- using inline JavaScript functions with parameters<br />
- using critical sections in server logic to accommodate concurrency<br />
- using in-memory caching on the server (the chat session is stored in server memory)<br />
- using visual effects for highlighting UI changes<br />
- no security measures: a very good example for many types of web application security attacks, especially injections :-)</p>
<p>PLEASE NOTE: this version of the chat engine is NOT secured, there are gaping holes and can be mistreated quite easily, so DO NOT use it for production purposes. It is very basic as well, you cannot set up chat rooms, or schedule events, authenticate users, there is no smiley handling, there are no application specific extensions, etc. Please also note that at the moment there are some open issues related to resource consumption in the Morfik framework that do affect the performance of the chat app. It has not been overly optimized either so substantial performance improvements can still be achieved.</p>
<p>If you need a production quality, secure chat engine, please contact me ;-).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/02/07/chat-example-full-of-morfik-insight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Morfik Tips: How to handle MouseOver and MouseOut efficiently</title>
		<link>http://www.pannonrex.com/2007/01/27/morfik-tips-how-to-handle-mouseover-and-mouseout-efficiently-and-how-to-stop-an-event-from-bubbling/</link>
		<comments>http://www.pannonrex.com/2007/01/27/morfik-tips-how-to-handle-mouseover-and-mouseout-efficiently-and-how-to-stop-an-event-from-bubbling/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 16:18:21 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=42</guid>
		<description><![CDATA[I owe you with an article on AnalogClock internals, but today we are in for a quick tip. What I wanted to do is: create a hover effect (i.e. the entire row is highlighted when the mouse is over) for continuous forms. First I put a Container on the continuous form and placed all the [...]]]></description>
			<content:encoded><![CDATA[<p>I owe you with an article on AnalogClock internals, but today we are in for a quick tip.</p>
<p>What I wanted to do is: create a hover effect (i.e. the entire row is highlighted when the mouse is over) for continuous forms.</p>
<p>First I put a Container on the continuous form and placed all the other text controls and checkboxes and others on the Container (since the Detail does not have OnMouseOver/Out events), then set up the Container for OnMouseOver and OnMouseOut. It fundamentally worked, but the hovering effect was slooow and sometimes did not even register on some of the lines (depending on how fast I moved the mouse pointer).</p>
<p>I  though the issue was related to the way the controls contained by Container bubble these events to Container. So I simply set the OnMouseOver/Out event handlers for all controls to the same event handlers and bingo! now it works properly. The exact code sample is below:</p>
<pre>
Procedure TestForm.InfoContainerMouseOut(Event: TDOMEvent);
Begin
  SwitchBandIndex( Event );
  InfoContainer.DOMStyle.backgroundColor := 'White';
End;</pre>
<pre>Procedure TestForm.InfoContainerMouseOver(Event: TDOMEvent);
Begin
  SwitchBandIndex( Event );
  InfoContainer.DOMStyle.backgroundColor := 'LightBlue';
End;</pre>
<p>Now there are two more items I have to explain:</p>
<ul>
<li><strong>SwitchBandIndex()</strong> will do some magic for continuous forms, making sure that by using controls like InfoContainer you will access the right instance of that control (since there are as many instances, as many bands/lines in your continuous forms are);</li>
<li><strong>DOMStyle</strong> is another magic property of all controls through which you can access and manipulate the style of the underlying HTML control: here I set the backgrtound color of the InfoContainer (for the technically more inclined: it is a DIV deep inside).</li>
</ul>
<p>That&#8217;s it. Clean and simple. Now if we could manipulate the :hover pseudo-class easily&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/01/27/morfik-tips-how-to-handle-mouseover-and-mouseout-efficiently-and-how-to-stop-an-event-from-bubbling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vector Graphics Analog Clock in Morfik</title>
		<link>http://www.pannonrex.com/2007/01/22/vector-graphics-analog-clock-in-morfik/</link>
		<comments>http://www.pannonrex.com/2007/01/22/vector-graphics-analog-clock-in-morfik/#comments</comments>
		<pubDate>Mon, 22 Jan 2007 00:27:53 +0000</pubDate>
		<dc:creator>piprog</dc:creator>
				<category><![CDATA[Analog Clock]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Morfik]]></category>

		<guid isPermaLink="false">http://www.pannonrex.com/blog/?p=37</guid>
		<description><![CDATA[I have just finished a new sample Morfik application that contains a lot of interesting stuff including custom controls, browser independent vector graphics, and more. I plan to write a detailed entry about the internal workings in the coming days. Until then the very short summary: it was surprisingly easy to create the custom control [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" id="image41" alt="Analog Clock" title="Analog Clock" src="http://www.pannonrex.com/blog/wp-content/uploads/2007/01/Labs_Clock.jpg" />I have just finished a new sample Morfik application that contains a lot of interesting stuff including custom controls, browser independent vector graphics, and more. I plan to write a detailed entry about the internal workings in the coming days.</p>
<p>Until then the very short summary:</p>
<ul>
<li>it was surprisingly easy to create the custom control (the clock itself): it took a few hours without knowing anything about the new Adapter architecture in Morfik;</li>
<li>there is no single standard for vector graphics on all browsers, or there is (SVG), but Internet Explorer does not support it (instead it does VML) &#8212; so I created a rendering engine that sits above these and provides a browser independent way of doing vector graphics (it should work in recent versions of IE, Firefox, Netscape, Safari, Opera, and other Gecko 1.8+ based browsers).</li>
</ul>
<p>You can take a look at the application <a target="_blank" title="Analog Clock in Morfik Labs" href="http://clock.labs.morfik.com/">here</a> and download the source code in the <a title="Morfik Labs" target="_blank" href="http://morfik.com/#3I(frmXappMain!!)I(Morfik%20Pioneers!frmXappMain%3ASubForm1!)I(frmMain!Morfik%20Pioneers%3AMainSubForm!)I(frmCategories!frmMain%3ASubform1!)I(frmXAppGallery!frmMain%3ASubform2!%22prmCategoryID%3D8%22)I(frmMorfikBanner!Morfik%20Pioneers%3ASubForm1!)">Morfik Labs</a>.</p>
<p>To Be Continued&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pannonrex.com/2007/01/22/vector-graphics-analog-clock-in-morfik/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
