<?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>Javatech &#187; Web Frameworks</title>
	<atom:link href="http://javatech.org/category/web-frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://javatech.org</link>
	<description>The Bleeding Edge of Java Technology</description>
	<lastBuildDate>Wed, 24 Jun 2009 22:30:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Discovering Roo</title>
		<link>http://javatech.org/2009/06/discovering-roo/</link>
		<comments>http://javatech.org/2009/06/discovering-roo/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 20:51:49 +0000</pubDate>
		<dc:creator>deevis</dc:creator>
				<category><![CDATA[Application Servers]]></category>
		<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Spring]]></category>
		<category><![CDATA[Web Frameworks]]></category>
		<category><![CDATA[aspectj]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[roo]]></category>

		<guid isPermaLink="false">http://javatech.org/?p=77</guid>
		<description><![CDATA[I decided to follow along with the presentation given by Ben Alex during the SpringOne Keynote Address by Rod Johnson.
First &#8211; I have to install Roo and get the Roo shell up and running.  I&#8217;m really excited at this point because Roo does look really cool &#8211; really RAD!
So I download Roo and explode it [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to follow along with the presentation given by Ben Alex during the <a title="SpringOne Keynote Address by Rod Johnson" href="http://www.infoq.com/presentations/SpringOne-Keynote-Rod-Johnson" target="_self">SpringOne Keynote Address by Rod Johnson</a>.</p>
<p>First &#8211; I have to install Roo and get the Roo shell up and running.  I&#8217;m really excited at this point because Roo does look really cool &#8211; really RAD!</p>
<p>So I <a title="Download Roo 1.0.0.M1" href="http://s3.amazonaws.com/dist.springframework.org/milestone/ROO/spring-roo-1.0.0.M1.zip" target="_self">download Roo</a> and explode it out to where I explode all of my 3rd party tools and then open <a title="cygwin" href="http://www.cygwin.com/">cygwin</a> (I&#8217;m on Windows and am trying hard to move away from Dos&#8230;) and navigate to the new directory.  I find a bin directory with two scripts in it: roo.bat and roo.sh.  Sweet!  They have a linux version ( cygwin == linux in many ways ).  So I run roo.sh and get:</p>
<p><strong>./roo.sh</strong></p>
<pre style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 800px; height: 204px; text-align: left;" dir="ltr">Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/roo/bootstrap/Bootstrap
Caused by: java.lang.ClassNotFoundException: org.springframework.roo.bootstrap.Bootstrap
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Could not find the main class: org.springframework.roo.bootstrap.Bootstrap.  Program will exit.</pre>
<p>OK &#8211; take a step back.  What have I done wrong here.</p>
<p>I back up a directory and also try <strong>./bin/roo.sh</strong>.  I look in the readme.txt and create the symlink for install on linux that they recommend:</p>
<p><strong>ln -s /path/to/roo/bin/roo.sh /usr/bin/roo</strong></p>
<p>I type in &#8216;roo&#8217; and get the same BootStrap Exception.</p>
<p>So then I invoke the wisdom of Google and learn that most everyone who encounters this error gets it because they are in Dos and are working in a different drive than where Roo is installed.  I&#8217;m on the same drive &#8211; but it&#8217;s not working in cygwin!  No hits on this somehow?!?  I find some other results which want me to additionally set an environment variable ROO_HOME.  I do this by running from the Roo install directory ( above bin, that is&#8230;):</p>
<p><strong>export ROO_HOME=`pwd`</strong></p>
<p><strong>env | grep ROO</strong></p>
<p>I still get the same problem (ClassNotFoundException: org.springframework.roo.bootstrap.Bootstrap), so I cave and go into a Dos prompt.  Well, first I add %ROO_HOME%\bin to my path, and *then* go into a Dos prompt.  I run &#8216;roo&#8217; and get the same Bootstrap Exception again.  But now, I am on the wrong drive, and cd to the same drive I installed Roo on &#8211; now things are working.</p>
<p>Time to even start using Roo in this example : <strong>15 minutes</strong></p>
<p>So, Roo is working now &#8211; I have a shell up and running.  I&#8217;m stoked because it really is cool.  It has &#8216;hint&#8217; as a keyword and tab-based auto-completion which is contextual &#8211; it auto-completes the correct things at the correct times.<br />
<a title="Creating a Project with Roo" href="http://javatech.org/article_yet_to_be_written">Creating a project with Roo</a> is a very nice experience : <strong>3 minutes</strong></p>
<p>I already have maven2 installed so I&#8217;m able to exit out of Roo and run &#8216;mvn eclipse:eclipse&#8217; and import the project into Eclipse : <strong>2 minute</strong>s</p>
<p>Wow, now we&#8217;re flying.  Except, wait, there a bunch of &#8220;.aj&#8221; files in my project.  Cool, <a title="Spring Roo Leverages AspectJ" href="http://javatech.org/article_yet_to_be_written">Roo is leveraging AspectJ</a>.  Suck, I don&#8217;t have AJDT plugin configured for Eclipse and I&#8217;m missing a bunch of the stuff Roo has added to my project ( 9 .aj files in all ).  Thinking this might not matter, I run the JUnitTest that Roo created for my project and see only 1 test being run &#8211; the demo has a bunch of tests being run ( added via AspectJ ).  Also, when I auto-complete on my entity class I created, I don&#8217;t get any of the framework added static methods.  Translation: I need to install the AJDT plugin for Eclipse: <strong>10 minutes</strong> ( http://download.eclipse.org/tools/ajdt/34/update ).</p>
<p>Now things are good to go &#8211; I now see the out-of-the box static methods added to my domain class ( Choice.java ).   And now when I run the JUnitTest I see that 8 new tests have been added and run.  But there&#8217;s something else stinky in the state of Denmark!</p>
<pre style="border: 1px inset; margin: 0px; padding: 6px; overflow: auto; width: 800px; height: 40px; text-align: left;" dir="ltr">IllegalStateException: Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?</pre>
<p>No, the SpringAspects JAR is *NOT* configured as an AJC/AJDT aspects library!  I don&#8217;t know what the SpringAspects JAR is nor what it means to configure it as an AJC/AJDT aspects library.  Basically, this means you need to select the spring-aspects.jar to be in the Aspect Path of the AspectJ Build configuration of the project.  A picture is worth a 1,000 words here</p>
<div id="attachment_84" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-84" title="aspectj_spring_aspects_configuration" src="http://javatech.org/wp-content/uploads/2009/06/aspectj_spring_aspects_configuration-300x170.jpg" alt="Adding spring-aspects.jar to AspectJ Build path" width="300" height="170" /><p class="wp-caption-text">Adding spring-aspects.jar to AspectJ Build path</p></div>
<p><strong>10 minutes</strong></p>
<p>So, we&#8217;re up to 40 minutes of time spent when the whole thing up until now should only be 5 minutes.</p>
<p>But wait, there&#8217;s more.  Now I find that I don&#8217;t have setters being woven into my Choice.java class by the Choice_Roo_Javabean.aj aspect.  I see the correct code in the aspect, but Eclipse&#8217;s autocomplete and the actual compilation fail when I attempt to access new Choice().setNamingChoice().    I can deal with this later because I&#8217;ve got to get on with the demo.</p>
<p>Next up &#8211; Roo will automatically update the companion aspect files it creates as new properties are added to the domain entity.  That is, if I simply add a new property called &#8216;description&#8217; to my entity, and I have roo running in the background, then the Choice_Roo_Javabean.aj is automatically updated with the new getter/setter methods, and the Choice_Roo_ToString.aj is updated to include description.  SUPER COOL.</p>
<p>On a tangent, it is not mandatory that these woven aspects dictate the toString and javabean parts of the entity class.  The class has annotations in it to specify that the framework will handle these concerns: @RooJavaBean, @RooToString.  There is also a @RooEntity which adds all of the dao-ish methods to the class.  This is a pattern taken from Grails.</p>
<p>At this point we have an autogenerated JavaBean and a companion TestCase that works.</p>
<p>What about the webapp?  Inside of Roo shell, we can now run:</p>
<p><strong>new controller automatic</strong></p>
<p>With a few arguments to generate the framework jsps, the wiring, the formBackingObject functionality and even the crud forms for the domain entity.  The ordering of the fields on the crud forms matches the order in which they appear in the java file.  Changing the order of properties in the java file will change their order in the ToString.aj and crud JSPs as well. <strong>2 minutes</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://javatech.org/2009/06/discovering-roo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Wicket Component Model Explained</title>
		<link>http://javatech.org/2007/10/the-wicket-component-model-explained/</link>
		<comments>http://javatech.org/2007/10/the-wicket-component-model-explained/#comments</comments>
		<pubDate>Tue, 30 Oct 2007 05:25:37 +0000</pubDate>
		<dc:creator>deevis</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Frameworks]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://javatech.org/?p=12</guid>
		<description><![CDATA[Wicket is a Java/HTML approach to building the guts of a J2EE web application, and I must admit that when I first heard of it I was both eagerly excited (to try it) and more than mildly pessimistic (that an application written in Wicket would be maintainable beyond a certain trivial size ).  The [...]]]></description>
			<content:encoded><![CDATA[<p>Wicket is a Java/HTML approach to building the guts of a J2EE web application, and I must admit that when I first heard of it I was both eagerly excited (to try it) and more than mildly pessimistic (that an application written in Wicket would be maintainable beyond a certain trivial size ).  The past few months I&#8217;ve heard only good things about Wicket, and haven&#8217;t heard anything in the negative.  I&#8217;m eager to benchmark it and check it out for performance on the Application Servers, but figure first things first &#8211; let&#8217;s tear it apart, see what makes it tick, and find out what really matters in Wicket.</p>
<p>So, basically everything ( apart from the <strong>WebApplication </strong>itself ) in Wicket is a <strong>Component</strong>.  Now the Wicket Component is no slouch; it&#8217;s a 3,000+ line abstract class with loads of functionality built right in.  I&#8217;ll dig into this base class later, but for now, let&#8217;s focus on the two immediate subclasses of Component: <strong>MarkupContainer </strong>and <strong>WebComponent</strong>.</p>
<p><strong>MarkupContainer</strong>s include things like: <strong>WebPage</strong>, <strong>RedirectPage</strong>, <strong>Form</strong>, <strong>FormComponent</strong>, <strong>FormComponentLabel</strong>, <strong>Button</strong>, <strong>CheckBox</strong>, <strong>TextArea</strong>, and <strong>TextField</strong>.</p>
<p><strong>WebComponent</strong>s include things like: <strong>Image</strong>, <strong>Include</strong>, <strong>Label</strong>.</p>
<p>I&#8217;m surprised, initially, to find controls such as <strong>Button</strong>, <strong>CheckBox</strong>, <strong>TextArea </strong>and <strong>TextField </strong>as <strong>MarkupContainers </strong>and not as <strong>WebComponents</strong>.</p>
<p>Also of interest is that subclassing is used to achieve behavior that might seem best placed in attributes of some of the classes.  For example, to create a hidden input field, I might expect to create a <strong>TextField </strong>instance and set its visible property false.   Instead, <strong>TextField </strong>is subclassed as <strong>HiddenField</strong>.  This is also true for adding password characteristics (<strong>PasswordTextField</strong>) or making the input required (<strong>RequiredTextField</strong>).  This same pattern of subclassing is used most thoroughly for <strong>Links </strong>( <strong>AjaxFallbackLink</strong>, <strong>BookmarkablePageLink</strong>, <strong>DownloadLink</strong>, <strong>PageLink</strong>, <strong>PopupCloseLink</strong>, and <strong>ResourceLink </strong>).</p>
<p>So, there&#8217;s a very rich Component-Model existing within Wicket for creating all the elements you&#8217;ll need on a web page, but where does the web page come from?  For this we look to another subclass of <strong>MarkupContainer</strong>. The class <strong>WebPage </strong>is the primary analog to a conventional webpage.  So much so, that the Wicket convention is actually to sit an HTML file of the same (prefix) name as the (simpleName) of the Java class extending <strong>WebPage</strong>.  That is, if you were to write a new class called FunPage like this:<br />
<code><br />
package org.javatech.wicket.examples;<br />
class FunPage extends WebPage {}<br />
</code></p>
<p>Then you would have an HTML file named FunPage.html located in org/javatech/wicket/examples which would contain the HTML used in rendering the webpage.</p>
<p>Cool.</p>
<p>But this is still a bit too abstract &#8211; should we really bother writing (yet another) Hello World application for Wicket?  No &#8211; there are plenty of them out there.  Instead, let&#8217;s discuss how the Components get added to the WebPage and then how the HTML is able to provide the layout used to create the desired web page.   And since every website since the beginning of time has forms on it, let&#8217;s show how to add a form.</p>
<p><strong>Adding a form using Wicket Components and a Wicket WebPage</strong>:</p>
<p>When I think of an html form, my mind drifts towards thoughts of Maps where the form element&#8217;s names are the keys and the values entered by the user are the corresponding values.  Then there are just a few other lingering details like the form&#8217;s name, whether to use POST or GET, and to what URL the form data should be sent.  Having isolated the Component <strong>Form</strong> as the candidate for the job, I&#8217;m immediately stunned by the Constructor which takes an id and/or an <strong>IModel</strong>.  The id makes sense.  I mean, really, every html element should have one.  But what on god&#8217;s green earth is an <strong>IModel</strong>?  I know one thing, it&#8217;s an interface &#8211; score one for the I-school of thought!  Upon inspection, it turns out that an <strong>IModel </strong>is simply a wrapper for a model object used by a component.  It provides methods to get/set the actual model object and to drill down into a nested model object.  This being learned, I see that it isn&#8217;t required for such humble beginnings as just getting a form to work and shall be forgotten for at least two days now.</p>
<p>So, our first form will be called DemoForm and starts out on the Java side as:<br />
<code><br />
package org.javatech.wicket.pages;</code></p>
<p>import wicket.markup.html.WebPage;<br />
import wicket.markup.html.basic.Label;<br />
import wicket.markup.html.form.Button;<br />
import wicket.markup.html.form.Form;<br />
import wicket.markup.html.form.TextField;</p>
<p>public class DemoForm extends WebPage {</p>
<p>public DemoForm() {<br />
Form f = new Form( &#8220;myForm&#8221; );<br />
f.add( new TextField( &#8220;myTextField&#8221; ));<br />
Button button = new Button(&#8221;mySubmitButton&#8221;);<br />
f.add( button );<br />
f.setDefaultButton( button );<br />
add( f );<br />
}<br />
}<br />
Which should look something like:</p>
<form>
<input type="text" />
<input onclick="alert('Javatech sample');return false;" type="submit" /> </form>
<p>When I start Wicket and hit the URL, I get an exception, because I haven&#8217;t created the appropriate HTML file.<br />
<strong>WicketMessage: Markup of type &#8216;html&#8217; for component &#8216;org.javatech.wicket.pages.LandingPage&#8217; not found</strong></p>
<p>So, it turns out that you need to have EVERY component added in the Java represented in the corresponding HTML.  In this case, the HTML would need to contain:<br />
<code><br />
&lt;form wicket:id="myForm"&gt;<br />
&lt;input wicket:id="myTextField" /&gt;<br />
&lt;input type="submit" wicket:id="mySubmitButton"&gt;&lt;/button&gt;<br />
&lt;/form&gt;<br />
</code></p>
<p>So I gotta admit that my Spidey-sense is tingling at this point.  This has the potential to grow quite ugly &#8211; having to manage the same essential layout in both Java code and in the HTML.  More on that later &#8211; so, now my form comes up and works.<br />
I can type into the textbox and click on the button.  When I do click on the button, however, I&#8217;m taken to a urHell:<br />
<strong>http://localhost:8080/hello_wicket/?wicket:interface=:24:myForm::IFormSubmitListener</strong> &#8211; SAY WHAT?</p>
<p>So, enough suspense.  Here are the remaining hoops that Wicket requires you to jump through:<br />
1) You must have a backing model object for your form.<br />
2) You must explicitly implement onSubmit() on the Form object being used.<br />
3) The onSubmit() method will ( in Java code! ) specify the response page for the form.<br />
4) You must (manually) pass the model object to the Confirmation Page.</p>
<p>We&#8217;ll have a new class called DemoFormModel defined as:</p>
<p><code><br />
package org.javatech.wicket.pages;</code></p>
<p>import java.io.Serializable;</p>
<p>public class DemoFormModel implements Serializable {</p>
<p>private String myTextField;</p>
<p>public String getMyTextField() {<br />
return myTextField;<br />
}</p>
<p>public void setMyTextField(String myTextField) {<br />
this.myTextField = myTextField;<br />
}<br />
}<br />
An instance of DemoFormModel will be instantiated in the constructor of DemoForm and will then be passed ( in the new onSubmit() method ) to the DemoFormConfirmation WebPage.  DemoForm now looks like:</p>
<p><code><br />
package org.javatech.wicket.pages;</code></p>
<p>import wicket.markup.html.WebPage;<br />
import wicket.markup.html.form.Button;<br />
import wicket.markup.html.form.Form;<br />
import wicket.markup.html.form.TextField;<br />
import wicket.model.CompoundPropertyModel;</p>
<p>public class DemoForm extends WebPage {</p>
<p>public DemoForm() {<br />
Form f = new Form( &#8220;myForm&#8221; ) {<br />
@Override<br />
protected void onSubmit() {<br />
DemoFormModel o = (DemoFormModel)getModelObject();<br />
DemoFormConfirmation landingPageSubmission = new DemoFormConfirmation( o );<br />
setResponsePage( landingPageSubmission );<br />
}</p>
<p>};<br />
f.setModel( new CompoundPropertyModel( new DemoFormModel() ));<br />
f.add( new TextField( &#8220;myTextField&#8221; ));<br />
Button button = new Button(&#8221;mySubmitButton&#8221;);<br />
f.add( button );<br />
f.setDefaultButton( button );<br />
add( f );<br />
}<br />
}<br />
The Java and HTML for DemoFormConfirmation look like:</p>
<p>DemoFormConfirmation.java<br />
<code><br />
package org.javatech.wicket.pages;</code></p>
<p>import wicket.markup.html.WebPage;<br />
import wicket.markup.html.basic.Label;</p>
<p>public class DemoFormConfirmation extends WebPage {</p>
<p>public DemoFormConfirmation(DemoFormModel o) {<br />
this.add( new Label( &#8220;myTextField&#8221;, o.getMyTextField() ));<br />
}<br />
}<br />
DemoFormConfirmation.html<br />
<code><br />
You entered:&lt;span wicket:id="myTextField"&gt;&lt;/span&gt;<br />
</code></p>
<p>So, in a mighty big nutshell, we needed to create 5 files to pull off a simple form submission and confirmation:</p>
<p>DemoForm.java, DemoForm.html, DemoFormModel.java, DemoFormConfirmation.java, and DemoFormConfirmation.html.</p>
<p>DemoForm specifies the form, the components on the form, the model object the components will bind to, and the form&#8217;s onSubmit() method.  The onSubmit() method is responsible for retrieving the model object, instantiating the DemoFormConfirmation instance with that object, and finally redirecting to that instance.</p>
<p>Then, DemoForm.html needs to reference the components added in DemoForm.java by the same String id&#8217;s and DemoFormModel.java needs to have properties which match these names.  DemoFormConfirmation.java and DemoFormConfirmation.html have the same sort of coupling but on a smaller scale ( 1 field only ).</p>
<p>The big lesson here is that naming conventions are super important and having a reliable, predictable mechanism for coming up with wicket id&#8217;s is going to be essential.  Fortunately, there are numerous ways to do this with the simplest being a ModelObject first driven development cycle.  Once your ModelObject is created, then it&#8217;s fieldNames should be used verbatim in both the Components added on the Java side and the wicket:id&#8217;s in the HTML.</p>
<p>I&#8217;m not particularly excited about hardcoding site navigation inside of onSubmit() methods in Java code.  I&#8217;ve been completely brainwashed that this should be configurable behavior, but I&#8217;ve seen configurable behavior become a royal pain in the butt and am willing to entertain this backward seeming restriction.  Besides, there are way to dynamically wire this stuff together if one is determined to do so ( custom code at this point in time ).</p>
]]></content:encoded>
			<wfw:commentRss>http://javatech.org/2007/10/the-wicket-component-model-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
