Wednesday, May 14, 2008

Tapestry5 NetBeans Quickstart

I have been following the development of Tapestry 5 closely for the last couple of months, and I even got the first Tapestry 5 book that came out. I'm a big Tapestry fan, and I've been looking forward to the new Tapestry 5 release. I even lucked out and had a chance to talk to Howard in person:



One of the cool things that keeps drawing me towards Tapestry is the goal to make it really easy and intuitive to work with. One of the goals that I remember hearing for Tapestry 5 was to make it that easy, that it would compete more w/ Grails & Rails and not so much w/ traditional Java Web app frameworks (e.g. Struts, Struts2, etc)

However, when I first took a look at Tapestry 5, I was a little disappointed by the six line Maven command that one had to type in when starting a new project (e.g. see http://tapestry.apache.org/tapestry5/tutorial1/first.html):

mvn archetype:create
-DarchetypeGroupId=org.apache.tapestry
-DarchetypeArtifactId=quickstart
-DgroupId=org.apache.tapestry
-DartifactId=tutorial1
-DpackageName=org.apache.tapestry.tutorial


Compare that with Grails:


grails create-app

Welcome to Grails 1.0 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/local/java/grails
Application name not specified. Please enter:
FooApp
---------------
[propertyfile] Updating property file: /home/polrtex/temp/FooApp/application.properties
Created Grails Application at /home/polrtex/temp/FooApp



It is true that one doesn't create an application all that often, and copy-and-pasting
these initial 5-6 lines would not be that big of a deal. However, for a newcomer, the Tapestry 5 experience has to be really smooth and starting a new app should be a breeze.

So, you would say, what does this have to do with NetBeans ?

Here it comes. As usual, NetBeans rocks everyone's socks, by lowering the entry barrier into starting an application. Here are the first steps (equivalent to the first two pages of the Tapestry tutorial : http://tapestry.apache.org/tapestry5/tutorial1/env.html). Here is what you need to do:
( Assuming that you already have a good install of NetBeans 6.1).

  1. Install the NetBeans Maven plugin by going into Tools -> Plugins . Type "maven" in the upper-left corner search box and install the plugin. The result should look something like this:
  2. Create a new Maven project
  3. Expand the "Archetypes from remote Maven repositories" and scroll down to find the Tapestry5 quickstart archetype . You might want to pay close attention to the description and select the latest archetypes (in my case, for 5.0.11)
  4. Now that you have the nice wizard, fill out the configuration attributes to specify the group id, the location of the project, the name of the project, etc.
  5. When you hit Finish, Maven will start downloading all the dependencies and setting up your project.
  6. Your new and shiny project is ready to go. Go into the project Properties and select your desired server to deploy to:
  7. Run the project from the project context menu and you're up and running !!!!



One very cool option that makes the Tapestry 5 setup almost identical to the Grails setup is the ability to run the application in Jetty by going to the command line and running:
mvn jetty:run

The upside of doing this is that after you run it, there is no deployment step. Tapestry supports reloading of the page templates as well as the page classes. As a result, whenever you make a change to a page, you can save it, refresh the browser and see the changes . Similarly, when you make a change to a class, compile it and the changes are immediately visible to the application. Such a setup really cuts down on waiting for the app to deploy.

So now, looking back a little bit, this setup is indeed very competitive w/ the Grails setup. In Grails, you would download the Grails distribution, and then would run the "grails create-app" command to create the new project. Grails would then prompt you for some properties (e.g. project name) and you're done. For Tapestry, it's quite similar; however, instead of downloading the Tapestry distribution, you would simply download Maven2 (or in the case of NetBeans, you would install the NetBeans plugin). Even better for Tapestry, if you already have Maven install, then starting a new app becomes a zero cost operation : you just specify the command line args (or better yet, use NetBeans to create the new app) and you're on your way, all dependencies already in place.

So, so far it's a tie between Grails and Tapestry. Grals vs Tapestry = 1:1

Enjoy your shiny and new Tapestry 5 app in NetBeans !!!

Tuesday, May 13, 2008

Scrapbooking Epiphany- Part VII

I cannot believe it! I have finished it!!! Finally!!!Twenty five pages biography in 8 days precisely!!! It's a miracle people, a miracle!
Somebody would think that a small person like this didn't live enough to fill 25 pages of scrapbook biography, but this is not true! There were so many interesting things I wanted to include, that I had hard time cutting the total number of pages down to 25 :-)
But it is official- my very first scrapbook is ready!
I really hope they like it at the school , but I hope even more that my grandchildren appreciate it one day as well :-)

