<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="/templates/default/atom.css" type="text/css" ?>

<feed version="0.3" 
   xmlns="http://purl.org/atom/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <link href="http://blog.bisna.com/rss.php?version=atom0.3" rel="service.feed" title="Bisna Blog" type="application/x.atom+xml" />
    <link href="http://blog.bisna.com/"                        rel="alternate"    title="Bisna Blog" type="text/html" />
    <link href="http://blog.bisna.com/rss.php?version=2.0"     rel="alternate"    title="Bisna Blog" type="application/rss+xml" />
    <title mode="escaped" type="text/html">Bisna Blog</title>
    <tagline mode="escaped" type="text/html"></tagline>
    <id>http://blog.bisna.com/</id>
    <modified>2009-04-05T19:16:43Z</modified>
    <generator url="http://www.s9y.org/" version="1.3.1">Serendipity 1.3.1 - http://www.s9y.org/</generator>
    <dc:language>en</dc:language>
    <info mode="xml" type="text/html">
        <div xmlns="http://www.w3.org/1999/xhtml">You are viewing an ATOM formatted XML site feed. Usually this file is inteded to be viewed in an aggregator or syndication software. If you want to know more about ATOM, please visist <a href="http://atomenabled.org/">Atomenabled.org</a></div>
    </info>

    <entry>
        <link href="http://blog.bisna.com/index.php?/archives/Turning-array-hydrated-resultset-of-a-Doctrine-Model-into-a-tree-structure.html" rel="alternate" title="Turning array-hydrated resultset of a Doctrine Model into a tree structure" type="text/html" />
        <author>
            <name>Guilherme Blanco</name>
                    </author>
    
        <issued>2009-03-30T13:41:14Z</issued>
        <created>2009-03-30T13:41:14Z</created>
        <modified>2009-04-05T19:16:43Z</modified>
        <wfw:comment>http://blog.bisna.com/wfwcomment.php?cid=5</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://blog.bisna.com/rss.php?version=atom0.3&amp;type=comments&amp;cid=5</wfw:commentRss>
    
        <id>http://blog.bisna.com/index.php?/archives/5.html</id>
        <title mode="escaped" type="text/html">Turning array-hydrated resultset of a Doctrine Model into a tree structure</title>
        <content type="application/xhtml+xml" xml:base="http://blog.bisna.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Too many people request me this enhancement, also it should be included in 1.1 branch.<br />
