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

<channel>
	<title>FiveDigital</title>
	<atom:link href="http://fivedigital.de/feed/" rel="self" type="application/rss+xml" />
	<link>http://fivedigital.de</link>
	<description>Ein Blog über Adobe Flex, Air &#38; PHP</description>
	<lastBuildDate>Wed, 23 Jun 2010 07:43:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Magento 1.5 Roadmap</title>
		<link>http://fivedigital.de/2010/06/23/magento-1-5-roadmap/</link>
		<comments>http://fivedigital.de/2010/06/23/magento-1-5-roadmap/#comments</comments>
		<pubDate>Wed, 23 Jun 2010 07:43:31 +0000</pubDate>
		<dc:creator>Thomas Müller</dc:creator>
				<category><![CDATA[Ohne Kategorie]]></category>

		<guid isPermaLink="false">http://fivedigital.de/?p=74</guid>
		<description><![CDATA[Mit dem Release von Magento 1.4.1.0 wurde auch die Roadmap für Magento 1.5.0.0 veröffentlicht. Sie ist wie immer interessant zu lesen: http://www.magentocommerce.com/roadmap/release/1.5.0.0]]></description>
			<content:encoded><![CDATA[<p>Mit dem Release von Magento 1.4.1.0 wurde auch die Roadmap für Magento 1.5.0.0 veröffentlicht. Sie ist wie immer interessant zu lesen: <a href="http://www.magentocommerce.com/roadmap/release/1.5.0.0">http://www.magentocommerce.com/roadmap/release/1.5.0.0</a></p>
]]></content:encoded>
			<wfw:commentRss>http://fivedigital.de/2010/06/23/magento-1-5-roadmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magische Setter/Getter in Magento Templates und Layouts</title>
		<link>http://fivedigital.de/2010/06/03/magische-settergetter-in-magento-templates-und-layouts/</link>
		<comments>http://fivedigital.de/2010/06/03/magische-settergetter-in-magento-templates-und-layouts/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 07:32:36 +0000</pubDate>
		<dc:creator>Thomas Müller</dc:creator>
				<category><![CDATA[Magento]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://fivedigital.de/?p=65</guid>
		<description><![CDATA[Die magischen Getter und Setter, die z.B. von Models bekannt sind, können auch in den Layouts verwendet werden. Hier ein Beispiel für die Verwendung der Setter und Getter: $product-&#62;setWurst&#40;&#34;Salami&#34;&#41;; echo $product-&#62;getWurst&#40;&#41;; Nach ein wenig Überlegung macht das Ganze auch in den Layouts Sinn.Beispiel: Im Header soll ein anderes Hintergrundbild angezeigt werden, wenn der Benutzer im [...]]]></description>
			<content:encoded><![CDATA[<p>Die magischen Getter und Setter, die z.B. von Models bekannt sind, können auch in den Layouts verwendet werden. Hier ein Beispiel für die Verwendung der Setter und Getter:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWurst</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Salami&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$product</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getWurst</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Nach ein wenig Überlegung macht das Ganze auch in den Layouts Sinn.<span id="more-65"></span><strong>Beispiel:</strong> Im Header soll ein anderes Hintergrundbild angezeigt werden, wenn der Benutzer im Warenkorb ist. Gelöst wird sowas natürlich mittels einer CSS-Klasse für den Header. Der alte Weg würde so aussehen, dass man im Template header.phtml in etwa sowas einbaut:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;header&quot; class=&quot;&lt;?php echo ($warenkorbAnzeige) ? &quot;header-cart&quot; : &quot;header-default&quot;; ?&gt;&quot;&gt;</pre></div></div>

<p>Das ist natürlich nicht so schön, wenn es mehr als 2 Klassen gibt. Magento löst das jedoch schöner. Im Template schreibt man einfach:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;header&quot; class=&quot;&lt;?php echo $this-&gt;getHeaderClass(); ?&gt;&quot;&gt;</pre></div></div>

<p>Den Wert für HeaderClass kann man direkt in den Layouts setzen.</p>
<p><strong>Beispiel in page.xml für alle Seiten:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;top.container&quot;</span> <span style="color: #000066;">as</span>=<span style="color: #ff0000;">&quot;topContainer&quot;</span> <span style="color: #000066;">translate</span>=<span style="color: #ff0000;">&quot;label&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setHeaderClass&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>header-default<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>Beispiel in cart.xml für die CSS-Klasse im Warenkorb</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;checkout_cart_index<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;topContainer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;setHeaderClass&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>header-cart<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/checkout_cart_index<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>Ein Blick unter die Haube:</strong></p>
<p>Eigentlich passiert nichts weiter, als dass die im XML angegebene Method für die Instanz des Blocks ausgeführt wird. Da jeder Block auf Varien_Object zurückzuführen ist, funktionieren die magischen Setter und Getter auch. Des Weiteren können auch alle public function einer Block-Klasse aus dem XML aufgerufen werden, auch wenn sie mehr als einen Parameter erfordern. </p>
<p><strong>Beispiel:</strong></p>
<p>1. Block-Klasse</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">Class</span> FiveDigital_TestModul_Block_Foo <span style="color: #000000; font-weight: bold;">extends</span> Mage_Core_Template <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$foo</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000088;">$bar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> changeFoo<span style="color: #009900;">&#40;</span><span style="color: #000088;">$baz</span><span style="color: #339933;">,</span> <span style="color: #000088;">$someVar</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">foo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$baz</span><span style="color: #339933;">;</span>	
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bar</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$someVar</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> showFoo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">foo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bar</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>2. Layout-XML</strong></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;testmodul_index_index<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;block</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;testmodul/foo&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;fooBlock&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">&quot;changeFoo&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;foo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Lorem<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/foo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;somevar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Ipsum<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/somevar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/action<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/block<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/reference<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/testmodul_index_index<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><strong>3. Template</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;h1&gt;Foo:&lt;/h1&gt;
&nbsp;
&lt;p&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">showFoo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://fivedigital.de/2010/06/03/magische-settergetter-in-magento-templates-und-layouts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex DataGrid zum Bearbeiten und Hinzufügen von Datensätzen</title>
		<link>http://fivedigital.de/2010/01/28/flex-datagrid-zum-bearbeiten-und-hinzufuegen-von-datensaetzen/</link>
		<comments>http://fivedigital.de/2010/01/28/flex-datagrid-zum-bearbeiten-und-hinzufuegen-von-datensaetzen/#comments</comments>
		<pubDate>Thu, 28 Jan 2010 13:13:10 +0000</pubDate>
		<dc:creator>Thomas Müller</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://fivedigital.de/?p=59</guid>
		<description><![CDATA[Das Flex DataGrid bietet von Haus aus die Möglichkeit, Datensätze in der Tabelle zu bearbeiten. Ich habe ein Beispiel erstellt, das ein DataGrid bereit hält, welches immer einen neuen, leeren Datensatz anzeigt. Der Trick dabei ist, dem Dataprovider einen leeren Datensatz hinzuzufügen. Update: Mein liebenswerter Kollege Alex hat mich auf einen kleinen Fehler im Beispiel [...]]]></description>
			<content:encoded><![CDATA[<p>Das Flex DataGrid bietet von Haus aus die Möglichkeit, Datensätze in der Tabelle zu bearbeiten. Ich habe ein <a href="http://fivedigital.de/flex/editgrid/">Beispiel</a> erstellt, das ein DataGrid bereit hält, welches immer einen neuen, leeren Datensatz anzeigt. Der Trick dabei ist, dem Dataprovider einen leeren Datensatz hinzuzufügen.</p>
<p><strong>Update:</strong> Mein liebenswerter Kollege Alex hat mich auf einen kleinen Fehler im Beispiel hingewiesen, den ich nun korrigiert habe. Vielen Dank!</p>
]]></content:encoded>
			<wfw:commentRss>http://fivedigital.de/2010/01/28/flex-datagrid-zum-bearbeiten-und-hinzufuegen-von-datensaetzen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Die Flex Tree Komponente für Kategorien mit Drag &amp; Drop &#8211; Teil 1</title>
		<link>http://fivedigital.de/2010/01/19/drag-drop-mit-der-flex-tree-komponente/</link>
		<comments>http://fivedigital.de/2010/01/19/drag-drop-mit-der-flex-tree-komponente/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 08:55:17 +0000</pubDate>
		<dc:creator>Thomas Müller</dc:creator>
				<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://fivedigital.de/?p=46</guid>
		<description><![CDATA[Die Tree Komponente ist sehr hilfreich um hierarchische Daten darzustellen. Angedacht ist die Komponente, wie der Name vermuten lässt, als Baum mit Knoten und Blättern. So wird er auch in den Beispielen auf der Adobe Seite dargestellt. Entwickelt man eine Flex Anwendung, kommt man oft an einen Punkt, an dem Daten kategorisiert werden müssen. Was [...]]]></description>
			<content:encoded><![CDATA[<p>Die <a href="http://livedocs.adobe.com/flex/3/langref/mx/controls/Tree.html">Tree</a> Komponente ist sehr hilfreich um hierarchische Daten darzustellen. Angedacht ist die Komponente, wie der Name vermuten lässt, als Baum mit Knoten und Blättern. So wird er auch in den Beispielen auf der Adobe Seite dargestellt. Entwickelt man eine Flex Anwendung, kommt man oft an einen Punkt, an dem Daten kategorisiert werden müssen. Was eignet sich dazu besser als die Tree Komponente? Wie sich heraus stellt, ist sie jedoch nicht 100%ig für einen derartigen Einsatz geschaffen.<br />
<span id="more-46"></span><br />
Die erste, kosmetische Änderung die an einem Tree zur Darstellung von Verschachtelten Kategorien vorgenommen werden muss, ist die Darstellung der Blätter. Alle Elemente in dem Tree sollen Kategorien darstellen.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
 <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;images/icons/folder.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
 <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> MyFolderIcon<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span>;
&nbsp;
<span style="color: #000000;">&#91;</span>Bindable<span style="color: #000000;">&#93;</span>
 <span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;images/icons/folder-open.png&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
 <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> MyFolderOpenIcon<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Class</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Tree id=<span style="color: #990000;">&quot;tree&quot;</span> defaultLeafIcon=<span style="color: #990000;">&quot;{MyFolderIcon}&quot;</span>
 folderOpenIcon=<span style="color: #990000;">&quot;{MyFolderOpenIcon}&quot;</span>
 folderClosedIcon=<span style="color: #990000;">&quot;{MyFolderIcon}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Durch den Einsatz von eigenen Grafiken für Blätter und Knoten wurde ein einheitliches Aussehen geschaffen. In der von mir entwickelten Anwendung löst ein Klick auf ein Element des Trees ein Event aus, das dazu führt das ein Datagrid alle Objekte die zu der ausgewählten Kategorie gehören, anzeigt.</p>
<p>Der Tree bietet die Möglichkeit, dass Elemente mittels Drag &amp; Drop neu zu arrangieren. Dazu müssen lediglich einige Eigenschaften des Trees gesetzt werden.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>mx<span style="color: #000000; font-weight: bold;">:</span>Tree id=<span style="color: #990000;">&quot;tree&quot;</span> defaultLeafIcon=<span style="color: #990000;">&quot;{MyFolderIcon}&quot;</span>
 folderOpenIcon=<span style="color: #990000;">&quot;{MyFolderOpenIcon}&quot;</span>
 folderClosedIcon=<span style="color: #990000;">&quot;{MyFolderIcon}&quot;</span>
dragMoveEnabled=<span style="color: #990000;">&quot;true&quot;</span> dragEnabled=<span style="color: #990000;">&quot;true&quot;</span> dropEnabled=<span style="color: #990000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Und schon kann der Tree beliebig sortiert werden. Ein Beispiel dazu liefert <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=dragdrop_4.html">Adobe</a>. Doch kann wirklich beliebig sortiert werden? Nein! Warum? Es ist nicht möglich ein Element &#8220;in&#8221; ein anderes herein zu schieben. Was bedeutet das für die Darstellung von Kategorien? Es ist nicht möglich eine Kategorie in eine andere Kategorie, die <strong>keine</strong> Kinder hat, zu verschieben. Dies fällt nicht nur mir auf, auch bei <a href="http://blog.flexexamples.com/2007/11/29/dragging-and-dropping-items-in-a-flex-tree-control/">FlexExamples</a> wurde dieses Verhalten bemängelt:</p>
<blockquote><p>Rob McKeown November 30, 2007 at 2:12 pm</p>
<p>One thing to note about <strong>the tree is that it is really just a list in which items are displayed</strong>. What that means is, <strong>you can’t really drop somthing “into” folder</strong> unless the folder is open. Even in that case the user experience isn’t quite right. So try moving everything out of one of the folders and then collapse that empty folder. If you drop something “on” the folder, it actually winds up between the target folder and the one below or above. This is indicated by the black line showing up as you move the mouse over the folders. If you “open” the folder (the only way to tell it is open is by the arrow) and then try it, you end up with an additional drop zone that is basically the bottom half of the opened, empty folder. This is also indicated by the black lines position.</p>
<p>It would be better if the middle section of any item could always be the drop zone for “add to this folder” and the top and bottom edges could be for dropping above or below respectively.</p></blockquote>
<p>Besser kann ich das Verhalten des Trees nicht beschreiben. Leider habe ich dieses Verhalten erst festgestellt, als ich das Verschieben der Kategorien bereits in Flex und im Webservice implementiert habe. Alles funktioniert, jedoch war es nicht möglich, eine Kategorie in eine andere ohne Kinder zu verschieben. So konnte es nicht bleiben, eine Workaround wurde benötigt.</p>
<p>Nach einigem Probieren kam ich zu dem Entschluss, dass es am einfachsten zu realisieren ist, indem einer Kategorie ein Kind hinzugefügt wird, wenn sie keiner Kinder besitzt. Der Ablauf sieht wie folgt aus:</p>
<ul>
<li>Der Benutzer zieht eine Kategorie</li>
<li>Jedes mal, wenn der Benutzer die gezogene Kategorie über eine andere Kategorie zieht, wird ein Timer gestartet um zu messen, wie lange er über der Kategorie verweilt</li>
<li>Ist eine bestimmte Zeit (in meiner Anwendung 2 Sekunden) erreicht und hat die Kategorie über der der Benutzer verweilt, wird der Kategorie ein Kind mit dem Titel &#8220;Als Unterkategorie einfügen&#8221; hinzugefügt</li>
<li>Bewegt der Benutzer die gezogene Kategorie weiter, wird das neu hinzugefügte Kind wieder entfernt</li>
<li>Nach erfolgtem Verschieben wird das Kind ebenfalls entfernt</li>
</ul>
<p>Durch diese Technik ist es möglich geworden, dass Kategorien auch in andere, die keine Kinder haben, zu verschieben. In meinem nächsten Posting werde ich mich der Implementierung widmen. Dabei werden neben der, in diesem Posting beschriebenen, Problematik auch weitere Probleme behandelt. Wie verhindere ich, dass eine Kategorie in eine eigene Unterkategorie &#8211; und damit in sich selber, verschoben wird? Wie lese ich aus, wohin die Kategorie verschoben wurde, wenn die Datenquelle des Trees kein XML ist? Wie setze ich das Verschieben auf Seiten des Webservices um?</p>
]]></content:encoded>
			<wfw:commentRss>http://fivedigital.de/2010/01/19/drag-drop-mit-der-flex-tree-komponente/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Autoloading mittels PHP Namespaces</title>
		<link>http://fivedigital.de/2009/11/20/autoloading-mittels-namespaces/</link>
		<comments>http://fivedigital.de/2009/11/20/autoloading-mittels-namespaces/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 08:22:59 +0000</pubDate>
		<dc:creator>Thomas Müller</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp1093087.vwp0880.webpack.hosteurope.de/?p=35</guid>
		<description><![CDATA[Seit Version 5.3 unterstützt PHP (endlich) Namespaces. Autoloading ist auch nichts neues mehr &#8211; Wird eine Klasse zur Laufzeit nicht gefunden, wird versucht die Klasse mittels der __autoload() Funktion zu laden, bevor ein PHP Fehler erscheint. Setzt man Klassen ein, die Namespaces nutzen, wird der Namespace der Funktion übergeben. Benutzt man für sein Script eine [...]]]></description>
			<content:encoded><![CDATA[<p>Seit Version 5.3 unterstützt PHP (endlich) <a href="http://de2.php.net/manual/en/language.namespaces.rationale.php" target="_blank">Namespaces</a>. <a href="http://php.net/manual/en/language.oop5.autoload.php" target="_blank">Autoloading</a> ist auch nichts neues mehr &#8211; Wird eine Klasse zur Laufzeit nicht gefunden, wird versucht die Klasse mittels der <code>__autoload()</code> Funktion zu laden, bevor ein PHP Fehler erscheint.</p>
<p>Setzt man Klassen ein, die Namespaces nutzen, wird der Namespace der Funktion übergeben. Benutzt man für sein Script eine Ordnerstruktur, die den Namespaces entspricht, ist es einfach aus dem Namespace heraus auf den Ordner in dem die Klasse liegt zu schließen.<br />
<span id="more-35"></span><br />
Hier ein Beispiel:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> __autoload<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Die Backslashes des Namespaces zu Slashes umwandeln</span>
	<span style="color: #000088;">$fileName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileName</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">require_once</span> <span style="color: #000088;">$fileName</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Natürlich setzt dieses Beispiel voraus, dass der Dateiname dem Klassennamen entspricht. Diese Konventionen sind in anderen Sprachen üblich. Noch einfacher geht es jedoch mittels der neuen <a href="http://de3.php.net/manual/en/ref.spl.php" target="_blank">SPL Funktionen</a>. Dadurch reicht der folgende Aufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">spl_autoload_extensions</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">spl_autoload_register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Die Funktionalität ist dieselbe, wie in der zuvor vorgestellten <code>__autoload()</code> Funktion, jedoch schneller, wie man einem <a href="http://de3.php.net/manual/en/function.spl-autoload-register.php#92514" target="_blank">Kommentar im PHP Manual</a> entnehmen kann.</p>
<p><strong>Ein Beispiel</strong></p>
<p>Datei: \com\my\app\foo\Foo.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">namespace</span> com\my\app\foo<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Datei: \com\my\app\bar\Bar.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">namespace</span> com\my\app\bar<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Bar <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Datei /index.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">use \com\my\app\bar <span style="color: #b1b100;">as</span> Bar<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">spl_autoload_extensions</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">spl_autoload_register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$foo</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \com\my\app\foo\Foo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Bar\Bar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Wie dieses kleine Beispiel zeigt, funktioniert das Autoloading auch, wenn Namespace-Aliase eingesetzt werden.</p>
]]></content:encoded>
			<wfw:commentRss>http://fivedigital.de/2009/11/20/autoloading-mittels-namespaces/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Authentifizierung mit dem Zend AMF Server</title>
		<link>http://fivedigital.de/2009/11/19/authentifizierung_mit_dem_zend_amf_server/</link>
		<comments>http://fivedigital.de/2009/11/19/authentifizierung_mit_dem_zend_amf_server/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 16:00:46 +0000</pubDate>
		<dc:creator>Thomas Müller</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp1093087.vwp0880.webpack.hosteurope.de/?p=1</guid>
		<description><![CDATA[Um einen Webservice für eine Flex Anwendung abzusichern, gibt es viele Möglichkeiten. Handelt es sich um eine öffentlich zugängliche Anwendung, ist es natürlich leicht, denn jeder Benutzer darf auf den Webservice zugreifen. Häufig jedoch ist dies nicht gewünscht und der Webservice muss abgesichert werden. Dazu gibt es viele Möglichkeiten, die alle ihre Vor- und Nachteile [...]]]></description>
			<content:encoded><![CDATA[<p>Um einen Webservice für eine Flex Anwendung abzusichern, gibt es viele Möglichkeiten. Handelt es sich um eine öffentlich zugängliche Anwendung, ist es natürlich leicht, denn jeder Benutzer darf auf den Webservice zugreifen.</p>
<p>Häufig jedoch ist dies nicht gewünscht und der Webservice muss abgesichert werden. Dazu gibt es viele Möglichkeiten, die alle ihre Vor- und Nachteile mit sich bringen. Für eine Anwendung an der ich zurzeit arbeite, greife ich auf eine bestehende Benutzerdatenbank zu. Wie es üblich ist, erfolgt der Login über eine E-Mail Adresse und ein als MD5 Hash in der Datenbank gespeichertes Passwort.</p>
<p>In diesem Artikel möchte ich auf die Authentifizierung mittels des Zend Frameworks eingehen.<br />
<span id="more-1"></span><br />
Die Anwendung setzt auf Remote Objects und nutzt den <a href="http://framework.zend.com/manual/de/zend.amf.html" target="_blank">Zend AMF Server</a> als Gateway. Nachdem ein erster Entwurf der Anwendung angefertigt und der Webservice konzipiert und umgesetzt wurde, fehlte noch der Login auf meiner Liste. In vielen Tutorials wird mit einem Value Object für den Login gearbeitet. Das Login Fenster sendet Username und Passwort an den Webservice und wenn beide Angaben korrekt waren, wird die UserID (oder das User Objekt usw.) in der Session gespeichert.</p>
<p>Dieser gängige Ansatz hat jedoch den Nachteil, das ein neuer Login erforderlich ist, sobald die Session abgelaufen ist. Ein weiterer Nachteil ist es, dass für diesen Ansatz Cookies benötigt werden. Doch wieso nicht das Authtifizierungsmodell des AMF Protokolls benutzen? Der Zend AMF Server bietet seit geraumer Zeit Unterstützung dafür. In diesem Beitrag möchte ich auf die Implementierung eines solchen Authtifizierungsmodells eingehen.</p>
<p>Dabei kommen der aktuelle <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4" target="_blank">Flash Builder Beta 2</a> sowie das <a href="http://framework.zend.com/" target="_blank">Zend Framework 1.9.5</a> zu Einsatz.</p>
<p><strong>Der PHP Teil</strong></p>
<p>In <a href="http://framework.zend.com/manual/de/zend.amf.server.html#zend.amf.server.auth" target="_blank">Kapitel 3.2.7.</a> &#8220;Authentication&#8221; der Zend Framework Dokumentation wird in groben Zügen beschrieben, wie die Authentifizierung funktioniert:</p>
<blockquote><p>Um Authentifizierung zu definieren, muß der Benutzer einen Authentifizierungs-Adapter             anbieten der die abstrakte Klasse <code>Zend_Amf_Auth_Abstract</code> erweitert. Der Adapter sollte die <code>authenticate()</code> Methode             implementieren so wie jeder normale             Authentifizierungs-Adapter.</p></blockquote>
<p>An dieser Stelle wird leider nicht weiter auf die Implementierung des Authentifizierungs-Adapters eingegangen. Es folgt noch ein kurzer Hinweis, wie die eigenen Authentifizierungs Klasse eingebunden wird:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAuth</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> My_Amf_Auth<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ein guter Hinweis ist die Klasse <code>Zend_Amf_Auth_Abstract</code>, die sich als reichlich simpel entpuppt:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">abstract <span style="color: #000000; font-weight: bold;">class</span> Zend_Amf_Auth_Abstract implements Zend_Auth_Adapter_Interface
<span style="color: #009900;">&#123;</span>
    protected <span style="color: #000088;">$_username</span><span style="color: #339933;">;</span>
    protected <span style="color: #000088;">$_password</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setCredentials<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_username <span style="color: #339933;">=</span> <span style="color: #000088;">$username</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_password <span style="color: #339933;">=</span> <span style="color: #000088;">$password</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Des Weiteren heißt es &#8220;Der Adapter sollte die <code>authenticate()</code> Methode implementieren&#8221; &#8211; richtig ist jedoch: Der Adapter <strong>muss</strong> die <code>authenticate()</code> Methode implementieren.  Es wäre schön, wenn die Klasse eine abstrakte Funktion <code>authenticate()</code> beinhalten würde.</p>
<p>Denn wenn der Zend AMF Gateway aus der Flex Anwendung die Credentials (Username und Passwort) gesendet bekommt <strong>und</strong> eine Auth Klasse gesetzt ist, wird automatisch die <code>setCredentials()</code> und anschließend die (von der eigenen Klasse implementierte) <code>authenticate()</code> Methode aufgerufen.</p>
<p>In <a href="http://framework.zend.com/manual/de/zend.auth.html#zend.auth.introduction.adapters" target="_blank">Kapitel 5.1.1.</a> der Zend Framework Dokumentation finden wir ein Beispiel, für eine <code>authenticate()</code> Methode:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #009933; font-style: italic;">/**
     * Führt einen Authentifizierungs-Versuch durch
     *
     * @throws Zend_Auth_Adapter_Exception Wenn die Authentifizierung nicht
     *                                     durchgeführt wurde
     * @return Zend_Auth_Result
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> authenticate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// ...</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Wieder ein Stück weiter ist jetzt bekannt, dass diese Methode ein <code>Zend_Auth_Result</code> Objekt zurück liefern muss. Ein <code>Zend_Auth_Result</code> Objekt erfordert (mindestens) 2 Parameter: Einen Code und eine Rolle. Auf die Rollen des Zend Frameworks möchte ich in diesem Beitrag nicht näher eingehen, deswegen kann an dieser Stelle ein beliebiger String oder ein beliebiges Objekt übergeben werden. Ein Beispiel für die zu verwendenden Codes befindet sich in <a href="http://framework.zend.com/manual/de/zend.auth.html#zend.auth.introduction.results" target="_blank">Kapitel 5.1.2</a>.</p>
<p>Die Zuvor erwähnt Klasse <code>My_Amf_Auth</code> könnte demnach wie folgt aussehen:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> My_Amf_Auth <span style="color: #000000; font-weight: bold;">extends</span> Zend_Amf_Auth_Abstract <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> authenticate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_object</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT * FROM users WHERE username = &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_username<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Username ungültig</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_object</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Auth_Result<span style="color: #009900;">&#40;</span>Zend_Auth_Result<span style="color: #339933;">::</span><span style="color: #004000;">FAILURE_IDENTITY_NOT_FOUND</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;guest&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Passwort ungültig</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">password</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_password<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Auth_Result<span style="color: #009900;">&#40;</span>Zend_Auth_Result<span style="color: #339933;">::</span><span style="color: #004000;">FAILURE_CREDENTIAL_INVALID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;guest&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// User ist kein Admin</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isAdmin</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Auth_Result<span style="color: #009900;">&#40;</span>Zend_Auth_Result<span style="color: #339933;">::</span><span style="color: #004000;">FAILURE_IDENTITY_AMBIGUOUS</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;guest&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// User ist ein Admin</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Auth_Result<span style="color: #009900;">&#40;</span>Zend_Auth_Result<span style="color: #339933;">::</span><span style="color: #004000;">SUCCESS</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;admin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Der Flex Teil</strong></p>
<p>Nachdem die Daten nun auf dem Server verarbeitet werden, stellt sich natürlich noch die Frage, wie Username und Passwort per Flex an die Remote Klassen gesendet werden können. Wenn man seine Webservice Abfragen mit dem eingebauten Daten/Dienste Manager erstellt hat, findet man in dem Paket des Services zwei Dateien: _Super_MyService.as und MyService.as. Die Super Klasse darf, wie man dem Quellcode auch entnehmen kann, nicht bearbeitet werden. Diese Datei wird automatich beim Aktualisieren der Services überschrieben. Stattdesses erweitert man die bisher noch leere MyService.as:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> services.myservice
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.core.FlexGlobals;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyService extends _Super_MyService
	<span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>In dieser Klasse mann man einen Konstruktor einfügen, der die Credentials setzt:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> services.categoryservice
<span style="color: #000000;">&#123;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> mx.core.FlexGlobals;
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> MyService extends _Super_MyService
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> MyService <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">this</span>._serviceControl.setCredentials<span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;Username&quot;</span>, <span style="color: #990000;">&quot;Password&quot;</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><code>this._serviceControl</code> ist das in der Super Klasse instanzierte <a href="http://help.adobe.com/en_US/Flex/4.0/langref/mx/rpc/remoting/mxml/RemoteObject.html" target="_blank">RemoteObject</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;">_serviceControl = <span style="color: #0033ff; font-weight: bold;">new</span> RemoteObject<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</pre></div></div>

<p>Erzeugt man nun in einer Komponente eine neue MyService Instanz, werden Benutzername und Passwort automatisch gesetzt:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:CallResponder</span> id=<span style="color: #ff0000;">&quot;myResult&quot;</span> result=<span style="color: #ff0000;">&quot;myResult_resultHandler(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;myservice:MyService</span> id=<span style="color: #ff0000;">&quot;myData&quot;</span> showBusyCursor=<span style="color: #ff0000;">&quot;true&quot;</span> fault=<span style="color: #ff0000;">&quot;myService_faultHandler(event)&quot;</span><span style="color: #7400FF;">/&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>Schöner ist es natürlich, Benutzername und Passwort nicht im Klartext in die Klassen einzutragen, sondern sie als Variablen über ein Loginfenster an die Klassen zu binden. Etwaige Fehler bei der Authentifizierung können mittels eines <code>myService_faultHandler(event:FaultEvent)</code> Listeners des <code>MyService</code> Objektes abgefangen werden.</p>
<p>Jetzt werden die Credentials im Header jeder AMF Anfrage mitgesendet. Ich empfehle, dass Passwort auf jeden Fall verschlüsselt zu senden, in meinem Fall als MD5 mittels des <a href="http://code.google.com/p/as3corelib/" target="_blank">as3corelibs</a> und den Webservice über ein HTTPS Protokoll anzusprechen. Mehr dazu gibt es in einem späteren Beitrag.</p>
<p>Sollte Interesse bestehen, kann ich auf weitere Aspekte dieses Authentifizierungsmethode eingeben und beantworte Fragen in den Kommentaren gerne so gut ich kann.</p>
]]></content:encoded>
			<wfw:commentRss>http://fivedigital.de/2009/11/19/authentifizierung_mit_dem_zend_amf_server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
