<?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>Der Blog von Benny Neugebauer</title>
	<atom:link href="http://www.bennyn.de/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bennyn.de</link>
	<description>Alles über die Informatik &#38; Co.</description>
	<lastBuildDate>Mon, 06 May 2013 16:05:52 +0000</lastBuildDate>
	<language>de-DE</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Chrome Remote Debugging mit Google Nexus 7</title>
		<link>http://www.bennyn.de/programmierung/html/chrome-remote-debugging-mit-google-nexus-7.html</link>
		<comments>http://www.bennyn.de/programmierung/html/chrome-remote-debugging-mit-google-nexus-7.html#comments</comments>
		<pubDate>Thu, 25 Apr 2013 09:35:47 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[Debug]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Chrome]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Nexus]]></category>
		<category><![CDATA[remote]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=5560</guid>
		<description><![CDATA[1. Google USB-Treiber installieren 2. Einstellungen im Goole Nexus 7 vornehmen Chrome for Mobile &#8211; Settings > Developer Tools > Enable USB Web debugging Device &#8211; Settings > Developer options > USB debugging 3. Google Nexus 7 über USB am PC anschließen 4. Windows-Kommandos in der Eingabeaufforderung cd C:\Android\adt-bundle-windows-x86_64-20130219\sdk\platform-tools adb forward tcp:9222 localabstract:chrome_devtools_remote 5. Aufruf [...]]]></description>
				<content:encoded><![CDATA[<p><strong>1. Google USB-Treiber installieren</strong><br />
<a href="http://www.bennyn.de/wp-content/uploads/google-usb-driver.png"><img src="http://www.bennyn.de/wp-content/uploads/google-usb-driver-300x188.png" alt="google-usb-driver" width="300" height="188" class="alignnone size-medium wp-image-5565" /></a></p>
<p><strong>2. Einstellungen im Goole Nexus 7 vornehmen</strong></p>
<ol>
<li>Chrome for Mobile &#8211; Settings > Developer Tools > Enable USB Web debugging</li>
<li>Device &#8211; Settings > Developer options > USB debugging</li>
</ol>
<p><strong>3. Google Nexus 7 über USB am PC anschließen</strong></p>
<p><strong>4. Windows-Kommandos in der Eingabeaufforderung</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> C:\Android\adt-bundle-windows-x86_64-<span style="color: #000000;">20130219</span>\sdk\platform-tools
adb forward tcp:<span style="color: #000000;">9222</span> localabstract:chrome_devtools_remote</pre></td></tr></table></div>

<p><strong>5. Aufruf im Chrome-Webbrowser</strong><br />
Danach &#8220;Inspectable pages&#8221; im Chrome Browser über die Adresse <code>http://localhost:9222/</code> aufrufen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/programmierung/html/chrome-remote-debugging-mit-google-nexus-7.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Logging in Java</title>
		<link>http://www.bennyn.de/programmierung/java/logging-in-java.html</link>
		<comments>http://www.bennyn.de/programmierung/java/logging-in-java.html#comments</comments>
		<pubDate>Fri, 12 Apr 2013 21:31:47 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Logger]]></category>
		<category><![CDATA[Logging]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=5543</guid>
		<description><![CDATA[Standard: import java.util.logging.Level; import java.util.logging.Logger; ... private final static Logger LOGGER = Logger.getLogger&#40;YourClass.class.getSimpleName&#40;&#41;&#41;; ... LOGGER.log&#40;Level.INFO, &#34;Something: {0}&#34;, &#34;Hello World&#34;&#41;; // Something: Hello World]]></description>
				<content:encoded><![CDATA[<p>Standard:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.logging.Level</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.logging.Logger</span><span style="color: #339933;">;</span>
...
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000000; font-weight: bold;">static</span> Logger LOGGER <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>YourClass.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getSimpleName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
<span style="color: #006633;">LOGGER</span>.<span style="color: #006633;">log</span><span style="color: #009900;">&#40;</span>Level.<span style="color: #006633;">INFO</span>, <span style="color: #0000ff;">&quot;Something: {0}&quot;</span>, <span style="color: #0000ff;">&quot;Hello World&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Something: Hello World</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/programmierung/java/logging-in-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON parsen mit Java</title>
		<link>http://www.bennyn.de/programmierung/java/json-parsen-mit-java.html</link>
		<comments>http://www.bennyn.de/programmierung/java/json-parsen-mit-java.html#comments</comments>
		<pubDate>Fri, 12 Apr 2013 21:29:18 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[parsen]]></category>
		<category><![CDATA[restfb]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=5540</guid>
		<description><![CDATA[Möglichkeit 1 Maven Dependency: &#60;dependency&#62; &#60;groupId&#62;net.sf.json-lib&#60;/groupId&#62; &#60;artifactId&#62;json-lib&#60;/artifactId&#62; &#60;version&#62;2.4&#60;/version&#62; &#60;classifier&#62;jdk15&#60;/classifier&#62; &#60;/dependency&#62; Code: import net.sf.json.JSONObject; import net.sf.json.JSONSerializer; ... String json = &#34;{\&#34;name\&#34;:\&#34;Benny\&#34;,\&#34;email\&#34;:\&#34;test\\u0040bennyn.de\&#34;}&#34;; JSONObject object = &#40;JSONObject&#41; JSONSerializer.toJSON&#40;json&#41;; String email = object.getString&#40;&#34;email&#34;&#41;; // test@bennyn.de Möglichkeit 2 Maven Dependency: &#60;dependency&#62; &#60;groupId&#62;com.restfb&#60;/groupId&#62; &#60;artifactId&#62;restfb&#60;/artifactId&#62; &#60;version&#62;1.6.12&#60;/version&#62; &#60;/dependency&#62; Code: import com.restfb.json.JsonObject; ... String json = &#34;{\&#34;name\&#34;:\&#34;Benny\&#34;,\&#34;email\&#34;:\&#34;test\\u0040bennyn.de\&#34;}&#34;; JsonObject object = new JsonObject&#40;json&#41;; String email [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Möglichkeit 1</strong></p>
<p>Maven Dependency:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>net.sf.json-lib<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>json-lib<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classifier<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jdk15<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/classifier<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Code:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.json.JSONObject</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">net.sf.json.JSONSerializer</span><span style="color: #339933;">;</span>
...
<span style="color: #003399;">String</span> json <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{<span style="color: #000099; font-weight: bold;">\&quot;</span>name<span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\&quot;</span>Benny<span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span>email<span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\&quot;</span>test<span style="color: #000099; font-weight: bold;">\\</span>u0040bennyn.de<span style="color: #000099; font-weight: bold;">\&quot;</span>}&quot;</span><span style="color: #339933;">;</span>
JSONObject object <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>JSONObject<span style="color: #009900;">&#41;</span> JSONSerializer.<span style="color: #006633;">toJSON</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> email <span style="color: #339933;">=</span> object.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;email&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// test@bennyn.de</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 2</strong></p>
<p>Maven Dependency:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.restfb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>restfb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6.12<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Code:</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.restfb.json.JsonObject</span><span style="color: #339933;">;</span>
...
<span style="color: #003399;">String</span> json <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;{<span style="color: #000099; font-weight: bold;">\&quot;</span>name<span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\&quot;</span>Benny<span style="color: #000099; font-weight: bold;">\&quot;</span>,<span style="color: #000099; font-weight: bold;">\&quot;</span>email<span style="color: #000099; font-weight: bold;">\&quot;</span>:<span style="color: #000099; font-weight: bold;">\&quot;</span>test<span style="color: #000099; font-weight: bold;">\\</span>u0040bennyn.de<span style="color: #000099; font-weight: bold;">\&quot;</span>}&quot;</span><span style="color: #339933;">;</span>
JsonObject object <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> JsonObject<span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> email <span style="color: #339933;">=</span> object.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;email&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// test@bennyn.de</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/programmierung/java/json-parsen-mit-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event-Handler mit JavaScript hinzufügen und entfernen</title>
		<link>http://www.bennyn.de/programmierung/javascript/event-handler-mit-javascript-hinzufugen-und-entfernen.html</link>
		<comments>http://www.bennyn.de/programmierung/javascript/event-handler-mit-javascript-hinzufugen-und-entfernen.html#comments</comments>
		<pubDate>Wed, 03 Apr 2013 19:06:55 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[addEventListener]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[entfernen]]></category>
		<category><![CDATA[Event Handler]]></category>
		<category><![CDATA[hinzufügen]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[removeEventListener]]></category>
		<category><![CDATA[unbind]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=5514</guid>
		<description><![CDATA[Event-Handler (dt. Ereignisbehandler) können in JavaScript über verschiedene Wege hinzugefügt werden. In den folgenden Code-Beispielen zeige ich die Vor- und Nachteile der jeweiligen Lösungen mit reinem JavaScript und jQuery. Event-Handler hinzufügen Möglichkeit 1 window.onload = function&#40;&#41; &#123; console.log&#40;'Ich bin ein Event-Handler.'&#41;; &#125;; &#160; window.onload = function&#40;&#41; &#123; console.log&#40;'... allerdings überschreibe alle vorherigen Event-Handler.'&#41;; &#125;; Möglichkeit [...]]]></description>
				<content:encoded><![CDATA[<p><strong>Event-Handler</strong> (dt. Ereignisbehandler) können in JavaScript über verschiedene Wege hinzugefügt werden. In den folgenden Code-Beispielen zeige ich die Vor- und Nachteile der jeweiligen Lösungen mit reinem JavaScript und jQuery.<br />
<span id="more-5514"></span></p>
<h2>Event-Handler hinzufügen</h2>
<p><strong>Möglichkeit 1</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #660066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Ich bin ein Event-Handler.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
window.<span style="color: #660066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'... allerdings überschreibe alle vorherigen Event-Handler.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 2</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Ich überschreibe NICHT meine vorherigen Event-Handler.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Allerdings funktioniere ich nicht in allen Browsern.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Im Internet Explorer 8 nennt man mich attachEvent()'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 3</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Ich funktioniere in vielen Browsern!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 4</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Ich bin die ALTE Variante von on()'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 5</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Ich bin die Kurzschreibweise von on('load')&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Event-Handler entfernen</h2>
<p><strong>Möglichkeit 1</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Man kann mich auch entfernen!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">off</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 2</strong></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Natürlich kann man mich auch ohne jQuery entfernen.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
window.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
window.<span style="color: #660066;">removeEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Event-Handler für mehrere Events</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Ich bin ein Event-Handler.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'load resize orientationchange'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Ereignis auslösen / Event triggern</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Ich bin ein Event-Handler.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Event-Triggering mit Parameterübergabe</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$event<span style="color: #339933;">,</span> param1<span style="color: #339933;">,</span> param2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>$event.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// orientationchange</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>param1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Hello</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>param2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// World</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Hello'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'World'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Event-Triggering mit Parameterübergabe und JSDoc</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Event handling example for 'window.onorientationchange' with jQuery.
 * 
 * @param {type} $event jQuery’s Event Object: http://api.jquery.com/category/events/event-object/
 * @param {type} param1 First argument from triggered parameters: http://api.jquery.com/trigger/
 * @param {type} param2 Second argument from triggered parameters: http://api.jquery.com/trigger/
 * @returns {undefined}
 */</span>
<span style="color: #000066; font-weight: bold;">var</span> handler <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$event<span style="color: #339933;">,</span> param1<span style="color: #339933;">,</span> param2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>$event.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// orientationchange</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>param1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Hello</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>param2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// World</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> handler<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Hello'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'World'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2>Event-Handling mit jQuery Chaining</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$event<span style="color: #339933;">,</span> param1<span style="color: #339933;">,</span> param2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>$event.<span style="color: #660066;">type</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// orientationchange</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>param1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Hello</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>param2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// World</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'Hello'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'World'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Nachteil: Event-Handler wurde mit einer anonymen Funktionen erstellt und lässt sich nicht über <code>$(window).off('orientationchange', handler);</code> entfernen. Die Lösung besteht in der Nutzung von eigenen Event-Namen.</p>
<h2>Event-Handling mit eigenen Event-Namen</h2>

<div class="wp_syntax"><table><tr><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">on</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange.helloWorld'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Hello World'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Hello World</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">off</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange.helloWorld'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">trigger</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'orientationchange'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Nothing...</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/programmierung/javascript/event-handler-mit-javascript-hinzufugen-und-entfernen.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event Handler in Windows Store-Apps hinzufügen</title>
		<link>http://www.bennyn.de/programmierung/csharp/event-handler-in-windows-store-apps-hinzufugen.html</link>
		<comments>http://www.bennyn.de/programmierung/csharp/event-handler-in-windows-store-apps-hinzufugen.html#comments</comments>
		<pubDate>Sun, 24 Mar 2013 21:56:10 +0000</pubDate>
		<dc:creator>bennyn</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Event Handler]]></category>
		<category><![CDATA[Windows Store-Apps]]></category>
		<category><![CDATA[XAML]]></category>

		<guid isPermaLink="false">http://www.bennyn.de/?p=5497</guid>
		<description><![CDATA[XAML-Element: 1 &#60;Grid x:Name=&#34;advert&#34;&#62;...&#60;/Grid&#62; Möglichkeit 1 1 &#60;Grid x:Name=&#34;advert&#34; Tapped=&#34;AdvertTapped&#34;&#62;...&#60;/Grid&#62; 1 2 3 4 private void AdvertTapped&#40;object sender, TappedRoutedEventArgs e&#41; &#123; // do something &#125; Möglichkeit 2 1 2 3 4 5 6 7 8 9 10 11 public GroupDetailPage&#40;&#41; &#123; this.InitializeComponent&#40;&#41;; &#160; advert.AddHandler&#40;Grid.TappedEvent, new TappedEventHandler&#40;AdvertTapped&#41;, true&#41;; &#125; &#160; private void AdvertTapped&#40;object sender, TappedRoutedEventArgs e&#41; [...]]]></description>
				<content:encoded><![CDATA[<p><strong>XAML-Element:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;advert&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><strong>Möglichkeit 1</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Grid</span> <span style="color: #000066;">x:Name</span>=<span style="color: #ff0000;">&quot;advert&quot;</span> <span style="color: #000066;">Tapped</span>=<span style="color: #ff0000;">&quot;AdvertTapped&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>...<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Grid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> AdvertTapped<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, TappedRoutedEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
 <span style="color: #008080; font-style: italic;">// do something</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 2</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> GroupDetailPage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InitializeComponent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  advert<span style="color: #008000;">.</span><span style="color: #0000FF;">AddHandler</span><span style="color: #008000;">&#40;</span>Grid<span style="color: #008000;">.</span><span style="color: #0000FF;">TappedEvent</span>, <span style="color: #008000;">new</span> TappedEventHandler<span style="color: #008000;">&#40;</span>AdvertTapped<span style="color: #008000;">&#41;</span>, <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> AdvertTapped<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, TappedRoutedEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
 <span style="color: #008080; font-style: italic;">// do something</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 3</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> GroupDetailPage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InitializeComponent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  advert<span style="color: #008000;">.</span><span style="color: #0000FF;">Tapped</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">new</span> TappedEventHandler<span style="color: #008000;">&#40;</span>AdvertTapped<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">void</span> AdvertTapped<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, TappedRoutedEventArgs e<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #008080; font-style: italic;">// do something</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p><strong>Möglichkeit 4</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> GroupDetailPage<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
  <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">InitializeComponent</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
  advert<span style="color: #008000;">.</span><span style="color: #0000FF;">Tapped</span> <span style="color: #008000;">+=</span> <span style="color: #008000;">&#40;</span>sender, e<span style="color: #008000;">&#41;</span> <span style="color: #008000;">=&gt;</span>
  <span style="color: #008000;">&#123;</span>
    <span style="color: #008080; font-style: italic;">// do something</span>
  <span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bennyn.de/programmierung/csharp/event-handler-in-windows-store-apps-hinzufugen.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