Unfortunately, I did this method AFTER Doctrine 1.1 became feature freezed, so it could not be included in distribution.<br />
<br />
I actually didn't finish the implementation of this. It currently only deals with array-hydrated resultsets. When I was building it, I found a couple of needed changes into 1.1 that I did until the feature freeze, so the record-hydrated resultset is easy enough to accomplish too. To include the support, just use mapValue() method.<br />
<br />
I usually create a DoctrineX_NestedSet class to support this and also other methods.<br />
Feel free to use it as you want.<br />
<br />
<div class="php" style="text-align: left"><span style="color: #000000; font-weight: bold;">class</span> DoctrineX_NestedSet<br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; public <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/static');"  href="http://www.php.net/static"><span style="color: #000066;">static</span></a> <span style="color: #000000; font-weight: bold;">function</span> toHierarchy<span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$collection</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Trees mapped</span><br />&#160; &#160; &#160; &#160; <span style="color: #0000ff;">$trees</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/array');"  href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; <span style="color: #0000ff;">$l</span> = <span style="color: #cc66cc;">0</span>;<br /><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/count');"  href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$collection</span><span style="color: #66cc66;">&#41;</span> &gt; <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Node Stack. Used to help building the hierarchy</span><br />&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$stack</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/array');"  href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">foreach</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$collection</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$child</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$item</span> = <span style="color: #0000ff;">$child</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$item</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'__children'</span><span style="color: #66cc66;">&#93;</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/array');"  href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Number of stack items</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$l</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/count');"  href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#41;</span>;<br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Check if we're dealing with different levels</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$l</span> &gt; <span style="color: #cc66cc;">0</span> &amp;&amp; <span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$l</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'level'</span><span style="color: #66cc66;">&#93;</span> &gt;= <span style="color: #0000ff;">$item</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'level'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/array_pop');"  href="http://www.php.net/array_pop"><span style="color: #000066;">array_pop</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$l</span>--;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Stack is empty (we are inspecting the root)</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$l</span> == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Assigning the root child</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$i</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/count');"  href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$trees</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$trees</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$item</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = &amp; <span style="color: #0000ff;">$trees</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #808080; font-style: italic;">// Add child to parent</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$i</span> = <a onclick="javascript: pageTracker._trackPageview('/extlink/www.php.net/count');"  href="http://www.php.net/count"><span style="color: #000066;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$l</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'__children'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$l</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'__children'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$item</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = &amp; <span style="color: #0000ff;">$stack</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$l</span> - <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">'__children'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #66cc66;">&#93;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><br />&#160; &#160; &#160; &#160; <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">$trees</span>;<br />&#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span></div><br />
<br />
<br />
Usage:<br />
<br />
<div class="php" style="text-align: left"><span style="color: #808080; font-style: italic;">// Just remember to ORDER BY root_id AND lft ascending and to select level column!</span><br /><span style="color: #808080; font-style: italic;">// ...</span><br /><span style="color: #0000ff;">$rs</span> = <span style="color: #0000ff;">$q</span>-&gt;<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$params</span>, Doctrine::<span style="color: #006600;">HYDRATE_ARRAY</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #0000ff;">$trees</span> = DoctrineX_NestedSet::<span style="color: #006600;">toHierarchy</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$rs</span><span style="color: #66cc66;">&#41;</span>;</div> 
            </div>
        </content>

        
    </entry>
    <entry>
        <link href="http://blog.bisna.com/index.php?/archives/Seven-things-you-probably-dont-know-about-me.html" rel="alternate" title="Seven things you probably don't know about me" type="text/html" />
        <author>
            <name>Guilherme Blanco</name>
                    </author>
    
        <issued>2009-01-05T12:12:41Z</issued>
        <created>2009-01-05T12:12:41Z</created>
        <modified>2009-01-05T15:18:18Z</modified>
        <wfw:comment>http://blog.bisna.com/wfwcomment.php?cid=4</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.bisna.com/rss.php?version=atom0.3&amp;type=comments&amp;cid=4</wfw:commentRss>
    
        <id>http://blog.bisna.com/index.php?/archives/4.html</id>
        <title mode="escaped" type="text/html">Seven things you probably don't know about me</title>
        <content type="application/xhtml+xml" xml:base="http://blog.bisna.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                Ok, I got tagged by <a onclick="javascript: pageTracker._trackPageview('/extlink/www.rafaeldohms.com.br/?language=en');"  href="http://www.rafaeldohms.com.br/?language=en">Rafael Dohms</a>...<br />