- Halloween 2007:


- Winter fun

- The "finishing touch"


Now that I am finished with this, I can breath a little more easily. I have only to figure out what kind of cake I will make him and we are all set :-)
I'll keep you posted! :-)
You can check the previous scrapbook pages here.

Sunday, May 4, 2008

Scrapbook - Almost there! VI part

Since today we were invited on a BBQ, I wasn't sure I would have time to do any pages for the scrapbook. But, luckily ( and thanks to my husband) I've set aside couple of hours and the result is 4 pages down!!! Can you believe, I have only 3 pages to go! This seems so unreal, considering how desperate I was when I first started!
I am actually quite happy how the pages turned out! One of the first ones that I can say I like!
Perhaps I would do better for my daughter's album, but for now it will do.

Here are the new pages:
- The 4th Birthday


- pets and events 2007 ( the spirals are made from wool thread, but it is not recognizable on the pictures. Sorry, I still haven't bought the new camera I wanted :-(



- Travel 2007

- sister's Birthday ( I made the page design the same design I made the actual cake)

Here is the previous post.

Scrapbooking progress part V

Here I am again! I can almost see the finish line! 17 pages down, 8 to go! Not bad for a week of work.
Here are the new pages that I made yesterday:

-Getting the news that we are pregnant

- the 3rd Birthday celebration

-Little sister is born


- Our home


- Friends


Here is the link to the previous part.

Saturday, May 3, 2008

NASA Birthday Invitations

Remember the Birthday invitations I published couple of days ago?
I am talking about these:

Well, I had trouble finding the right envelope for them, since the size wasn't standard and I wanted it to be somehow connected to the whole " space Birthday" idea.
So...while browsing in the store today it suddenly hit me! I can make them look like NASA letters ( not that I've ever actually seen one, but a party equivalent of them)!!!
And that is what I came up with, whit a 6/9 business envelopes, a red marker, Open Office Draw and a monochromatic printer.


If I just had color printer I would have saved so much more time! But unfortunately when we bought ours ( not that is bad, it's working great actually) we thought that we would never need to print anything in color.
Here is one of the "stamps" up close":

Now I have to think of a cake to go with these and I would be fine for the Birthday :-).
That's all for today, folks!

Friday, May 2, 2008

Quick File Chooser in NetBeans 6.1

I'm on a roll today, but I thought I'd drop this tip as well.

I'm a big fan of the NetBeans Quick File Chooser plugin, it makes it oh-so-easy to open up a file without having to detach my fingers from the keyboard. So, if you Google for the plugin, you'll find Tor's recommendation of the same; however, you can't find it on the Plugin Center . So, what if you really wanted to use the Quick File Chooser, in NetBeans 6.1, what should you do ? In the past, I've always copied the plugin with my netbeans preferences from the previous version that I've used, and it's worked OK. However, I decided on a clean NetBeans install on my home laptop, and I couldn't get my hands on it.

So, I followed a tip from Octavian's blog , added the Netbeans Latest Build update center, and ... voila, the Quick File Chooser is in the list of available plugins. Since it doesn't depend on any of the features of 6.1+ code, it works great in 6.1 as well.

Scrapbook- I see the light!!! ( part IV)

Thanks to a lovely lady from a Bulgarian forum with the beautiful nickname Despina, I have many ideas how to make the pages that I have left easier, faster and better!
Well, sleeping would definitely help, but if not else, I feel a little bit more confident now that I can finish them on time.
Here is what I made tonight, FORTUNATELY before 10 pm, and I think it shows:
- the 2nd Birthday


- "Daddy and I together again"

- First Halloween in the US

Tomorrow hopefully I will have a lot more to show, since I have to finish at least 6 pages to be on track.
12 down, 13 to go! Here is the previous part (III).

Groovy HTML Encode

I kinda thought that in the past I had used a special Groovy method to encode something as HTML. I mostly need that when I need to post something to Blogger (which completely baffles me - why isn't there a better way of copy-and-pasting html/xml in blogger content ???) . I do know that in Grails, there are a couple of special methods that you can use if you want to encode something as html, json, or something else. However, I'm not using Grails right now, so that's not always the best option.

After wasting 15 minutes trying to remember exactly how I did it in the past, I realized that I was using StringEscapeUtils from Apache commons-lang. So, having remembered that, it just works like magic, here is what I use to convert my xml/html samples in order to post them on Blogger:

this.class.classLoader.rootLoader.addURL(new File("/usr/local/java/grails-1.0/lib/commons-lang-2.1.jar").toURL())


xml = '''
<module id="id" version="0.0.1" package="package"> </module>
'''
org.apache.commons.lang.StringEscapeUtils.escapeHtml(xml).split("\n").each() {println it }

, which outputs the following :
&lt;module id=&quot;id&quot; version=&quot;0.0.1&quot; package=&quot;package&quot;&gt; &lt;/module&gt;

, which is what I paste into blogger and it works like magic !!!

No more running around like a headless chicken trying to find some service online that will convert my html/xml snippets !


Freeform projects NetBeans JUnit test results : binding output to source code

As I had mentioned in a prior post a while back, it is pretty straightforward to bind the output of a Freeform Project JUnit task to the NetBeans JUnit test results. However, there are a couple of minor tweaks that I find myself making and forgetting, so, I thought I'd drop a blog entry, even just as a reminder for myself.

First, make sure that the JUnit task as a showoutput="true" attribute and has a formatter that explicitly states that doesn't use a file, e.g.

<formatter usefile="false" type="brief"/>

Emphasis on not using a file : e.g. you can use an xml formatter and it would work; however, if you don't specify the usefile="false" attribute, everything goes to the file and NetBeans doesn't get a chance to capture the output and display the results in a nice JUnit test results tree. As a result, the best combination ends up being a combination of a xml formatter that outputs to a file, and a brief formatter that doesn't, e.g. :


<junit fork="yes" printsummary="withOutAndErr" showoutput="true" errorProperty="test.failed" failureProperty="test.failed" filtertrace="false">
<formatter type="xml">
<formatter usefile="false" type="brief" />
<classpath refid="whatever-path-id">
</classpath>
</junit>

The second important part of working with the JUnit results in NetBeans is to make sure that when a test fails, when you click on the failure in the JUnit results, you want NetBeans to take you to the right line in the source code:

In order to accomplish that, make sure that you properly set the output directory for your test cases in your NetBeans project with the UI or project.xml:

  • In the Project Properties UI


  • In the nbproject/project.xml
...
<java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/2">\n ....
<compilation-unit>
<package-root>test/integration</package-root>
<unit-tests/>
<classpath mode="compile">${test.completion.classpath}</classpath>
<built-to>dest/test/unit</built-to>
<source-level>1.5</source-level>
</compilation-unit>
....
</java-data>
....

Scrapbook dissapoinment- III

I am so disappointed in the way the last pages turn out :-( Working after the kids fall asleep just doesn't work for me. I am so tired by that time, that I can barely keep my eyes open and it definitely shows in the result. I made 9 pages so far, 16 left.
When I finish it I would probably redo it later, because I don't like the state of it now :-(.
The Baptism page:

I made a pattern with a pencil on the black cross and it looked like engraved, but I only shows on this picture.


The " mommy and daddy's little helper" page.


The "Travel before the age of 2 " page:

The 2004 Christmas page:

Well, that's it :-(
Here are the first and second part.

Popular Posts

Related Posts with Thumbnails