<?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>wicket praxis &#187; component</title>
	<atom:link href="http://www.wicket-praxis.de/blog/tag/component/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.wicket-praxis.de/blog</link>
	<description>erfahrungen mit wicket aus dem projektalltag</description>
	<lastBuildDate>Fri, 26 Aug 2011 11:14:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Wicket &#8211; Flexibilität mit Factories</title>
		<link>http://www.wicket-praxis.de/blog/2010/07/15/wicket-flexibilitat-mit-factories/</link>
		<comments>http://www.wicket-praxis.de/blog/2010/07/15/wicket-flexibilitat-mit-factories/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 07:13:46 +0000</pubDate>
		<dc:creator>michael</dc:creator>
				<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Wicket]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[factory]]></category>

		<guid isPermaLink="false">http://www.wicket-praxis.de/blog/?p=270</guid>
		<description><![CDATA[Komplexe Komponenten entstehen in Wicket durch das zusammenfügen von einfacheren Komponenten. Dabei werden die verwendeten Komponenten direkt adressiert. Nach außen ist nicht sichtbar, wie sich eine Komponente zusammensetzt. Um von dieser Komponente eine leicht abgewandelte Form zu erstellen, kann man auf z.B. Vererbung zurückgreifen, Komponenten ausblenden, das Markup überschreiben. Je mehr Variationen nötig sind, desto [...]]]></description>
			<content:encoded><![CDATA[<p>Komplexe Komponenten entstehen in Wicket durch das zusammenfügen von einfacheren Komponenten. Dabei werden die verwendeten Komponenten direkt adressiert. Nach außen ist nicht sichtbar, wie sich eine Komponente zusammensetzt. Um von dieser Komponente eine leicht abgewandelte Form zu erstellen, kann man auf z.B. Vererbung zurückgreifen, Komponenten ausblenden, das Markup überschreiben. Je mehr Variationen nötig sind, desto komplizierter wird der Aufbau. Der Aufwand steigt erheblich an.</p>
<p>Einen Ausweg aus dieser Situation könnte die Verwendung von Factories liefern. Dazu benötigen wir ein sehr einfach gehaltenes Interface:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.factories</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Component</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> IComponentFactory<span style="color: #339933;">&lt;</span>T <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;T newComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Eine einfach Implementierung, die immer ein Label mit einem bestimmten Text liefert, können wir wie folgt implementieren:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.factories</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.basic.Label</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.IModel</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LabelFactory <span style="color: #000000; font-weight: bold;">implements</span> IComponentFactory<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Label</span><span style="color: #339933;">&gt;</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;IModel<span style="color: #339933;">&lt;?&gt;</span> _model<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> LabelFactory<span style="color: #009900;">&#40;</span>IModel<span style="color: #339933;">&lt;?&gt;</span> model<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_model = model<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Label</span> newComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Label</span><span style="color: #009900;">&#40;</span>id,_model<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Wir übergeben hierbei ein Model, das durch das Label angezeigt wird. Soll ein anderer Text angezeigt werden, muss man dafür eine neue Factory erstellen. Bis jetzt ist noch kein Vorteil dieser Lösung absehbar. Deshalb steigern wir etwas die Komplexität. Wir erstellen eine Factory, die einen Rahmen um eine Komponente ziehen kann. Dabei wird für die Darstellung das style-Attribut erweitert.<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.factories</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.AttributeModifier</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Component</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.behavior.AttributeAppender</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.WebMarkupContainer</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.panel.Panel</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.IModel</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BorderPanelFactory <span style="color: #000000; font-weight: bold;">implements</span> IComponentFactory<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Panel</span><span style="color: #339933;">&gt;</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> _content<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> IModel<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> _style<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> content, IModel<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> style<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_content = content<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_style = style<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Panel</span> newComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> BorderPanel<span style="color: #009900;">&#40;</span>id, _content, _style<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> BorderPanel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Panel</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> BorderPanel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id,IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> content,IModel<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> style<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WebMarkupContainer border=<span style="color: #000000; font-weight: bold;">new</span> WebMarkupContainer<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>content.<span style="color: #006633;">newComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;content&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;border.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> AttributeAppender<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;style&quot;</span>, <span style="color: #006600; font-weight: bold;">true</span>, style,<span style="color: #0000ff;">&quot;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>border<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
Wir übergeben daher eine Factory, die Komponenten erzeugt und ein Model, dass die Styleattribute beinhaltet. In dem Panel, was innerhalb der Factory erzeugt wird, wir dann eine Komponente eingebunden (&#8220;content&#8221;), die aus der übergebenen Factory kommt. Wir benötigen noch eine passende Markup-Datei (BorderPanelFactory$BorderPanel.html):<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;wicket:panel&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;padding: 8px&quot;</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;wicket:container wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>wicket:container&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>wicket:panel&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Um zu demonstrieren, welche Flexibilität man mit diesen wenigen Klassen bereits erreicht hat, verwenden wir beide Factories in einem Beispiel:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.factories</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.WebPage</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.Model</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ComponentFactoryPage <span style="color: #000000; font-weight: bold;">extends</span> WebPage</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> ComponentFactoryPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Model<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> redBorderStyle = Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border:1px solid red; background-color: #fff0f0;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Model<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> greenBorderStyle = Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border:1px solid green; background-color: #f0fff0;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Model<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> blueBorderStyle = Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border:1px solid blue; background-color: #f0f0ff;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;LabelFactory haveFunLabelFactory = <span style="color: #000000; font-weight: bold;">new</span> LabelFactory<span style="color: #009900;">&#40;</span>Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Have Fun&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;BorderPanelFactory redBorderHasFunFactory = <span style="color: #000000; font-weight: bold;">new</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>haveFunLabelFactory,redBorderStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;BorderPanelFactory greenBorderWrapsRedFactory = <span style="color: #000000; font-weight: bold;">new</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>redBorderHasFunFactory,greenBorderStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;BorderPanelFactory blueBorderWrapsAllFactory = <span style="color: #000000; font-weight: bold;">new</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>greenBorderWrapsRedFactory,blueBorderStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>blueBorderWrapsAllFactory.<span style="color: #006633;">newComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;element&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Wir erstellen 3 Modelle mit unterschiedlichen Werten für das style-Attribut. Um etwas Text anzuzeigen benutzen wir die LabelFactory. Danach werden drei BorderPanelFactory-Instanzen erzeugt, die eine andere Factory &#8220;umwickelt&#8221;. Zum Schluss wird ein Element erzeugt und in der Seite benutzt. Das Markup ist entsprechend einfach:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>ComponentFactory Page<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;wicket:container wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;element&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>wicket:container&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Das Ergebnis sieht dann wie folgt aus:<br />
<a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2010/07/wicket-component-factory.jpg"><img src="http://www.wicket-praxis.de/blog/wp-content/uploads/2010/07/wicket-component-factory-450x72.jpg" alt="" title="Wicket Component Factory Beispiel" width="450" height="72" class="aligncenter size-medium wp-image-271" /></a></p>
<p>Um zu zeigen, wie schnell die Möglichkeiten wachsen, die man mit diesem Ansatz abdecken kann, erstellen wir eine weitere Factory. In diesem Fall möchten wir zwei Elemente nebeneinander dargestellen:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.factories</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Component</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.panel.Panel</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TwoInARowFactory <span style="color: #000000; font-weight: bold;">implements</span> IComponentFactory<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> _left<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> _right<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> TwoInARowFactory<span style="color: #009900;">&#40;</span>IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> left, IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> right<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_left = left<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_right = right<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> newComponent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ContainerPanel<span style="color: #009900;">&#40;</span>id, _left, _right<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> ContainerPanel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Panel</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> ContainerPanel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id,IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> left, IComponentFactory<span style="color: #339933;">&lt;?</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span> right<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>left.<span style="color: #006633;">newComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>right.<span style="color: #006633;">newComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--><br />
Es werden daher zwei Factories übergeben, die dann für die Erzeugung des linken und des rechten Elements zuständig sind. Das Markup benutzt der Einfachheit halber Html-Tabellen für die Anordnung:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;wicket:panel&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">table</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">tr</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;wicket:container wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;left&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>wicket:container&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">td</span>&gt;&lt;wicket:container wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;right&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>wicket:container&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">td</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">tr</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">table</span>&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>wicket:panel&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Unsere Seitenklasse ergänzen wir entsprechend:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.factories</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.WebPage</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.Model</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ComponentFactoryPage <span style="color: #000000; font-weight: bold;">extends</span> WebPage</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> ComponentFactoryPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Model<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> redBorderStyle = Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border:1px solid red; background-color: #fff0f0;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Model<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> greenBorderStyle = Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border:1px solid green; background-color: #f0fff0;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Model<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">String</span><span style="color: #339933;">&gt;</span> blueBorderStyle = Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;border:1px solid blue; background-color: #f0f0ff;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;LabelFactory haveFunLabelFactory = <span style="color: #000000; font-weight: bold;">new</span> LabelFactory<span style="color: #009900;">&#40;</span>Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Have Fun&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;BorderPanelFactory redBorderHasFunFactory = <span style="color: #000000; font-weight: bold;">new</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>haveFunLabelFactory,redBorderStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;BorderPanelFactory greenBorderWrapsRedFactory = <span style="color: #000000; font-weight: bold;">new</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>redBorderHasFunFactory,greenBorderStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;BorderPanelFactory blueBorderWrapsAllFactory = <span style="color: #000000; font-weight: bold;">new</span> BorderPanelFactory<span style="color: #009900;">&#40;</span>greenBorderWrapsRedFactory,blueBorderStyle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>blueBorderWrapsAllFactory.<span style="color: #006633;">newComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;element&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;TwoInARowFactory twoInARowFactory = <span style="color: #000000; font-weight: bold;">new</span> TwoInARowFactory<span style="color: #009900;">&#40;</span>redBorderHasFunFactory, greenBorderWrapsRedFactory<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>twoInARowFactory.<span style="color: #006633;">newComponent</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Das Markup muss ebenfalls angepasst werden:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>ComponentFactory Page<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;wicket:container wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;element&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>wicket:container&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&lt;wicket:container wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;two&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>wicket:container&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Das Ergebnis kann sich sehen lassen:<br />
<a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2010/07/wicket-component-factory-split.jpg"><img src="http://www.wicket-praxis.de/blog/wp-content/uploads/2010/07/wicket-component-factory-split-450x128.jpg" alt="" title="Wicket Component Factory Split" width="450" height="128" class="aligncenter size-medium wp-image-272" /></a></p>
<p>Wie man an diesem Beispiel sehr gut erkennen kann, liegt in diesem Ansatz sehr viel Potential, gerade wenn die Anforderungen an die Flexibilität sehr hoch sind. In Projekten, die eine hohe Flexibilität erforderten hat sich dieses System bereits erfolgreich bewährt. Dabei kommt eine Kombinationen aus dem &#8220;klassischen&#8221; und dem Factory-Ansatz zum Einsatz, wodurch sich die meisten Anforderungen wesentlich besser abdecken lassen.</p>
<p>Gibt es noch ganz andere Lösungsstrategien?</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F07%2F15%2Fwicket-flexibilitat-mit-factories%2F&amp;title=Wicket%20-%20Flexibilit%C3%A4t%20mit%20Factories&amp;bodytext=Komplexe%20Komponenten%20entstehen%20in%20Wicket%20durch%20das%20zusammenf%C3%BCgen%20von%20einfacheren%20Komponenten.%20Dabei%20werden%20die%20verwendeten%20Komponenten%20direkt%20adressiert.%20Nach%20au%C3%9Fen%20ist%20nicht%20sichtbar%2C%20wie%20sich%20eine%20Komponente%20zusammensetzt.%20Um%20von%20dieser%20Komponent" title="Digg"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F07%2F15%2Fwicket-flexibilitat-mit-factories%2F" title="Sphinn"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F07%2F15%2Fwicket-flexibilitat-mit-factories%2F&amp;title=Wicket%20-%20Flexibilit%C3%A4t%20mit%20Factories&amp;notes=Komplexe%20Komponenten%20entstehen%20in%20Wicket%20durch%20das%20zusammenf%C3%BCgen%20von%20einfacheren%20Komponenten.%20Dabei%20werden%20die%20verwendeten%20Komponenten%20direkt%20adressiert.%20Nach%20au%C3%9Fen%20ist%20nicht%20sichtbar%2C%20wie%20sich%20eine%20Komponente%20zusammensetzt.%20Um%20von%20dieser%20Komponent" title="del.icio.us"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F07%2F15%2Fwicket-flexibilitat-mit-factories%2F&amp;t=Wicket%20-%20Flexibilit%C3%A4t%20mit%20Factories" title="Facebook"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F07%2F15%2Fwicket-flexibilitat-mit-factories%2F&amp;title=Wicket%20-%20Flexibilit%C3%A4t%20mit%20Factories" title="Mixx"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F07%2F15%2Fwicket-flexibilitat-mit-factories%2F&amp;title=Wicket%20-%20Flexibilit%C3%A4t%20mit%20Factories&amp;annotation=Komplexe%20Komponenten%20entstehen%20in%20Wicket%20durch%20das%20zusammenf%C3%BCgen%20von%20einfacheren%20Komponenten.%20Dabei%20werden%20die%20verwendeten%20Komponenten%20direkt%20adressiert.%20Nach%20au%C3%9Fen%20ist%20nicht%20sichtbar%2C%20wie%20sich%20eine%20Komponente%20zusammensetzt.%20Um%20von%20dieser%20Komponent" title="Google Bookmarks"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
<div id="vgwpixel"><img src="http://vg05.met.vgwort.de/na/dbf3aa1d112c4807bddeabbd9ede6f31" width="1" height="1" alt=""></div><h3  class="related_post_title">Andere Beiträge</h3><ul class="related_post"><li>5. Januar 2010 -- <a href="http://www.wicket-praxis.de/blog/2010/01/05/wicket-lose-koppelung-von-komponenten/" title="Wicket &#8211; lose Koppelung von Komponenten">Wicket &#8211; lose Koppelung von Komponenten</a></li><li>16. Oktober 2009 -- <a href="http://www.wicket-praxis.de/blog/2009/10/16/wicket-component-overview/" title="Wicket Komponentenübersicht">Wicket Komponentenübersicht</a></li><li>29. April 2011 -- <a href="http://www.wicket-praxis.de/blog/2011/04/29/wicket-back-button-detect/" title="Wicket &#8211; Back Button zuverlässig erkennen">Wicket &#8211; Back Button zuverlässig erkennen</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.wicket-praxis.de/blog/2010/07/15/wicket-flexibilitat-mit-factories/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Wicket &#8211; lose Koppelung von Komponenten</title>
		<link>http://www.wicket-praxis.de/blog/2010/01/05/wicket-lose-koppelung-von-komponenten/</link>
		<comments>http://www.wicket-praxis.de/blog/2010/01/05/wicket-lose-koppelung-von-komponenten/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 08:02:40 +0000</pubDate>
		<dc:creator>michael</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Refactoring]]></category>
		<category><![CDATA[Wicket]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[coupling]]></category>
		<category><![CDATA[koppelung]]></category>
		<category><![CDATA[loose]]></category>
		<category><![CDATA[lose]]></category>

		<guid isPermaLink="false">http://www.wicket-praxis.de/blog/?p=225</guid>
		<description><![CDATA[Auch bei Webanwendungen entstehen schnell komplexe Oberflächen. Es ist nur eine Frage der Zeit, bis man Komponenten, die miteinander interagieren sollen, gegenseitig bekannt macht. Diese Vorgehensweise ist limitiert und außerdem sehr aufwendig. Wie ich bereits im Buch beschrieben habe, kann man die Koppelung von Komponenten aufweichen, die per Ajax neu gezeichnet werden müssen. Dabei ist [...]]]></description>
			<content:encoded><![CDATA[<p>Auch bei Webanwendungen entstehen schnell komplexe Oberflächen. Es ist nur eine Frage der Zeit, bis man Komponenten, die miteinander interagieren sollen, gegenseitig bekannt macht. Diese Vorgehensweise ist limitiert und außerdem sehr aufwendig. Wie ich bereits im <a href="http://books.google.de/books?id=9esdx8R-fJAC&#038;pg=PA103&#038;lpg=PA103&#038;dq=praxisbuch+wicket+Ajax+Events&#038;source=bl&#038;ots=ajlFEqWKuj&#038;sig=FA36Ar-X7aa4psPGuECpIJrKZtU&#038;hl=de&#038;ei=aONCS6-AFZLcmgOI4azzCw&#038;sa=X&#038;oi=book_result&#038;ct=result&#038;resnum=10&#038;ved=0CDQQ6AEwCQ#v=onepage&#038;q=&#038;f=false">Buch</a> beschrieben habe, kann man die Koppelung von Komponenten aufweichen, die per Ajax neu gezeichnet werden müssen. Dabei ist es zu kurz gedacht, dass man die Entkoppelung von Komponenten nur aus diesem Grund forciert.</p>
<p>Der Unterschied zwischen einem normalen Request und einem Ajax-Request liegt darin, dass bei einem Ajax-Request nur Teile der Seite neu gerendert werden. Dazu müssen die Komponenten markiert werden, die in der Zielseite ersetzt werden sollen. Wenn es sich um einen normalen Request handelt, ist das nicht notwendig, da die ganze Seite und damit alle Komponenten neu gerendert werden.</p>
<p>Solange sich alle Aktionen auf die Änderungen von Daten beziehen, die dann entweder per Ajax neu dargestellt werden oder beim Darstellen der ganzen Seite automatisch angezeigt werden, besteht eigentlich kein Grund, mehr Aufwand in das Entkoppeln von Komponenten zu stecken. Doch oft ist das Ändern der Daten nicht trivial, der Code verteilt sich unwillkürlich auf verschiedene Komponenten.</p>
<p>Um dieser Entwicklung entgegen zu wirken, erweitert man das Event-Konzept einfach auch auf normale Requests. Im folgenden Code werden daher alle notwendigen Klassen aufgeführt. Die im Buch verwendeten Klassen können durch diese ersetzt werden.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.events</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> EventListenerInterface</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> notifyAjaxEvent<span style="color: #009900;">&#40;</span>AbstractEvent event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Das EventListenerInterface muss jede Komponente implementieren, dass auf Events reagieren muss.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.events</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Component</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Page</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Component.IVisitor</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.ajax.AjaxRequestTarget</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AbstractEvent</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #003399; font-weight: bold;">Component</span> _source<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;AjaxRequestTarget _requestTarget<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">protected</span> AbstractEvent<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Component</span> source,AjaxRequestTarget requestTarget<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_source=source<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;_requestTarget=requestTarget<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Component</span> getSource<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">return</span> _source<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> fire<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;Page page = _source.<span style="color: #006633;">getPage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000;&nbsp;&nbsp;font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>page <span style="color: #000000; font-weight: bold;">instanceof</span> EventListenerInterface<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>EventListenerInterface<span style="color: #009900;">&#41;</span> page<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">notifyAjaxEvent</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;page.<span style="color: #006633;">visitChildren</span><span style="color: #009900;">&#40;</span>EventListenerInterface.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> AjaxEventVisitor<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> update<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Component</span> component<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000;&nbsp;&nbsp;font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>_requestTarget<span style="color: #339933;">!</span>=<span style="color: #006600; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> _requestTarget.<span style="color: #006633;">addComponent</span><span style="color: #009900;">&#40;</span>component<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> AjaxEventVisitor <span style="color: #000000; font-weight: bold;">implements</span> IVisitor<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Component</span><span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;AbstractEvent _event<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">protected</span> AjaxEventVisitor<span style="color: #009900;">&#40;</span>AbstractEvent event<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_event=event<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399; font-weight: bold;">Object</span> component<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Component</span> component<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>EventListenerInterface<span style="color: #009900;">&#41;</span> component<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">notifyAjaxEvent</span><span style="color: #009900;">&#40;</span>_event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">return</span> IVisitor.<span style="color: #006633;">CONTINUE_TRAVERSAL</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Die Eventklasse wurde dahingehend erweitert, dass jetzt auch für die Seite geprüft wird, ob das EventListernerInterface implementiert wurde. Ob Ajax benutzt wurde oder nicht, wird in der update()-Methode überprüft, so dass man diese Prüfung nicht mehr selbst vornehmen muss.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.events</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.Component</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.ajax.AjaxRequestTarget</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #003399; font-weight: bold;">ChangeEvent</span> <span style="color: #000000; font-weight: bold;">extends</span> AbstractEvent</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #006600; font-weight: bold;">int</span> _change<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399; font-weight: bold;">ChangeEvent</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">Component</span> source, AjaxRequestTarget requestTarget, <span style="color: #006600; font-weight: bold;">int</span> change<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>source, requestTarget<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;_change=change<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">int</span> getChange<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">return</span> _change<span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Der ChangeEvent wurde abgeleitet und um eine Information erweitert. In der folgenden Komponente wird diese Information ausgewertet:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.events</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.basic.Label</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.panel.Panel</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.IModel</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CounterPanel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Panel</span> <span style="color: #000000; font-weight: bold;">implements</span> EventListenerInterface</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;IModel<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Integer</span><span style="color: #339933;">&gt;</span> _counter<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> CounterPanel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id,IModel<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Integer</span><span style="color: #339933;">&gt;</span> counter<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;setOutputMarkupId<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;_counter=counter<span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;counter&quot;</span>,_counter<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> notifyAjaxEvent<span style="color: #009900;">&#40;</span>AbstractEvent event<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000;&nbsp;&nbsp;font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399; font-weight: bold;">ChangeEvent</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #006600; font-weight: bold;">int</span> change = <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">ChangeEvent</span><span style="color: #009900;">&#41;</span> event<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getChange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #003399; font-weight: bold;">Integer</span> cur = _counter.<span style="color: #006633;">getObject</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;info<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Aktuell: &quot;</span>+cur+<span style="color: #0000ff;">&quot; Change: &quot;</span>+change<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_counter.<span style="color: #006633;">setObject</span><span style="color: #009900;">&#40;</span>cur+change<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.<span style="color: #006633;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Man beachte, dass für die Komponente setOutputMarkupId() aufgerufen wird, da diese Komponente evtl. per Ajax aktualisiert werden kann.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;wicket:panel&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span> wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;counter&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>wicket:panel&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Jetzt benötigen wir noch eine Komponente, die diesen Event auslöst:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.events</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.ajax.AjaxRequestTarget</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.ajax.markup.html.AjaxFallbackLink</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.basic.Label</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.panel.Panel</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.IModel</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ActionPanel <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399; font-weight: bold;">Panel</span></li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> ActionPanel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id,IModel<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Integer</span><span style="color: #339933;">&gt;</span> change<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;AjaxFallbackLink<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Integer</span><span style="color: #339933;">&gt;</span> link = <span style="color: #000000; font-weight: bold;">new</span> AjaxFallbackLink<span style="color: #339933;">&lt;</span><span style="color: #003399; font-weight: bold;">Integer</span><span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;link&quot;</span>,change<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@<span style="color: #003399; font-weight: bold;">Override</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span>AjaxRequestTarget target<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">ChangeEvent</span><span style="color: #009900;">&#40;</span>ActionPanel.<span style="color: #000000; font-weight: bold;">this</span>,target,getModelObject<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">fire</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;link.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399; font-weight: bold;">Label</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;change&quot;</span>,change<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span>link<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="HTML"><div class="devcodeoverflow"><ol><li><span style="color: #009900;">&lt;wicket:panel&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;link&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">span</span> wicket:<span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;change&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></li><li><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span>wicket:panel&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Nachdem wir alle Komponten erstell habe, benutzen wir sie in einer Anwendung:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">de.wicketpraxis.web.blog.pages.questions.events</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.WebPage</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.markup.html.panel.FeedbackPanel</span><span style="color: #339933;">;</span></li><li><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.wicket.model.Model</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> EventPage <span style="color: #000000; font-weight: bold;">extends</span> WebPage</li><li><span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> EventPage<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> EventFeedbackPanel<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;feedback&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ActionPanel<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;changeAdd1&quot;</span>,Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ActionPanel<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;changeSub1&quot;</span>,Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span>-<span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;add<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> CounterPanel<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;counter&quot;</span>,Model.<span style="color: #006633;">of</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> EventFeedbackPanel <span style="color: #000000; font-weight: bold;">extends</span> FeedbackPanel <span style="color: #000000; font-weight: bold;">implements</span> EventListenerInterface</li><li>&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> EventFeedbackPanel<span style="color: #009900;">&#40;</span><span style="color: #003399; font-weight: bold;">String</span> id<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setOutputMarkupId<span style="color: #009900;">&#40;</span><span style="color: #006600; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #006600; font-weight: bold;">void</span> notifyAjaxEvent<span style="color: #009900;">&#40;</span>AbstractEvent event<span style="color: #009900;">&#41;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#123;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;event.<span style="color: #006633;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li>&nbsp;&nbsp;<span style="color: #009900;">&#125;</span></li><li><span style="color: #009900;">&#125;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Wie man sieht, habe ich auch ein FeedbackPanel erstellt, dass auf Events (und in diesem Fall jedes) reagiert.</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="Java(TM) 2 Platform Standard Edition 5.0"><div class="devcodeoverflow"><ol><li><span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>head<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>title<span style="color: #339933;">&gt;</span>EventPage<span style="color: #339933;">&lt;</span>/title<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>/head<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>body<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>div wicket:id=<span style="color: #0000ff;">&quot;feedback&quot;</span><span style="color: #339933;">&gt;&lt;</span>/div<span style="color: #339933;">&gt;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>wicket:container wicket:id=<span style="color: #0000ff;">&quot;changeAdd1&quot;</span><span style="color: #339933;">&gt;&lt;</span>/wicket:container<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>wicket:container wicket:id=<span style="color: #0000ff;">&quot;changeSub1&quot;</span><span style="color: #339933;">&gt;&lt;</span>/wicket:container<span style="color: #339933;">&gt;</span></li><li>&nbsp;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>div wicket:id=<span style="color: #0000ff;">&quot;counter&quot;</span><span style="color: #339933;">&gt;&lt;</span>/div<span style="color: #339933;">&gt;</span></li><li>&nbsp;&nbsp;<span style="color: #339933;">&lt;</span>/body<span style="color: #339933;">&gt;</span></li><li><span style="color: #339933;">&lt;</span>/html<span style="color: #339933;">&gt;</span></li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Wenn Komponenten per Ajax aktualisiert werden müssen, funktioniert das nur, wenn es auch ein Html-Tag mit der passenden ID gibt, dass per Javascript gefunden und ersetzt werden kann. Daher muss man die Komponente dann an ein Html-Tag binden, die Einbettung über wicket:container funktioniert nicht.</p>
<p>Betätigt man nun einen der Links in der AktionPanel-Komponente, dann wird der Zähler in der CounterPanel-Komponenten angepasst und eine entsprechende Meldung im FeedbackPanel angezeigt. Wenn man nun das CounterPanel einfach ausbaut, passiert nichts. Das zeigt zum einen, dass die Komponenten wirklich unabhängig voneinander sind, zum anderen aber auch, welches Risiko man eingeht: es kann vorkommen, dass Events nicht verarbeitet werden.</p>
<p>Dieses Beispiel veranschaulicht, wie einfach man Komponenten entkoppeln kann. Doch dieses Beispiel ist nur eine einfache Anwendung. Wie weit man diese Vorgehensweise in der Praxis treiben kann, möchte ich in ein paar Sichtpunkten erwähnen:</p>
<ul>
<li>Anwendung der Möglichkeiten von Vererbung auf Events</li>
<li>Prüfung, ob ein Event einen Empfänger erreicht hat</li>
<li>Kaskadierung von Events (wenn Event A eintrifft, wird Event B ausgelöst)</li>
<li>Mehr als ein Sender und mehr als einen Empfänger für Events</li>
<li>Ein Event kann mit und ohne Ajax ausgelöst werden, ohne dass der Code auf Empfängerseite angepasst werden muss.</li>
</ul>
<p>Ich hoffe, dass dient als Anregung oder Vorlage. Komplexen Oberflächen mit Wicket steht nun nichts mehr im Weg.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F01%2F05%2Fwicket-lose-koppelung-von-komponenten%2F&amp;title=Wicket%20-%20lose%20Koppelung%20von%20Komponenten&amp;bodytext=Auch%20bei%20Webanwendungen%20entstehen%20schnell%20komplexe%20Oberfl%C3%A4chen.%20Es%20ist%20nur%20eine%20Frage%20der%20Zeit%2C%20bis%20man%20Komponenten%2C%20die%20miteinander%20interagieren%20sollen%2C%20gegenseitig%20bekannt%20macht.%20Diese%20Vorgehensweise%20ist%20limitiert%20und%20au%C3%9Ferdem%20sehr%20aufwendig.%20Wie" title="Digg"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F01%2F05%2Fwicket-lose-koppelung-von-komponenten%2F" title="Sphinn"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F01%2F05%2Fwicket-lose-koppelung-von-komponenten%2F&amp;title=Wicket%20-%20lose%20Koppelung%20von%20Komponenten&amp;notes=Auch%20bei%20Webanwendungen%20entstehen%20schnell%20komplexe%20Oberfl%C3%A4chen.%20Es%20ist%20nur%20eine%20Frage%20der%20Zeit%2C%20bis%20man%20Komponenten%2C%20die%20miteinander%20interagieren%20sollen%2C%20gegenseitig%20bekannt%20macht.%20Diese%20Vorgehensweise%20ist%20limitiert%20und%20au%C3%9Ferdem%20sehr%20aufwendig.%20Wie" title="del.icio.us"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F01%2F05%2Fwicket-lose-koppelung-von-komponenten%2F&amp;t=Wicket%20-%20lose%20Koppelung%20von%20Komponenten" title="Facebook"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F01%2F05%2Fwicket-lose-koppelung-von-komponenten%2F&amp;title=Wicket%20-%20lose%20Koppelung%20von%20Komponenten" title="Mixx"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2010%2F01%2F05%2Fwicket-lose-koppelung-von-komponenten%2F&amp;title=Wicket%20-%20lose%20Koppelung%20von%20Komponenten&amp;annotation=Auch%20bei%20Webanwendungen%20entstehen%20schnell%20komplexe%20Oberfl%C3%A4chen.%20Es%20ist%20nur%20eine%20Frage%20der%20Zeit%2C%20bis%20man%20Komponenten%2C%20die%20miteinander%20interagieren%20sollen%2C%20gegenseitig%20bekannt%20macht.%20Diese%20Vorgehensweise%20ist%20limitiert%20und%20au%C3%9Ferdem%20sehr%20aufwendig.%20Wie" title="Google Bookmarks"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
<div id="vgwpixel"></div><h3  class="related_post_title">Andere Beiträge</h3><ul class="related_post"><li>15. Juli 2010 -- <a href="http://www.wicket-praxis.de/blog/2010/07/15/wicket-flexibilitat-mit-factories/" title="Wicket &#8211; Flexibilität mit Factories">Wicket &#8211; Flexibilität mit Factories</a></li><li>16. Oktober 2009 -- <a href="http://www.wicket-praxis.de/blog/2009/10/16/wicket-component-overview/" title="Wicket Komponentenübersicht">Wicket Komponentenübersicht</a></li><li>29. April 2011 -- <a href="http://www.wicket-praxis.de/blog/2011/04/29/wicket-back-button-detect/" title="Wicket &#8211; Back Button zuverlässig erkennen">Wicket &#8211; Back Button zuverlässig erkennen</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.wicket-praxis.de/blog/2010/01/05/wicket-lose-koppelung-von-komponenten/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wicket Komponentenübersicht</title>
		<link>http://www.wicket-praxis.de/blog/2009/10/16/wicket-component-overview/</link>
		<comments>http://www.wicket-praxis.de/blog/2009/10/16/wicket-component-overview/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 06:57:45 +0000</pubDate>
		<dc:creator>michael</dc:creator>
				<category><![CDATA[Technologie]]></category>
		<category><![CDATA[Wicket]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[listener]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[overview]]></category>
		<category><![CDATA[target]]></category>

		<guid isPermaLink="false">http://www.wicket-praxis.de/blog/?p=166</guid>
		<description><![CDATA[Ich habe in den letzten Tagen damit angefangen, die verschiedenen Componenten, die Wicket bereits in dem Basisbibliotheken bietet, zu visualisieren. Den ersten Versuch habe ich noch von Hand durchgeführt, um schnell festzustellen, dass man auf diese Weise nicht besonders schnell vorwärts kommt. Der zweite und damit aktuelle Ansatz ist da schon sehr viel versprechend. Es [...]]]></description>
			<content:encoded><![CDATA[<p>Ich habe in den letzten Tagen damit angefangen, die verschiedenen Componenten, die Wicket bereits in dem Basisbibliotheken bietet, zu visualisieren. Den ersten Versuch habe ich noch von Hand durchgeführt, um schnell festzustellen, dass man auf diese Weise nicht besonders schnell vorwärts kommt. Der zweite und damit aktuelle Ansatz ist da schon sehr viel versprechend. Es werden die Wicket-Quellen geparst und alle Klassendefinitionen eingelesen, die Abhängigkeiten untereinander ermittelt, verschiedene Filter angewendet um die Darstellung auf ein Thema einzugrenzen und das ganze dann mit dem dot-Programm aus dem Graphviz-Paket in ein Diagramm umgewandelt.</p>
<p>Die folgenden Grafiken sind das vorläufige Zwischenergebnis. Es ist nicht auszuschließen, dass es Fehler gibt. Für jeden gemeldeten Fehler bin ich daher sehr dankbar, aber auch Anregungen sind natürlich herzlich willkommen.</p>
<div id="attachment_161" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-comp.gv.jpg"><img class="size-medium wp-image-161" title="wicket-comp.gv" src="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-comp.gv-450x365.jpg" alt="Wicket Kompontenten - Basis" width="450" height="365" /></a>
<p class="wp-caption-text">Wicket Kompontenten &#8211; Basis</p>
</div>
<div id="attachment_162" class="wp-caption aligncenter" style="width: 389px"><a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-comp-ext.gv.jpg"><img class="size-medium wp-image-162" title="wicket-comp-ext.gv" src="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-comp-ext.gv-379x450.jpg" alt="Wicket Komponenten inklusive Extensions" width="379" height="450" /></a>
<p class="wp-caption-text">Wicket Komponenten inklusive Extensions</p>
</div>
<div id="attachment_164" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-model.gv.jpg"><img class="size-medium wp-image-164" title="wicket-model.gv" src="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-model.gv-450x406.jpg" alt="Wicket Modelle" width="450" height="406" /></a>
<p class="wp-caption-text">Wicket Modelle</p>
</div>
<div id="attachment_160" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-behavior.gv.jpg"><img class="size-medium wp-image-160" title="wicket-behavior.gv" src="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-behavior.gv-450x97.jpg" alt="Wicket Behavior" width="450" height="97" /></a>
<p class="wp-caption-text">Wicket Behavior</p>
</div>
<div id="attachment_163" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-listener.gv.jpg"><img class="size-medium wp-image-163" title="wicket-listener.gv" src="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-listener.gv-450x219.jpg" alt="Wicket Listener" width="450" height="219" /></a>
<p class="wp-caption-text">Wicket Listener</p>
</div>
<div id="attachment_165" class="wp-caption aligncenter" style="width: 460px"><a href="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-requestTarget.gv.jpg"><img class="size-medium wp-image-165" title="wicket-requestTarget.gv" src="http://www.wicket-praxis.de/blog/wp-content/uploads/2009/10/wicket-requestTarget.gv-450x176.jpg" alt="Wicket RequestTarget" width="450" height="176" /></a>
<p class="wp-caption-text">Wicket RequestTarget</p>
</div>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li class="sociablefirst"><a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2009%2F10%2F16%2Fwicket-component-overview%2F&amp;title=Wicket%20Komponenten%C3%BCbersicht&amp;bodytext=Ich%20habe%20in%20den%20letzten%20Tagen%20damit%20angefangen%2C%20die%20verschiedenen%20Componenten%2C%20die%20Wicket%20bereits%20in%20dem%20Basisbibliotheken%20bietet%2C%20zu%20visualisieren.%20Den%20ersten%20Versuch%20habe%20ich%20noch%20von%20Hand%20durchgef%C3%BChrt%2C%20um%20schnell%20festzustellen%2C%20dass%20man%20auf%20diese" title="Digg"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2009%2F10%2F16%2Fwicket-component-overview%2F" title="Sphinn"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2009%2F10%2F16%2Fwicket-component-overview%2F&amp;title=Wicket%20Komponenten%C3%BCbersicht&amp;notes=Ich%20habe%20in%20den%20letzten%20Tagen%20damit%20angefangen%2C%20die%20verschiedenen%20Componenten%2C%20die%20Wicket%20bereits%20in%20dem%20Basisbibliotheken%20bietet%2C%20zu%20visualisieren.%20Den%20ersten%20Versuch%20habe%20ich%20noch%20von%20Hand%20durchgef%C3%BChrt%2C%20um%20schnell%20festzustellen%2C%20dass%20man%20auf%20diese" title="del.icio.us"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2009%2F10%2F16%2Fwicket-component-overview%2F&amp;t=Wicket%20Komponenten%C3%BCbersicht" title="Facebook"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2009%2F10%2F16%2Fwicket-component-overview%2F&amp;title=Wicket%20Komponenten%C3%BCbersicht" title="Mixx"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.wicket-praxis.de%2Fblog%2F2009%2F10%2F16%2Fwicket-component-overview%2F&amp;title=Wicket%20Komponenten%C3%BCbersicht&amp;annotation=Ich%20habe%20in%20den%20letzten%20Tagen%20damit%20angefangen%2C%20die%20verschiedenen%20Componenten%2C%20die%20Wicket%20bereits%20in%20dem%20Basisbibliotheken%20bietet%2C%20zu%20visualisieren.%20Den%20ersten%20Versuch%20habe%20ich%20noch%20von%20Hand%20durchgef%C3%BChrt%2C%20um%20schnell%20festzustellen%2C%20dass%20man%20auf%20diese" title="Google Bookmarks"><img src="http://www.wicket-praxis.de/blog/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
</ul>
</div>
<div id="vgwpixel"></div><h3  class="related_post_title">Andere Beiträge</h3><ul class="related_post"><li>15. Juli 2010 -- <a href="http://www.wicket-praxis.de/blog/2010/07/15/wicket-flexibilitat-mit-factories/" title="Wicket &#8211; Flexibilität mit Factories">Wicket &#8211; Flexibilität mit Factories</a></li><li>5. Januar 2010 -- <a href="http://www.wicket-praxis.de/blog/2010/01/05/wicket-lose-koppelung-von-komponenten/" title="Wicket &#8211; lose Koppelung von Komponenten">Wicket &#8211; lose Koppelung von Komponenten</a></li><li>10. Dezember 2009 -- <a href="http://www.wicket-praxis.de/blog/2009/12/10/praxisbuch-wicket-ubersicht/" title="Praxisbuch Wicket &#8211; Übersicht">Praxisbuch Wicket &#8211; Übersicht</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.wicket-praxis.de/blog/2009/10/16/wicket-component-overview/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 17/64 queries in 0.084 seconds using disk: basic
Object Caching 1130/1175 objects using disk: basic

Served from: www.wicket-praxis.de @ 2012-02-06 20:40:21 -->