<br />
You may see that this blog is not too much updated, but I'll try from now to stay engadget with community.<br />
Here is my list... no particular order, just remembering and typing:<br />
<br />
- <strong>Once I won a chess match with the São Paulo state champion.</strong> When I was on primary school, I participate on a tournament that was suppose to play with the São Paulo state chess champion and also later a season with other players until the winner appears.<br />
I played twice with the guy and one of those games I won. He invited me to go to his chess school... and he's probably waiting me until now... lol<br />
<br />
- <strong>I went to a party dressed like a girl.</strong> Ok, no games, right?! It was intentional. My girlfriend and I were invited to a party where women needed to go dressed like guys and guys like womens. My gf took more than 5h "preparing" me to go to the party... a blonde wig, maquillage, mini-skirt, top, bra with silicone, etc. And now I don't get angry when she takes forever to be ready.... lol<br />
<br />
- <strong>My first nickname on internet was Yakko.</strong> No appearent reason, I was a fan of Animaniacs and decided to use it everywhere... when I was 15 I switched to my real name and never changed again.<br />
<br />
- <strong>My middle name is "Augusto".</strong> But you never heard that... and will never hear again, ok?! I hate it, honestly.<br />
<br />
- <strong>Most of my life I lived on my family's farm.</strong> I know everything you can imagine about country. I enjoy country music, know how to take milk from cows, love to fish, organized challenges between scorpions and spiders until one of them die, etc.<br />
<br />
- <strong>I drink TOO MUCH beer.</strong> Andrei is the proof of concept. Drinking from morning to evening with not stopping is awesome!<br />
<br />
- <strong>I forget a lot of things that I need to do.</strong> I think I have Alzheimer. Just an example... I should have left the DVD I rent, but I went to São Paulo to work (just 240km) today and I forgot to leave the DVD... now it's in my car and I need to send through postal to someone to leave it there.<br />
<br />
<br />
And now it's my turn to choose the next 7 victims:<br />
- <a onclick="javascript: pageTracker._trackPageview('/extlink/blog.thepimp.net/');"  href="http://blog.thepimp.net/">Pierre-Alain Joye</a> - PHP Windows JEDI<br />
- Felipe Pena - PHP Core and an old friend<br />
- Hannes Magnusson - Another PHP Windows JEDI (ok, just CHM!)<br />
- <a onclick="javascript: pageTracker._trackPageview('/extlink/www.jwage.com');"  href="http://www.jwage.com">Jonathan Wage</a> - Co-worker at Doctrine<br />
- <a onclick="javascript: pageTracker._trackPageview('/extlink/erik.eae.net');"  href="http://erik.eae.net">Erik Arvidsson</a> - "The Oracle" of JavaScript<br />
- <a onclick="javascript: pageTracker._trackPageview('/extlink/www.forgetfoo.com');"  href="http://www.forgetfoo.com">Jerod Huseman</a> - Foo guy<br />
- <a onclick="javascript: pageTracker._trackPageview('/extlink/www.vedovelli.com.br');"  href="http://www.vedovelli.com.br">Fabio Vedovelli</a> - One of the most expert Flex guys in Brazil 
            </div>
        </content>

        
    </entry>
    <entry>
        <link href="http://blog.bisna.com/index.php?/archives/Dynamic-Events-in-Flex.html" rel="alternate" title="Dynamic Events in Flex" type="text/html" />
        <author>
            <name>Guilherme Blanco</name>
                    </author>
    
        <issued>2008-07-18T17:36:10Z</issued>
        <created>2008-07-18T17:36:10Z</created>
        <modified>2008-07-25T17:13:09Z</modified>
        <wfw:comment>http://blog.bisna.com/wfwcomment.php?cid=3</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.bisna.com/rss.php?version=atom0.3&amp;type=comments&amp;cid=3</wfw:commentRss>
    
        <id>http://blog.bisna.com/index.php?/archives/3.html</id>
        <title mode="escaped" type="text/html">Dynamic Events in Flex</title>
        <content type="application/xhtml+xml" xml:base="http://blog.bisna.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                In my vast 2 months experience with Flex, I found myself doing stupid things a lot of times.<br />
<br />
One of them is creating a new Event subclass every time I need a custom property. So, I created AuthorizeEvent, ServiceEvent, FormEvent, etc.<br />
I did this until I found DynamicEvent. DynamicEvent is a class derived from Event that accepts to create properties inside of it dynamically.<br />
<br />
So, instead of do: <br />
<div class="actionscript" style="text-align: left"><span style="color: #000000; font-weight: bold;">new</span> AuthorizeEvent<span style="color: #66cc66;">&#40;</span>AuthorizeEvent.<span style="color: #006600;">AUTHORIZED</span>, user<span style="color: #66cc66;">&#41;</span></div><br />
<br />
I started to do:<br />
<div class="actionscript" style="text-align: left"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">e</span>:DynamicEvent = <span style="color: #000000; font-weight: bold;">new</span> DynamicEvent<span style="color: #66cc66;">&#40;</span>AuthorizeEvent.<span style="color: #006600;">AUTHORIZED</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #0066CC;">e</span>.<span style="color: #006600;">user</span> = user;</div><br />
<br />
Sounds cool, but I still rely on AuthorizeEvent. Just for a naming convention?!<br />
I know this is bad, but we already have a convention about naming events. So... ChangeXXX or UserXXX.<br />
<br />
Since we have a convention, we could simply use the name as strings... so:<br />
<br />
<div class="actionscript" style="text-align: left"><span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">e</span>:DynamicEvent = <span style="color: #000000; font-weight: bold;">new</span> DynamicEvent<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"UserAuthorized"</span><span style="color: #66cc66;">&#41;</span>;<br /><span style="color: #0066CC;">e</span>.<span style="color: #006600;">user</span> = user;</div><br />
<br />
Now, we decided to create a custom class, basically to encapsulate things that we may need in the future. So, our final class became core.events.DynEvent.<br />
Here is the base implementation:<br />
<br />
<div class="actionscript" style="text-align: left"><br />package core.<span style="color: #006600;">events</span><br /><span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">DynamicEvent</span>;<br /><br />&#160; &#160; &#160; &#160; <span style="color: #0066CC;">public</span> <span style="color: #0066CC;">dynamic</span> <span style="color: #000000; font-weight: bold;">class</span> DynEvent <span style="color: #0066CC;">extends</span> DynamicEvent<br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> DynEvent<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>:<span style="color: #0066CC;">String</span>, bubbles:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span>, cancelable:<span style="color: #0066CC;">Boolean</span>=<span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#123;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #0066CC;">super</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">type</span>, bubbles, cancelable<span style="color: #66cc66;">&#41;</span>;<br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br />&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <br />&#160; &#160; &#160; &#160; <span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span><br />&#160;</div><br />
<br />
I hope this helps everyone that is looking for something like that. 
            </div>
        </content>

        
    </entry>
    <entry>
        <link href="http://blog.bisna.com/index.php?/archives/Castings-of-DataProvider-in-Flex.html" rel="alternate" title="Castings of DataProvider in Flex" type="text/html" />
        <author>
            <name>Guilherme Blanco</name>
                    </author>
    
        <issued>2008-06-21T18:13:59Z</issued>
        <created>2008-06-21T18:13:59Z</created>
        <modified>2008-06-26T01:01:27Z</modified>
        <wfw:comment>http://blog.bisna.com/wfwcomment.php?cid=2</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.bisna.com/rss.php?version=atom0.3&amp;type=comments&amp;cid=2</wfw:commentRss>
    
        <id>http://blog.bisna.com/index.php?/archives/2.html</id>
        <title mode="escaped" type="text/html">Castings of DataProvider in Flex</title>
        <content type="application/xhtml+xml" xml:base="http://blog.bisna.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                First real post here, and it's not a SO difficult thing, but it deserves a post. It'll also be used as an experiment to see how GeSHi plugin of Serendipity works.<br />
