tag:blogger.com,1999:blog-47172590913921949762024-02-20T03:51:44.600+06:00Random code snippetsVitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-4717259091392194976.post-61424842302990417302010-09-08T20:20:00.000+06:002010-09-08T20:20:34.099+06:00How to install python PILInstalling PIL library using easy_install is easy as always. But it has some dependencies, that are not so obvious at first. In order to have support for JPEG, PNG and Freetype we need to install those development libraries as well.<br />
So the whole command list is as following:<br />
<br />
> apt-get install zlib1g-dev libfreetype6-dev libjpeg-dev<br />
> easy_install pil<br />
<br />
After PIL installation script is finished you should check for the following lines:<br />
*** TKINTER support not available<br />
--- JPEG support available<br />
--- ZLIB (PNG/ZIP) support available<br />
--- FREETYPE2 support available<br />
*** LITTLECMS support not available<br />
<br />
as you can see JPEG, ZLIB and FREETYPE support is available now.Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0tag:blogger.com,1999:blog-4717259091392194976.post-22965868994853493402010-04-24T09:39:00.003+06:002010-04-24T09:48:55.779+06:00Flex OLAP Aggregators Fix for Null and Undefined Values<p>There is very little information available on Adobe Flex data visualization components. Sometimes I even question whether it is used in production at all. In one of our recent projects we used OLAP components extensively. It is the first time I had to check out the source of component so often: to check out how it is supposed to work and to fix issues (and there are quite a lot). </p><p>Data visualization provides a set of aggregators: sum, average, count, max, min. But there is an issue how they handle null or undefined values. Result defaults to 0(zero) even if there is no value defined for given <em>dataField</em> in a <em>dataprovider</em> or all values are null/undefined. Maybe it is by design, but it is not how it is used in real world scenarios. For example, Flex chart components support null/undefined values and there is even <em>interpolateValues</em> property in <em>LineSeries </em>to handle exactly this situation.</p><p>Fortunately, it is easy to fix. Let’s look at mx.olap.aggregators.SumAggregator source code for example. There are 3 methods of interest to us: computeBegin, computeLoop, and computeEnd. First, computeBegin is called and you create a holder object where temporary data will be stored as aggregation proceeds. Next, there is a call to computeLoop for every object in dataprovider where you update your holder object. Finally, computeEnd is called where you compute the final result and return it back. You see, the problem is in computeBegin and computeLoop:</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 510px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: <span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> computeBegin(dataField:<span style="color: #0000ff">String</span>):Object
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2: {
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">3: <span style="color: #0000ff">var</span> newObj:Object = {};
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">4: newObj[dataField] = 0;
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">5: <span style="color: #0000ff">return</span> newObj;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">6: }
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">7:
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">8: <span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> computeLoop(data:Object, dataField:<span style="color: #0000ff">String</span>,
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">9: rowData:Object):<span style="color: #0000ff">void</span>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">10: {
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">11: <span style="color: #0000ff">var</span> value:<span style="color: #0000ff">Number</span> = rowData[dataField];
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">12: <span style="color: #0000ff">if</span> (<span style="color: #0000ff">typeof</span>(value) == "<span style="color: #8b0000">xml</span>")
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">13: value = <span style="color: #0000ff">Number</span>(value.<span style="color: #0000ff">toString</span>());
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">14: <span style="color: #0000ff">if</span> (!data.hasOwnProperty(dataField))
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">15: data[dataField] = value ;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">16: <span style="color: #0000ff">else</span>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">17: data[dataField] += value;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">18: }</pre><p> </p></pre><p>In comuteBegin holder object is immediately initialized to default 0 value (line 4). We can simply comment it, because in computeLoop this case is handled (line 14). But computeLoop has its own problems. There is no check for null/NaN values. So, if some of data objects does not have a value for given dataField the whole result is broken. Another problem is line 12. How Number type variable is supposed to be of type xml is beyond me. This check should be done before casting to Number. Looks like untested and unreviewed code to me. But interesting thing is how it stayed this way for 3 years. Anyway, here is the fixed version for sum aggregator:</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 510px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> computeBegin(dataField:<span style="color: #0000ff">String</span>):Object
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">return</span> {};
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> computeLoop(data:Object, dataField:<span style="color: #0000ff">String</span>,
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">rowData:Object):<span style="color: #0000ff">void</span>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">{
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">var</span> value:Object = rowData[dataField];
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">if</span>(value == <span style="color: #0000ff">null</span>)
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">return</span>;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">if</span> (<span style="color: #0000ff">typeof</span>(value) == "<span style="color: #8b0000">xml</span>")
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> value = <span style="color: #0000ff">Number</span>(value.<span style="color: #0000ff">toString</span>());
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">else</span>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> value = <span style="color: #0000ff">Number</span>(value);
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">if</span>(<span style="color: #0000ff">isNaN</span>(value as <span style="color: #0000ff">Number</span>))
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">return</span>;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">if</span> (!data.hasOwnProperty(dataField))
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> data[dataField] = value;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">else</span>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> data[dataField] += value;
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}</pre></pre><p>Other aggregators can be fixed just the same way.</p>Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0tag:blogger.com,1999:blog-4717259091392194976.post-62740031890092619832010-04-16T15:10:00.002+06:002010-04-16T15:17:15.715+06:00How To: Tomcat 6, BlazeDS 3.2, Hibernate 3.5 (JPA 2), Spring 3, Maven 2 – Part 1<p>In the following series of articles I want to explore how to set up a RIA project based on the latest stable Java and Flex stack using Maven and Eclipse. One would expect it to be easy enough and it is, but as always evil is in the details.</p><p><strong>Prerequisites:</strong> recent version of Eclipse(3.4, 3.5) and m2eclipse plugin from SonaType.</p><h2>Creating Web Project in Eclipse with Maven Dependency Management</h2><p>In one of my previous posts I have tried to express my love for Maven. Using it from command prompt is a pleasure: quickly generating projects from templates(archetypes), building, running test, packaging and deploying, all is good. These are repetitive steps that need to be automated and maven handles that quite good. But we also need our old good IDEs with all the features we are used to have and got addicted to. So we need to look at our project from several different perspectives. To do that we need to set our project so that Maven and Eclipse understand the format/structure.</p><p>There are two ways to go: create Dynamic Web Project in Eclipse and enable Maven Dependency Management in it or create new Maven Project and enable Dynamic Web Module Facet in it.</p><p>First approach is more appropriate when you have some project in progress and want to start managing its dependencies with Maven. You can accomplish this from Project context menu/Maven/Enable Dependency Management. But it is not enough, you will have to modify folder structure according to established Maven project structure standards. Your sources should be in src/main/java and web content should be in src/main/webapp. Then you will have to edit some configuration files. For example you need to edit wb-resource parameters in org.eclipse.wst.common.component file located in .settings folder, and some more.</p><p>It looks like too much manual modification of Eclipse managed and hidden(by default) settings files and that is why I prefer the second way (with some maven plug-in help of course). Here is a step by step explanation:</p><p>1. Create new Maven Project. Check “Create a simple maven project(skip archetype selection)” option and set packaging to WAR. You have a working maven project structure. No we would like to work with the project as if it is native eclipse dynamic web project.</p><p>2. But first you should modify your pom.xml file to enable Java version 1.5 (or 1.6, what ever you need). It is necessary,  because  by default Maven compiles java code as Java 1.4. We also need this configuration for the next step. Just add the following xml in you pom.xml file:</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 402px; padding-right: 5px; height: 340px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><build>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><plugins>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><plugin>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><groupId>org.apache.maven.plugins</groupId>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><artifactId>maven-compiler-plugin</artifactId>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><configuration>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><source>1.5</source>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><target>1.5</target>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></configuration>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></plugin>
</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></plugins>
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></build></pre></pre><p>It may look like too much custom xml, but after you work with maven for some time those plugin/dependency/groupId/artifactId elements just become part of your programming lexicon and m2eclipse plug-in with its code completion really helps here.</p><p>3. Now from Project context menu select Run As/Maven build… with the following options:</p><blockquote><p>Goals = eclipse:eclipse</p><p>Parameter Name = wtpversion, Parameter Value = 2.0</p></blockquote>After you run this maven build you get standard Eclipse Dynamic Web Project with Java Facet and Dynamic Web Module Facet enabled. Check it out from Project Properties / Project Facets section. Now you can configure Targeted Runtime (Tomcat 6 in our case) and other possible configurations you need just the same way you did it before maven era. <br />
<p>In Part2 we will explore how to further edit pom.xml file and add BlazeDS support using excellent Spring framework.</p>Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0tag:blogger.com,1999:blog-4717259091392194976.post-86037748835385702482010-01-17T21:07:00.001+06:002010-01-17T21:07:49.898+06:00Speed up compilation process with Ram Disk<p>I often review my software development toolbox to check if I my development process is actually optimal. Recently I was looking around if there is something new in the area of compilation time improvements. There are classics like IDE settings for Visual Studio and even more for Eclipse, maximum amount of RAM (unfortunately my notebook has 4Gb limit) and speedy hard disk options like 7200RPM and SSD disks. But there is something new (for me at least). All of you are familiar with DVD disk virtualization utilities. But what if we could have a virtual RAM disk? Something like ramdrive.sys from MS-DOS times. Then we could put our complete project folder on that disk and theoretically the compilation process, which has lots of disk read/writes, should speed up.</p> <p>Before you try this option on your current project I should remind you that in case ram disk fails you loose all your work since the last backup! All these utilities provide persistence to disk image file, but how do you know that it won’t be corrupted somehow. I hear you saying that you often commit to your source control, so do I. Then in case of your very unlucky day when everything just breaks you should lose at most a few hours of work.</p> <p>Below is the list of utilities:</p> <p><a href="http://ramdisk.tk/ ">QSoft Ramdisk</a> –  My choice. Commercial but free for 6 months and a good price. Just runs. Runs on 64bit Windows. Do not be afraid of their confusing web site :)</p> <p><a href="http://memory.dataram.com/products-and-services/software/ramdisk ">Dataram Ramdisk</a> – Would be my choice. Commercial with free option for up to 4Gb size disks. Seems to be the most popular and convenient, but I could not run it on Windows 7 64bit (compatibility mode does not help)</p> <p><a href="http://www.superspeed.com/ramdisk.php ">Superspeed</a> – another popular commercial utility with lots of features.</p> <p><a href="http://www.farstone.com/software/virtual-hard-drive-pro.htm ">Farstone Virtual Hard Drive PRO</a> – commercial. Seems to be a good option with good reviews on blogs.</p> <p><a href="http://www.softperfect.com/products/ramdisk/ ">Softperfect Ramdisk</a> – commercial. I did not try it myself</p> <p><a href="http://www.romexsoftware.com/main/products/vsuite.html ">VSuite Ramdisk</a> – commercial. I did not try it myself.</p> Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com2tag:blogger.com,1999:blog-4717259091392194976.post-91336368477502273982010-01-05T12:30:00.001+06:002010-01-05T12:30:16.771+06:00Class Not Found Issue in Eclipse<p>Recently I have come across a really strange bug in Eclipse 3.4.2 version. After adding new java class Eclipse refused to find it. And suddenly, it marked all my custom class imports as not found. Cleaning project, restarting IDE would not help. If you experience the same problem there is a simple quick solution. All you need is to change “Default output folder” in Project Properties/Java Build Path. Once you change output folder all those “class not found” errors will go away. Strange enough, but now you can change output folder path to the previous value and it will still compile correctly.</p> <p>I am not sure what is the real cause of this error,  one possibility is that maven plug-in somehow interferes with the process. If it is Eclipse itself then upgrade to 3.5 version may resolve this issue. Need to check.</p> Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0tag:blogger.com,1999:blog-4717259091392194976.post-18153430324691838702009-12-17T13:30:00.003+06:002009-12-17T13:59:46.194+06:00Toolbar Flex Button Control<p>In the <a href="http://tsvayer.blogspot.com/2009/12/borderless-flex-button-control.html">previous post</a> I have found a way how to remove borders from the Button control. But often in your toolbar buttons you have some of the buttons disabled and need to visually mark them as that. With borders it was obvious, as borders were drawn black/white. But what can we do without borders? If you look at some standard desktop applications, disabled buttons are completely drawn black/white and maybe with some lowered alpha value. In Flex we can do just that.</p> <p>Below you can see complete example of Button control:</p> <pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 500px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><?xml version="<span style="color: #8b0000">1.0</span>" encoding="<span style="color: #8b0000">utf-8</span>"?><br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><mx:Button xmlns:mx="<span style="color: #8b0000">http://www.adobe.com/2006/mxml</span>"<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> width="<span style="color: #8b0000">22</span>"<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> height="<span style="color: #8b0000">20</span>"<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> upSkin="<span style="color: #8b0000">mx.skins.Border</span>"<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> disabledSkin="<span style="color: #8b0000">mx.skins.Border</span>"><br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <mx:Script><br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <![CDATA[<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">var</span> bwMatrixArray:<span style="color: #0000ff">Array</span> = [.33, .33, .33, 0, 0,<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> .33, .33, .33, 0, 0,<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> .33, .33, .33, 0, 0,<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 0, 0, 0, 0.7, 0];<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">var</span> bwFilter:ColorMatrixFilter = <span style="color: #0000ff">new</span> ColorMatrixFilter(bwMatrixArray);<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> override <span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> set enabled(value:<span style="color: #0000ff">Boolean</span>):<span style="color: #0000ff">void</span> {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">super</span>.enabled = value;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">this</span>.filters = value ? [] : [bwFilter];<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> ]]><br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> </mx:Script><br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></mx:Button></pre></pre><br /><br /><p>Borders are removed by setting upSkin and disabledSkin to mx.skins.Border value. Black/white and alpha effect is achieved through ColorMatrixFilter with equal RGB values 0.33 and with alpha value set to 0.7. If you need icons for your toolbar buttons, there is a free icon set available at <a href="http://www.famfamfam.com/">http://www.famfamfam.com/</a>.</p> Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0tag:blogger.com,1999:blog-4717259091392194976.post-537622062762274742009-12-15T20:15:00.005+06:002009-12-15T20:21:00.339+06:00Borderless Flex Button Control<p>In our recent project with RIA Flex client we are using button icons with little neat shadow below. But inside button control with border enabled these shadows look ugly (even to me - developer). Unfortunately, in Flex 3 you can’t disable border of the button control. Yes, I did not believe it myself, but that is what we have. As getting new icons is much more trouble for me than hacking button control, I started to explore the ways to do it.</p><p>First, I tried to extend Button control class, but soon remembered that all the border and background drawings is done in the Skin classes. mx.skins.halo.ButtonSkin is the skin class for Button control in Flex 3. So, my second attempt was to extend this skin class. Unfortunately, all the drawings are done in the same method with no simple point of extension. That is extending this class meant coping 200 lines method and commenting out a few lines. It is not good at all. With no choice of easy elegant solution I was about to break that DRY rule. Fortunately (at last), I found simple, almost empty mx.skins.Border class and that was it - simple solution.</p><p>To disable borders in button control you need to simply set skin property to this mx.skins.Border class. Something like this:</p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 400px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><mx:Button skin="<span style="color: #8b0000">mx.skins.Border</span>" /></pre></pre><p>In addition, button control provides you a way to specify skin classes for various states individually:</p><ul><li>upSkin </li>
<li>overSkin </li>
<li>downSkin </li>
<li>disabledSkin </li>
<li>selectedUpSkin </li>
<li>selectedOverSkin </li>
<li>selectedDownSkin </li>
<li>selectedDisabledSkin </li>
</ul><br />
<p>So, if you need to disable borders but still enable them for cases like mouse-over, click, etc… you only need to set upSkin property.</p>Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com2tag:blogger.com,1999:blog-4717259091392194976.post-89257103128064943612009-12-14T22:41:00.001+06:002009-12-14T22:41:42.010+06:00Auto-Resizable TextInput and TextArea Flex Controls<p>Well, title says it all. Simple extension of TextInput and TextArea controls in Flex 3 to enable auto resize.</p> <pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">package</span> components {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">import</span> flash.events.Event;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">import</span> flash.text.TextFieldAutoSize;<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">import</span> mx.controls.TextInput;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> AutoSizeTextInput <span style="color: #0000ff">extends</span> TextInput {<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> AutoSizeTextInput() {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">super</span>();<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">this</span>.addEventListener(Event.CHANGE, <span style="color: #0000ff">function</span>(event:Event) {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> invalidateSize();<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> });<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> override <span style="color: #0000ff">protected</span> <span style="color: #0000ff">function</span> childrenCreated():<span style="color: #0000ff">void</span> {<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">this</span>.textField.autoSize = TextFieldAutoSize.LEFT;<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">super</span>.childrenCreated();<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}</pre></pre><br /><br /><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"><span style="color: #0000ff">package</span> components {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">import</span> flash.events.Event;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">import</span> flash.text.TextFieldAutoSize;<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">import</span> mx.controls.TextArea;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> AutoSizeTextInput <span style="color: #0000ff">extends</span> TextArea {<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">public</span> <span style="color: #0000ff">function</span> AutoSizeTextInput() {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">super</span>();<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> horizontalScrollPolicy = "<span style="color: #8b0000">off</span>";<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> verticalScrollPolicy = "<span style="color: #8b0000">off</span>";<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">this</span>.addEventListener(Event.CHANGE, <span style="color: #0000ff">function</span>(event:Event) {<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> invalidateSize();<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> });<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> override <span style="color: #0000ff">protected</span> <span style="color: #0000ff">function</span> childrenCreated():<span style="color: #0000ff">void</span> {<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">this</span>.textField.autoSize = TextFieldAutoSize.LEFT;<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">this</span>.textField.wordWrap = <span style="color: #0000ff">false</span>;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">super</span>.childrenCreated();<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> override <span style="color: #0000ff">protected</span> <span style="color: #0000ff">function</span> measure():<span style="color: #0000ff">void</span> {<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> <span style="color: #0000ff">super</span>.measure();<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> measuredWidth = textField.width;<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> measuredHeight = textField.height;<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> }<br /></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">}</pre></pre> Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com1tag:blogger.com,1999:blog-4717259091392194976.post-40604126699094879682009-12-11T00:39:00.005+06:002009-12-11T15:51:45.533+06:00Would You Consider Moving from .Net to Java?<p>First, I should clarify that I am a long time .Net developer with quite a few high grade projects behind. And I am in fact still heavily using excellent .Net Framework. There is certainly place for both of them, no flame war intended. But you know, everyone has a favorite one. With this post I start a series of articles in which I will try to explore some really cool Java technologies, which not so long time ago made Java my framework of choice. The primary target audience are those .Net developers who started to have that strange feeling that there should be something more than standard .Net framework and Visual Studio with all its conveniences. I strongly encourage you to try examples by hand and feel that excitement of learning something new. Some of you might argue that there ARE many exciting development done in .Net as well. Although I might agree, we have to admit that almost any .Net related open source project (and open source IS the driving force of innovation) is in some respect a reflection of the same project started years ago in Java or some other alternative technology like RoR. Anyway, lets start and you decide on yourself.</p><h4>Everything started with <a href="http://maven.apache.org/">Apache Maven</a></h4><p>I remember my first acquaintance with Maven. My reaction was: “I want this tool in .Net !”. I was so much excited with it that I have spent couple of days playing with it and searching for .Net equivalent. Without any success I started to consider building one. How naive I was! First let me explain what is all the fuss about. </p><p>Lets imagine we are about to build a web application. How do you set your project/solution/workspace? What is your directory structure? Where do you put source files, resources, tests, configuration files, etc? How do you add/resolve references/dependencies to external assemblies/libraries?  What about different versions of those libraries? Hopefully you have some templates setup in Visual Studio to reuse them later. But are you consistent from project to project? Are your different developer teams consistent with each other? It is quite a long list of questions and we are just about to create our project. Well, Maven is the tool from Apache Foundation to answer all of these and more. But you have to try it yourself to see all the possibilities and flexibility it provides.</p><p>Lets install Maven first and try some examples. I expect you already have a recent JDK installed on your system. Now go to <a href="http://maven.apache.org/download.html">Maven web site</a> download latest release and follow simple steps to install it (unzipping and PATH environment variable settings). Now create some working folder for our examples , open command prompt in it and execute the following:</p><pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: >mvn archetype:generate</pre></pre><p>You will see lots of text as an output. First it may confuse you, but explore it a little bit. You will realize that Maven gave us a list of project types (archetypes in Maven terminology). Some keywords in the list may sound familiar to you, <em>struts </em>(one of the first web frameworks in Java world) or maybe <em>spring </em>(popular IoC container with support for integration with many other technologies). Lets just choose #18 (in your case number may vary) which is <em>maven-archetype-webapp</em>. Now Maven will prompt you for groupId, artifactId and version. These are the properties which make any module/library/assembly unique. For this example we can enter something like com.tsvayer, web-app,1.0 accordingly. For further prompts simply accept default values.</p><p>What we got as a result is a web application template with standard folder structure for our source files, standard Java web application folders like WEB-INF,  tests etc. Now execute the following two commands:</p><pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: >cd web-app
</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">2: >mvn tomcat:run</pre></pre><p>You will see lots of text output and Maven will download some files. Simply ignore it for now. After you see this last message “INFO: Starting Coyote HTTP/1.1 on http-8080” open your browser and direct to <a href="http://localhost:8080/web-app">http://localhost:8080/web-app</a>. You should see running Hello World web application. Cool.</p><p>Now stop it pressing CTRL-C and execute the following command:</p><pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: >mvn jetty:run</pre></pre><p>Again you will see lots of output and some downloads and after “Started Jetty Server” browse to <a href="http://localhost:8080/web-app">http://localhost:8080/web-app</a></p><p>Lets stop and analyse what we have done so far. Before this Maven thing all we had is JDK installed. Then we installed some little tool called Maven, executed few commands and got a working web application hosted on a real Web Server. Wait, on two different real web servers, that is <a href="http://tomcat.apache.org/">Tomcat</a> and <a href="http://www.mortbay.org/jetty/">Jetty</a> (in fact, you can try others as well, just run mvn jboss:run to run under JBoss, but be prepared, it will download lots of Mbs). Some of you may notice similarity with Ubuntu/Debian linux apt-get utility.</p><p>Now execute the following command:</p><pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: >mvn <span style="color: #0000ff">package</span></pre></pre><p>After some more strange output you can find a <em>target </em>folder created and <em>web-app.war</em> file in it. What we have done is building our application, running unit tests on it(notice No Tests to Run info messages in the output) and packaging it in a standard Java WAR archive ready to be deployed on a production web server.</p><p>Just think about it, it is quite a lot for a few commands. By simply typing a few commands you get the whole application stack downloaded from internet with right external dependencies with right versions, all ready to develop, build, test, run and deploy ANY kind of application in ANY kind of hosting environment. Just imagine how easy it is now to have a standard development environment in your team, standard way of structuring your applications, standard way of building/packaging and deploying. In case you are not excited as much as I am, remember the day a new junior developer has joined your team with a fresh installed machine and how frustrating it was to set that machine to the same “comfortable” level as yours. Another question to consider: “Are you afraid to format you machine?” :)</p><p>To conclude this part, I just want to introduce you one more Maven command. Maybe some of you are not so much comfortable with command prompt and maybe you even say: “Man, wasn’t it supposed to eas the whole development process? Will I have to develop my web application from command prompt?”. As an answer for this, just execute the following command:</p><pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: >mvn eclipse:eclipse</pre></pre><p>And if you have an Eclipse IDE installed on your system, your project is ready to be imported. Now you can enjoy all the conveniences of modern IDE. All of the commands we just learned above are available through mouse clicks.</p><p>“But wait, I heard IntelliJ IDEA is the best Java IDE out there. I want that instead“. Just execute the following:</p><pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px">1: >mvn idea:idea</pre></pre><p>and you are ready to go. In fact, all the modern IDEs support Maven generated projects directly.</p><p>In conclusion I want to clarify why building such a tool in .Net won’t be so much a cool idea as it is in Java. The reason is open source community. Just google how many libraries of any kind out there in Java world freely available to you and then you start to understand how invaluable Maven is. Just go to Apache Foundation web site and see it. In contrary, what we have in .Net world? Well, you answer that. Although I see certain benefits of using such a tool internally for in house built assemblies, and all that version conflict resolutions etc, the real benefit of Maven is in the availability of a central repository available over internet anytime anywhere.</p>Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com26tag:blogger.com,1999:blog-4717259091392194976.post-68563489917908346202009-12-10T18:10:00.001+06:002009-12-10T18:16:44.397+06:00MATE File Upload Service InvokerIf you are working with Adobe Flex technology you probably heard of <a href="http://mate.asfusion.com/">MATE Flex Framework</a>. It is “a tag-based, event-driven Flex framework” with IoC container, view auto wiring and other convenient features. In one of my recent projects there was a requirement to import local data files in XML format. Unfortunately, Flash Player 9 was a constraint as it does not allow to load local files into Flex application. This feature comes with Flash Player 10 through FileReference.load method. In this scenario you have to first upload file on to the server and download it back to Flex client application. MATE framework provides a concept of Service Invokers for remote communication, configurable through its Event Maps in MXML format. There are Service Invokers for RemoteObject, HTTPService and WebService available out of the box. It seemed logical to handle this file upload scenario the same way. Unfortunately, current version of MATE does not provide such a Service Invoker, so I decided to build it myself. <br />
It consists of two classes: FileUploadServiceInvoker and FileUploadHandlers. You can see them below:<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">1: <span style="color: blue;">package</span> components {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">2: <span style="color: blue;">import</span> com.asfusion.mate.actionLists.IScope;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">3: <span style="color: blue;">import</span> com.asfusion.mate.actions.IAction;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">4: <span style="color: blue;">import</span> com.asfusion.mate.actions.builders.ServiceInvoker;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">5: <span style="color: blue;">import</span> com.asfusion.mate.core.ISmartObject;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">6: <span style="color: blue;">import</span> com.asfusion.mate.events.UnhandledFaultEvent;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">7:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">8: <span style="color: blue;">import</span> flash.events.DataEvent;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">9: <span style="color: blue;">import</span> flash.events.IOErrorEvent;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">10: <span style="color: blue;">import</span> flash.net.FileReference;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">11: <span style="color: blue;">import</span> flash.net.URLRequest;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">12:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">13: <span style="color: blue;">public</span> <span style="color: blue;">class</span> FileUploadServiceInvoker <span style="color: blue;">extends</span> ServiceInvoker <span style="color: blue;">implements</span> IAction {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">14: <span style="color: blue;">private</span> <span style="color: blue;">var</span> _url:<span style="color: blue;">String</span>;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">15: <span style="color: blue;">private</span> <span style="color: blue;">var</span> _fileReference:Object;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">16:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">17: <span style="color: blue;">public</span> <span style="color: blue;">function</span> FileUploadServiceInvoker() {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">18: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">19:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">20: <span style="color: blue;">public</span> <span style="color: blue;">function</span> get url():Object {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">21: <span style="color: blue;">return</span> _url;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">22: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">23:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">24: <span style="color: blue;">public</span> <span style="color: blue;">function</span> set url(value:Object):<span style="color: blue;">void</span> {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">25: <span style="color: blue;">if</span> (value is <span style="color: blue;">String</span>) {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">26: _url = <span style="color: blue;">String</span>(value);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">27: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">28: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">29:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">30: <span style="color: blue;">public</span> <span style="color: blue;">function</span> get fileReference():Object {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">31: <span style="color: blue;">return</span> _fileReference;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">32: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">33:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">34: <span style="color: blue;">public</span> <span style="color: blue;">function</span> set fileReference(value:Object):<span style="color: blue;">void</span> {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">35: _fileReference = value;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">36: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">37:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">38: override <span style="color: blue;">protected</span> <span style="color: blue;">function</span> run(scope:IScope):<span style="color: blue;">void</span> {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">39: <span style="color: blue;">var</span> uploadRequest:URLRequest = <span style="color: blue;">new</span> URLRequest(_url);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">40: getRealFileReference(scope).upload(uploadRequest);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">41: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">42:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">43: <span style="color: blue;">private</span> <span style="color: blue;">function</span> getRealFileReference(scope:IScope):FileReference {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">44: <span style="color: blue;">var</span> value:FileReference = fileReference is ISmartObject ? ISmartObject(fileReference).getValue(scope) as FileReference : FileReference(fileReference);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">45: <span style="color: blue;">return</span> value;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">46: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">47:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">48: override <span style="color: blue;">protected</span> <span style="color: blue;">function</span> complete(scope:IScope):<span style="color: blue;">void</span> {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">49: innerHandlersDispatcher = getRealFileReference(scope);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">50: <span style="color: blue;">if</span> (resultHandlers && resultHandlers.<span style="color: blue;">length</span> > 0) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">51: <span style="color: blue;">var</span> resultHandlersInstance:FileUploadHandlers = createInnerHandlers(scope, DataEvent.UPLOAD_COMPLETE_DATA, resultHandlers, FileUploadHandlers) as FileUploadHandlers;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">52: resultHandlersInstance.validateNow();
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">53: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">54: <span style="color: blue;">if</span> ((faultHandlers && faultHandlers.<span style="color: blue;">length</span> > 0) || scope.dispatcher.hasEventListener(UnhandledFaultEvent.FAULT)) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">55: <span style="color: blue;">var</span> faultHandlersInstance:FileUploadHandlers = createInnerHandlers(scope, IOErrorEvent.IO_ERROR, faultHandlers, FileUploadHandlers) as FileUploadHandlers;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">56: faultHandlersInstance.validateNow();
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">57: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">58: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">59: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">60: }</pre>
</pre><br />
<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">1: <span style="color: blue;">package</span> components {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">2: <span style="color: blue;">import</span> com.asfusion.mate.actionLists.EventHandlers;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">3: <span style="color: blue;">import</span> com.asfusion.mate.actionLists.IScope;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">4: <span style="color: blue;">import</span> com.asfusion.mate.actionLists.ServiceScope;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">5: <span style="color: blue;">import</span> com.asfusion.mate.events.UnhandledFaultEvent;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">6:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">7: <span style="color: blue;">import</span> flash.events.DataEvent;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">8: <span style="color: blue;">import</span> flash.events.Event;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">9: <span style="color: blue;">import</span> flash.events.IOErrorEvent;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">10:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">11: <span style="color: blue;">import</span> mx.rpc.Fault;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">12:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">13: <span style="color: blue;">public</span> <span style="color: blue;">class</span> FileUploadHandlers <span style="color: blue;">extends</span> EventHandlers {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">14: <span style="color: blue;">public</span> <span style="color: blue;">function</span> FileUploadHandlers(inheritedScope:IScope = <span style="color: blue;">null</span>) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">15: <span style="color: blue;">super</span>();
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">16: <span style="color: blue;">this</span>.inheritedScope = inheritedScope;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">17: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">18:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">19: override <span style="color: blue;">protected</span> <span style="color: blue;">function</span> fireEvent(event:Event):<span style="color: blue;">void</span> {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">20: <span style="color: blue;">if</span> (actions && actions.<span style="color: blue;">length</span> > 0) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">21: <span style="color: blue;">var</span> currentScope:ServiceScope = <span style="color: blue;">new</span> ServiceScope(inheritedScope.event, debug, inheritedScope);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">22: currentScope.owner = <span style="color: blue;">this</span>;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">23:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">24: <span style="color: blue;">if</span> (event is DataEvent && event.type == DataEvent.UPLOAD_COMPLETE_DATA) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">25: currentScope.result = DataEvent(event).data;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">26: } <span style="color: blue;">else</span> <span style="color: blue;">if</span> (event is IOErrorEvent) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">27: currentScope.fault = <span style="color: blue;">new</span> Fault("<span style="color: darkred;"></span>", IOErrorEvent(event).text);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">28: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">29:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">30: setScope(currentScope);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">31: runSequence(currentScope, actions);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">32: } <span style="color: blue;">else</span> <span style="color: blue;">if</span> (event is IOErrorEvent) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">33: <span style="color: blue;">var</span> faultEvent:UnhandledFaultEvent = <span style="color: blue;">new</span> UnhandledFaultEvent(UnhandledFaultEvent.FAULT);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">34: faultEvent.fault = <span style="color: blue;">new</span> Fault("<span style="color: darkred;"></span>", IOErrorEvent(event).text);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">35: inheritedScope.dispatcher.dispatchEvent(faultEvent);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">36: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">37: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">38: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">39: }</pre>
</pre><br />
FileUploadServiceInvoker prepares URLRequest and calls FileReference.upload in its run() method. FileUploadHandlers handles DataEvent.UPLOAD_COMPLETE_DATA and IOErrorEvent events in its fireEvent() method. Everything else is MATE specific code like scope management etc.<br />
<br />
Usage of this service invoker is exactly the same as other service invokers provided by MATE. To give a short example, lets suppose we need to import local XML data file and bind it to DataGrid. Here you can see main.mxml file, FileUploadEvent even class which holds FileReference object, MainEventMap which configures Handlers/Injectors and server side import.jsp which simply echoes uploaded file back to Flex client.<br />
<br />
main.mxml<br />
<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">1: <span style="color: blue;"><?</span>xml version="1.0" encoding="utf-8"<span style="color: blue;">?></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">2: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Application</span> <span style="color: red;">xmlns</span>:<span style="color: red;">mx</span>=<span style="color: blue;">"http://www.adobe.com/2006/mxml"</span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">3: <span style="color: red;">layout</span>=<span style="color: blue;">"vertical"</span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">4: <span style="color: red;">xmlns</span>:<span style="color: red;">maps</span>=<span style="color: blue;">"maps.*"</span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">5: <span style="color: red;">xmlns</span>:<span style="color: red;">net</span>=<span style="color: blue;">"flash.net.*"</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">6: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Script</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">7: <span style="color: blue;"><</span>![CDATA[
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">8: import mx.controls.Alert;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">9: import mx.rpc.Fault;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">10: import components.FileUploadEvent;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">11:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">12: [Bindable]
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">13: private var xmlData:XML;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">14:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">15: private function selectFile():void {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">16: fileRef.addEventListener(Event.SELECT, onFileSelect);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">17: fileRef.browse();
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">18: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">19:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">20: private function onFileSelect(event:Event):void {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">21: var uploadEvent:FileUploadEvent = new FileUploadEvent(FileUploadEvent.FILE_UPLOAD, true);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">22: uploadEvent.fileReference = fileRef;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">23: dispatchEvent(uploadEvent);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">24: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">25:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">26: public function onResult(data:*):void {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">27: xmlData = new XML(data);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">28: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">29:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">30: public function onFail(fault:Fault):void {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">31: Alert.show(fault.faultString);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">32: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">33: ]]<span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">34: <span style="color: blue;"></</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Script</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">35: <span style="color: blue;"><</span><span style="color: mediumvioletred;">maps</span>:<span style="color: maroon;">MainEventMap</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">36:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">37: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Button</span> <span style="color: red;">label</span>=<span style="color: blue;">"Select File"</span> <span style="color: red;">click</span>=<span style="color: blue;">"selectFile()"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">38: <span style="color: blue;"><</span><span style="color: mediumvioletred;">net</span>:<span style="color: maroon;">FileReference</span> <span style="color: red;">id</span>=<span style="color: blue;">"fileRef"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">39: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">DataGrid</span> <span style="color: red;">dataProvider</span>=<span style="color: blue;">"{xmlData.member}"</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">40: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">columns</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">41: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">DataGridColumn</span> <span style="color: red;">dataField</span>=<span style="color: blue;">"@name"</span> <span style="color: red;">headerText</span>=<span style="color: blue;">"Name"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">42: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">DataGridColumn</span> <span style="color: red;">dataField</span>=<span style="color: blue;">"@email"</span> <span style="color: red;">headerText</span>=<span style="color: blue;">"Email"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">43: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">DataGridColumn</span> <span style="color: red;">dataField</span>=<span style="color: blue;">"@department"</span> <span style="color: red;">headerText</span>=<span style="color: blue;">"Department"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">44: <span style="color: blue;"></</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">columns</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">45: <span style="color: blue;"></</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">DataGrid</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">46: <span style="color: blue;"></</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Application</span><span style="color: blue;">></span></pre>
</pre><br />
FileUploadEvent.as<br />
<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">1: <span style="color: blue;">package</span> components {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">2: <span style="color: blue;">import</span> flash.events.Event;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">3: <span style="color: blue;">import</span> flash.net.FileReference;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">4:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">5: <span style="color: blue;">public</span> <span style="color: blue;">class</span> FileUploadEvent <span style="color: blue;">extends</span> Event {
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">6: <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">const</span> FILE_UPLOAD:<span style="color: blue;">String</span> = "<span style="color: darkred;">fileUpload</span>";
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">7:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">8: <span style="color: blue;">public</span> <span style="color: blue;">var</span> fileReference:FileReference;
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">9:
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">10: <span style="color: blue;">public</span> <span style="color: blue;">function</span> FileUploadEvent(type:<span style="color: blue;">String</span>, bubbles:<span style="color: blue;">Boolean</span> = <span style="color: blue;">false</span>, cancelable:<span style="color: blue;">Boolean</span> = <span style="color: blue;">false</span>) {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">11: <span style="color: blue;">super</span>(type, bubbles, cancelable);
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">12: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">13: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">14: }</pre>
</pre><br />
MainEventMap.mxml<br />
<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">1: <span style="color: blue;"><?</span>xml version="1.0" encoding="utf-8"<span style="color: blue;">?></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">2: <span style="color: blue;"><</span><span style="color: maroon;">EventMap</span> <span style="color: red;">xmlns</span>:<span style="color: red;">mx</span>=<span style="color: blue;">"http://www.adobe.com/2006/mxml"</span> <span style="color: red;">xmlns</span>=<span style="color: blue;">"http://mate.asfusion.com/"</span> <span style="color: red;">xmlns</span>:<span style="color: red;">components</span>=<span style="color: blue;">"components.*"</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">3: <span style="color: blue;"><</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Script</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">4: <span style="color: blue;"><</span>![CDATA[
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">5: import components.FileUploadEvent;
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">6: ]]<span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">7: <span style="color: blue;"></</span><span style="color: mediumvioletred;">mx</span>:<span style="color: maroon;">Script</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">8: <span style="color: blue;"><</span><span style="color: maroon;">EventHandlers</span> <span style="color: red;">type</span>=<span style="color: blue;">"{FileUploadEvent.FILE_UPLOAD}"</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">9: <span style="color: blue;"><</span><span style="color: mediumvioletred;">components</span>:<span style="color: maroon;">FileUploadServiceInvoker</span> <span style="color: red;">url</span>=<span style="color: blue;">"import.jsp"</span> <span style="color: red;">fileReference</span>=<span style="color: blue;">"{event.fileReference}"</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">10: <span style="color: blue;"><</span><span style="color: mediumvioletred;">components</span>:<span style="color: maroon;">resultHandlers</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">11: <span style="color: blue;"><</span><span style="color: maroon;">CallBack</span> <span style="color: red;">method</span>=<span style="color: blue;">"onResult"</span> <span style="color: red;">arguments</span>=<span style="color: blue;">"{resultObject}"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">12: <span style="color: blue;"></</span><span style="color: mediumvioletred;">components</span>:<span style="color: maroon;">resultHandlers</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">13: <span style="color: blue;"><</span><span style="color: mediumvioletred;">components</span>:<span style="color: maroon;">faultHandlers</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">14: <span style="color: blue;"><</span><span style="color: maroon;">CallBack</span> <span style="color: red;">method</span>=<span style="color: blue;">"onFail"</span> <span style="color: red;">arguments</span>=<span style="color: blue;">"{fault}"</span> <span style="color: blue;">/></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">15: <span style="color: blue;"></</span><span style="color: mediumvioletred;">components</span>:<span style="color: maroon;">faultHandlers</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">16: <span style="color: blue;"></</span><span style="color: mediumvioletred;">components</span>:<span style="color: maroon;">FileUploadServiceInvoker</span><span style="color: blue;">></span>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">17: <span style="color: blue;"></</span><span style="color: maroon;">EventHandlers</span><span style="color: blue;">></span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">18: <span style="color: blue;"></</span><span style="color: maroon;">EventMap</span><span style="color: blue;">></span></pre>
</pre><br />
import.jsp<br />
<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">1: <%@page <span style="color: blue;">import</span>="<span style="color: darkred;">org.apache.commons.fileupload.FileItem</span>"%>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">2: <%@page <span style="color: blue;">import</span>="<span style="color: darkred;">java.util.List</span>"%>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">3: <%@page <span style="color: blue;">import</span>="<span style="color: darkred;">org.apache.commons.fileupload.servlet.ServletFileUpload</span>"%>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">4: <%@page <span style="color: blue;">import</span>="<span style="color: darkred;">org.apache.commons.fileupload.disk.DiskFileItemFactory</span>"%>
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">5: <%
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">6:
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">7: DiskFileItemFactory factory = <span style="color: blue;">new</span> DiskFileItemFactory();
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">8: ServletFileUpload upload = <span style="color: blue;">new</span> ServletFileUpload(factory);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">9: <span style="color: green;">//@SuppressWarnings("unchecked")</span>
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">10: List items = upload.parseRequest(request);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">11: <span style="color: blue;">for</span>(<span style="color: blue;">int</span> i= 0; i <items.size(); i++){
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">12: FileItem item = (FileItem)items.get(i);
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">13: <span style="color: blue;">if</span>(!item.isFormField())
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">14: {
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">15: out.write(<span style="color: blue;">new</span> String(item.get(), "<span style="color: darkred;">UTF-8</span>"));
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">16: }
</pre><pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">17: }
</pre><pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;">18: %></pre>
</pre>Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0tag:blogger.com,1999:blog-4717259091392194976.post-334737235701478402009-11-29T03:50:00.006+06:002009-11-29T05:44:08.931+06:00How to host your Blogger theme imagesI was thinking on the topic for my first blog post. Suddenly, I realized that there is one little problem I just solved and probably should share with others.<br />
<br />
I was searching for a good simple theme for my new software development oriented blog. There are some nice free themes to start with on the net. I picked one, customized a little bit (few css and image tweaks), and just before saving it in Blogger Settings Layout panel, my brain threw an exception, saying: “Man, you need some place to host your theme image files!”. Fortunately, I managed to catch that and after some stack trace investigation came up with a few possible recovery solutions:<br />
<ul><li>Find similar images (mostly background) on the net and use that </li>
<li>Host images on some free/paid hosting site </li>
<li>Host images on Blogger itself </li>
</ul>Well, the first one is not reliable, at least, and although images in my theme are very simple I would have to find similar ones. Second one is not logical, if I need some place to host something related to my blog on Blogger, than why do I need Blogger at all? The last one seems to be the most reliable and elegant solution. And actually simple one.<br />
<br />
All you need is to create a new post, insert all the images used in your theme and publish it (or save as a draft if you do not want everyone to see some strange post with a list of 1px wide images). That’s it. If you see your images in your browser than Blogger hosts them, right? Then there is some URL, right? Absolutely. Now you need to update your theme with URLs of the images from your post hosted on Blogger.<br />
<br />
Well, in fact, this post is exactly that post which contains those 2 images used in my theme. You can see them below.<br />
<div class="separator" style="clear: both; text-align: left;"><br />
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1-orEytwQwUfTC3wAJIX-zjSlv4kplfzZ1hURYX2N8T5LM1XDe1hC1IgvimW8TSi_CzADp_4RM1d4DJbN1kigicY48_b05yqBYd14Ak3r7wxj-77hAwbxCexMYu5hN-yS4w9EGgs-ZhNi/s1600/top-bg_vit.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1-orEytwQwUfTC3wAJIX-zjSlv4kplfzZ1hURYX2N8T5LM1XDe1hC1IgvimW8TSi_CzADp_4RM1d4DJbN1kigicY48_b05yqBYd14Ak3r7wxj-77hAwbxCexMYu5hN-yS4w9EGgs-ZhNi/s320/top-bg_vit.png" /></a><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5JN3lFbzBcqwVYSNlgMFF0WkCIM3AJ_Uplq9YntXwfK0GoQsGTqI3ptWZanikt9-bbmSjtXWhzCPMQxPZbFwpTwDvz9GXzLct1fgpHegv1fA3HXXXaBiSh0UvZ77oXQfwNmPgtNqVjrfJ/s1600/bulled.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5JN3lFbzBcqwVYSNlgMFF0WkCIM3AJ_Uplq9YntXwfK0GoQsGTqI3ptWZanikt9-bbmSjtXWhzCPMQxPZbFwpTwDvz9GXzLct1fgpHegv1fA3HXXXaBiSh0UvZ77oXQfwNmPgtNqVjrfJ/s320/bulled.png" /></a><br />
</div><br />
<br />
Ok, this is my first post on this blog and I hope it will be useful to someone. If it is, please drop some note below. It is really nice to <a href="http://www.phpbuilder.com/board/showthread.php?t=10272060">hear</a> that these few bytes of information help someone.Vitaliy Tsvayerhttp://www.blogger.com/profile/00145257982118777153noreply@blogger.com0