<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Removing Fragile String Expressions From Wicket Code</title>
	<atom:link href="http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/</link>
	<description>A comprehensive guide for Java developers building Wicket-based web applications</description>
	<lastBuildDate>Wed, 07 Jul 2010 23:51:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Hielke Hoeve</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-676</link>
		<dc:creator>Hielke Hoeve</dc:creator>
		<pubDate>Fri, 28 May 2010 07:17:00 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-676</guid>
		<description>Try using Bindgen in Eclipse in a project with over 1k entity classes and try to refactor something (or even better change generics). Coffee and lunch anyone? :)

Half the time Bindgen does not understand generics and just leaves the building...</description>
		<content:encoded><![CDATA[<p>Try using Bindgen in Eclipse in a project with over 1k entity classes and try to refactor something (or even better change generics). Coffee and lunch anyone? :)</p>
<p>Half the time Bindgen does not understand generics and just leaves the building&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bert Bruynooghe</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-673</link>
		<dc:creator>Bert Bruynooghe</dc:creator>
		<pubDate>Thu, 13 May 2010 20:45:25 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-673</guid>
		<description>I tried something similar using an own class that can be used as follows:
new AccessorModel(modelOrObjectItself){{
  registrar.getFoo();
  registrar.setFoo(null);
}} where registrar is of the type InputType, thus allowing auto-complete features of the IDE.  I was also thinking of allowing chaining expressions, but as I wasn&#039;t able to use final classes as InputType, I gave up. However, today I discovered PowerMock, and they seem to have the solution to my problem. Is this a path worth investigating, and if yes, is anybody interested in trying to work this out in an small open source thingie?</description>
		<content:encoded><![CDATA[<p>I tried something similar using an own class that can be used as follows:<br />
new AccessorModel(modelOrObjectItself){{<br />
  registrar.getFoo();<br />
  registrar.setFoo(null);<br />
}} where registrar is of the type InputType, thus allowing auto-complete features of the IDE.  I was also thinking of allowing chaining expressions, but as I wasn&#8217;t able to use final classes as InputType, I gave up. However, today I discovered PowerMock, and they seem to have the solution to my problem. Is this a path worth investigating, and if yes, is anybody interested in trying to work this out in an small open source thingie?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ivaynberg</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-661</link>
		<dc:creator>ivaynberg</dc:creator>
		<pubDate>Fri, 15 Jan 2010 04:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-661</guid>
		<description>@Paul, i would guess that while Entities take up a large usecase space for this kind of object navigation they still only account for about 60%. In Wicket you still bind a lot to non-entities such as DTOs or to Component properties.

The JPA2 solution doesnt chain properties :( so you cant say new PersonBinding().address().state().code(), instead you woul dhave to do something like:
new EntityBinding(Person_.address, Address_.state, State_.code) which is more error prone. And as you said, it only works for Entities.</description>
		<content:encoded><![CDATA[<p>@Paul, i would guess that while Entities take up a large usecase space for this kind of object navigation they still only account for about 60%. In Wicket you still bind a lot to non-entities such as DTOs or to Component properties.</p>
<p>The JPA2 solution doesnt chain properties :( so you cant say new PersonBinding().address().state().code(), instead you woul dhave to do something like:<br />
new EntityBinding(Person_.address, Address_.state, State_.code) which is more error prone. And as you said, it only works for Entities.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-660</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Thu, 14 Jan 2010 15:55:22 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-660</guid>
		<description>If you&#039;re using hibernate 3.5, then I don&#039;t think you need bindgen to accomplish this, at least when dealing with entities which is probably most of the time. It has it&#039;s static typesafe metamodel generator. Tutorial to set it up can be found here: http://relation.to/Bloggers/HibernateStaticMetamodelGeneratorAnnotationProcessor

I&#039;ve just been glancing at it so I don&#039;t know if this can be a complete solution. If it can just be used directly with the PropertyModel, or even if you can get complex property strings out of it (or even if you&#039;d want to).</description>
		<content:encoded><![CDATA[<p>If you&#8217;re using hibernate 3.5, then I don&#8217;t think you need bindgen to accomplish this, at least when dealing with entities which is probably most of the time. It has it&#8217;s static typesafe metamodel generator. Tutorial to set it up can be found here: <a href="http://relation.to/Bloggers/HibernateStaticMetamodelGeneratorAnnotationProcessor" rel="nofollow">http://relation.to/Bloggers/HibernateStaticMetamodelGeneratorAnnotationProcessor</a></p>
<p>I&#8217;ve just been glancing at it so I don&#8217;t know if this can be a complete solution. If it can just be used directly with the PropertyModel, or even if you can get complex property strings out of it (or even if you&#8217;d want to).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ivaynberg</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-647</link>
		<dc:creator>ivaynberg</dc:creator>
		<pubDate>Mon, 07 Dec 2009 18:17:06 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-647</guid>
		<description>@Francisco

It is possible with a PropertyModel. BindingModel is exactly the same as the PropertyModel, the only exception being that it uses a type-safe expression instead of a string to specify the property.</description>
		<content:encoded><![CDATA[<p>@Francisco</p>
<p>It is possible with a PropertyModel. BindingModel is exactly the same as the PropertyModel, the only exception being that it uses a type-safe expression instead of a string to specify the property.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francisco</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-646</link>
		<dc:creator>Francisco</dc:creator>
		<pubDate>Mon, 07 Dec 2009 18:03:02 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-646</guid>
		<description>Alright, I see what you mean.

In that case I would just do:

object personModel extends IModel[Person] {         
   var p = Person(Address(&quot;first&quot;))
   def getObject = p
   def setObject(p: Person) = { this.p = p }
}


model.getObject
// here i would obtain first

personModel.setObject(Person(Address(&quot;second&quot;)))

model.getObject
// here i would obtain second

But most probably I can&#039;t see in which cases I would benefit from that (a &quot;generic safe street model&quot; :). And afaik that is not possible with PropertyModel, or is it?

Anyways, in general I tend to avoid setters whenever possible... they&#039;re evil =)</description>
		<content:encoded><![CDATA[<p>Alright, I see what you mean.</p>
<p>In that case I would just do:</p>
<p>object personModel extends IModel[Person] {<br />
   var p = Person(Address(&#8220;first&#8221;))<br />
   def getObject = p<br />
   def setObject(p: Person) = { this.p = p }<br />
}</p>
<p>model.getObject<br />
// here i would obtain first</p>
<p>personModel.setObject(Person(Address(&#8220;second&#8221;)))</p>
<p>model.getObject<br />
// here i would obtain second</p>
<p>But most probably I can&#8217;t see in which cases I would benefit from that (a &#8220;generic safe street model&#8221; :). And afaik that is not possible with PropertyModel, or is it?</p>
<p>Anyways, in general I tend to avoid setters whenever possible&#8230; they&#8217;re evil =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ivaynberg</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-645</link>
		<dc:creator>ivaynberg</dc:creator>
		<pubDate>Mon, 07 Dec 2009 16:48:09 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-645</guid>
		<description>@Francisco not really sure, maybe its easier with code :)
&lt;pre&gt;
Person bob=new Person(&quot;bob&quot;);
Person john=new Person(&quot;bob&quot;);

IModel model=new BindingModel(person, new 
PersonBinding().address().street());

model.getObject() &lt;== bob.getAddress().getStreet();
model.setObject(john);
model.getObject() &lt;== john.getAddress().getStreet();
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>@Francisco not really sure, maybe its easier with code :)</p>
<pre>
Person bob=new Person("bob");
Person john=new Person("bob");

IModel model=new BindingModel(person, new
PersonBinding().address().street());

model.getObject() &lt;== bob.getAddress().getStreet();
model.setObject(john);
model.getObject() &lt;== john.getAddress().getStreet();
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francisco</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-644</link>
		<dc:creator>Francisco</dc:creator>
		<pubDate>Mon, 07 Dec 2009 14:19:53 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-644</guid>
		<description>Hi Igor,

Sure. I haven&#039;t really thought about that, but I guess it could be solved with an implicit conversion?

So instead of:

val model = new SafePropertyModel(p.address.street)

by introducing the following (or mixing-in a trait with it):

implicit def m2o[A](model: IModel[A]): A = model.getObject

we can now invoke the expression on a model:

// this is a concrete instance of a person model
object personModel extends IModel[Person] {
  def getObject = Person(Address(&quot;My model&#039;s street&quot;))
}

val model = new SafePropertyModel(personModel.address.street)

Now,

assert(model.getObject == &quot;My model&#039;s street&quot;)
println(model.getObject)

All it does is convert under the hood a model to an object when needed. Is this what you meant?

Francisco</description>
		<content:encoded><![CDATA[<p>Hi Igor,</p>
<p>Sure. I haven&#8217;t really thought about that, but I guess it could be solved with an implicit conversion?</p>
<p>So instead of:</p>
<p>val model = new SafePropertyModel(p.address.street)</p>
<p>by introducing the following (or mixing-in a trait with it):</p>
<p>implicit def m2o[A](model: IModel[A]): A = model.getObject</p>
<p>we can now invoke the expression on a model:</p>
<p>// this is a concrete instance of a person model<br />
object personModel extends IModel[Person] {<br />
  def getObject = Person(Address(&#8220;My model&#8217;s street&#8221;))<br />
}</p>
<p>val model = new SafePropertyModel(personModel.address.street)</p>
<p>Now,</p>
<p>assert(model.getObject == &#8220;My model&#8217;s street&#8221;)<br />
println(model.getObject)</p>
<p>All it does is convert under the hood a model to an object when needed. Is this what you meant?</p>
<p>Francisco</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ivaynberg</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-638</link>
		<dc:creator>ivaynberg</dc:creator>
		<pubDate>Wed, 02 Dec 2009 04:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-638</guid>
		<description>@Nico mind elaborating? im not sure i get what you mean. the problem is that java has no way to express a chain of method calls easily, this is why we resort to things like strings...</description>
		<content:encoded><![CDATA[<p>@Nico mind elaborating? im not sure i get what you mean. the problem is that java has no way to express a chain of method calls easily, this is why we resort to things like strings&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ivaynberg</title>
		<link>http://wicketinaction.com/2009/11/removing-fragile-string-expressions-from-wicket-code/comment-page-1/#comment-637</link>
		<dc:creator>ivaynberg</dc:creator>
		<pubDate>Wed, 02 Dec 2009 03:52:27 +0000</pubDate>
		<guid isPermaLink="false">http://wicketinaction.com/?p=470#comment-637</guid>
		<description>@Francisco if i read your code correctly there is a pretty huge gap left out that your SafePropertyModel does not take care of...

your code says p.address.street which, with my non-existant knowledge of all things Scala, creates a lambda expression to be avaluated later? but, the expression is tied to a specific instance of the root object &quot;p&quot;. can you show an easy way to achieve the same but with interchangeable &quot;p&quot;? so in other words:

&lt;pre language=&quot;java&quot;&gt;
new BindingModel(personModel, new PersonBinding().address.street())
&lt;/pre&gt;

the above creates a &quot;address.street&quot; expression that is evaluated against which ever &quot;p&quot; is provided by the personModel...</description>
		<content:encoded><![CDATA[<p>@Francisco if i read your code correctly there is a pretty huge gap left out that your SafePropertyModel does not take care of&#8230;</p>
<p>your code says p.address.street which, with my non-existant knowledge of all things Scala, creates a lambda expression to be avaluated later? but, the expression is tied to a specific instance of the root object &#8220;p&#8221;. can you show an easy way to achieve the same but with interchangeable &#8220;p&#8221;? so in other words:</p>
<pre language="java">
new BindingModel(personModel, new PersonBinding().address.street())
</pre>
<p>the above creates a &#8220;address.street&#8221; expression that is evaluated against which ever &#8220;p&#8221; is provided by the personModel&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