<br />
I work in project here where I'm building a prototype using Flex + Symfony + Doctrine. <br />
My scenario: I had to populate a combobox component from an XML provided by server. The XML format is this:<br />
<br />
<div class="xml" style="text-align: left"><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"utf-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;response<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;status<span style="font-weight: bold; color: black;">&gt;</span></span></span>OK<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/status<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;message</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;data<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />&#160; &#160; &#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;item</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"1"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Foo"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />&#160; &#160; &#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;item</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"2"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Bar"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />&#160; &#160; &#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;item</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"3"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Baz"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/data<span style="font-weight: bold; color: black;">&gt;</span></span></span><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/response<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />&#160;</div><br />
<br />
I have a wrapper to HTTPService which handles for non-status OK and Alerts the message. If it's ok, call result as it should. So, my interested data is everything under "data" node.<br />
<br />
I wrote then a simple combo component to handle my wish:<br />
<br />
<div class="xml" style="text-align: left"><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"utf-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:ComboBox xmlns:<span style="color: #000066;">mx</span>=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #000066;">labelField</span>=<span style="color: #ff0000;">"@label"</span> <span style="color: #000066;">dataProvider</span>=<span style="color: #ff0000;">"{itemService.lastResult.data.item}"</span> <span style="color: #000066;">creationComplete</span>=<span style="color: #ff0000;">"itemService.send()"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />&#160; &#160; &#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;mx</span>:HTTPService <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"itemService"</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"POST"</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">"module/action"</span> <span style="color: #000066;">useProxy</span>=<span style="color: #ff0000;">"false"</span> <span style="color: #000066;">resultFormat</span>=<span style="color: #ff0000;">"e4x"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/mx</span>:ComboBox<span style="font-weight: bold; color: black;">&gt;</span></span><br />&#160;</div><br />
<br />
With all the Flex magic, it worked well, but 2 warnings in Builder console started to drive me crazy. Those were the warnings:<br />
<br />
warning: unable to bind to property 'data' on class 'XML' (class is not an IEventDispatcher) <br />
warning: unable to bind to property 'item' on class 'XMLList' (class is not an IEventDispatcher)<br />
<br />
I tried to place under a result event, with warning still flashing me. After a lot of research, I found that was because of lack of castings. Then I started a furious write-and-try to get rid of it.<br />
After a hundred tries, I found my solution. Here it is:<br />
<br />
<div class="actionscript" style="text-align: left"><br />dataProvider=<span style="color: #ff0000;">"{XMLList(XMLList(XML(itemService.lastResult).data)[0].item)}"</span><br />&#160;</div><br />
<br />
I know, it's ugly.... but it works.<br />
On IRC (irc.freenode.net channel #flex) one user told me I was probably driving compiler crazy. I don't think so, because the performance increased quite a bit.<br />
<br />
Let me explain what I found as how compiler understands it.<br />
<br />
itemService.lastResult always return the XML response. It's not a XMLListCollection, so don't even try to change that.<br />
This cast was necessary because you cannot cast to an XMLList without previously casting an XML. I tried to cast "data" as XML, but it told me I could not cast an unknown variable that could not be an XML. So I casted the lastResult as the XML, then I tried to cast "data" as XML too, and compiler gave me another warning, telling I was trying to cast an XMLList into an XML. That was easy... I casted to an XMLList then and retrieved the 0 index. The last thing remaining was the XMLList casting of items... I tried to follow Adobe's recommendation (always use XMLListCollection as dataProvider), but didn't work either.<br />
<br />
So, if you experience the same thing, feel free to do the same thing I've done. Most people usually return the response directly, like:<br />
<br />
<div class="xml" style="text-align: left"><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">"utf-8"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;response<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;item</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"1"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Foo"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;item</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"2"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Bar"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />&#160; &#160; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;item</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"3"</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">"Baz"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br /><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/response<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />&#160;</div><br />
<br />
For you guys, you'll never need my "hack". If you use this approach, itemService.lastResult is already an XML, and the following children will be always treated as XMLList. <br />
BBBUUUTTT.... if you want to help compiler, do:<br />
<br />
<div class="actionscript" style="text-align: left"><br />dataProvider=<span style="color: #ff0000;">"{XMLList(XML(itemService.lastResult).item)}"</span><br />&#160;</div><br />
<br />
<br />
That's all folks! 
            </div>
        </content>

        
    </entry>
    <entry>
        <link href="http://blog.bisna.com/index.php?/archives/Welcome!.html" rel="alternate" title="Welcome!" type="text/html" />
        <author>
            <name>Guilherme Blanco</name>
                    </author>
    
        <issued>2008-06-19T03:36:23Z</issued>
        <created>2008-06-19T03:36:23Z</created>
        <modified>2008-06-19T03:36:23Z</modified>
        <wfw:comment>http://blog.bisna.com/wfwcomment.php?cid=1</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://blog.bisna.com/rss.php?version=atom0.3&amp;type=comments&amp;cid=1</wfw:commentRss>
    
        <id>http://blog.bisna.com/index.php?/archives/1.html</id>
        <title mode="escaped" type="text/html">Welcome!</title>
        <content type="application/xhtml+xml" xml:base="http://blog.bisna.com/">
            <div xmlns="http://www.w3.org/1999/xhtml">
                After exactly two years I decided to revamp my web blog.<br />
<br />
For those that didn't even remember my name, Guilherme Blanco. I live in Brazil and I work for my own company called Bisna.<br />
<br />
I spent these years learning new languages and specializing myself into my known languages too.<br />
As a result, today I am:<br />
<br />
- Core developer of <a onclick="javascript: pageTracker._trackPageview('/extlink/www.phpdoctrine.org');"  href="http://www.phpdoctrine.org" title="Doctrine ORM for PHP">Doctrine project</a><br />
- Commiter of <a onclick="javascript: pageTracker._trackPageview('/extlink/www.symfony-project.org');"  href="http://www.symfony-project.org" title="Symfony PHP Framework">Symfony project</a><br />
- Beta tester of <a onclick="javascript: pageTracker._trackPageview('/extlink/www.bindows.net');"  href="http://www.bindows.net" title="Bindows AJAX Framework">Bindows</a>, aswell as bug fixer too<br />
- User of <a onclick="javascript: pageTracker._trackPageview('/extlink/www.adobe.com/products/flex');"  href="http://www.adobe.com/products/flex" title="Adobe Flex">Adobe Flex</a><br />
<br />
I learned a bit of Linux too, and currently I use <a onclick="javascript: pageTracker._trackPageview('/extlink/www.kubuntu.org');"  href="http://www.kubuntu.org" title="Kubuntu">Kubuntu 8.04</a> as my default OS.<br />
<br />
What do I expect for my future? Besides conquer the world, nothing else.<br />
And what do I expect from you? Well, actually I wish to enjoy my website, come back and recommend it!<br />
<br />
What do I offer? The experience I've had with all these technology I have worked.<br />
<br />
I hope you enjoy it! Ah... and welcome! =) 
            </div>
        </content>

        
    </entry>
</feed>