Netbeans5.5Beta2 bundled with JBoss4.0.4 : No way to change server port

Netbeans5.5Beta2 bundled with JBoss4.0.4 : No way to change server port

I’ve been playing a bit with Netbeans5.5, mostly due to Geertjan’s posts (esp. those describing how to build plugins supporting web frameworks). I even started nbtapestrysupport.

So, i’m on a new machine today and having decided to take a look at NB’s plugin support, i head for www.netbeans.org to download the 5.5 version. I’m however sidetracked with the plethora of the available installers… without thinking a lot, i go for the “NetBeans IDE 5.5 Beta 2 + JBoss Application Server 4.0.4 Bundle Installer“.

Installation went smoothly. After updating NB to include the subversion support, I was able to checkout from https://nbtapestrysupport.dev.java.net/svn/nbtapestrysupport/trunk/TapestryPlugin and build & run the project.

My next thought is ‘let’s see how well JBoss integrates’…so, going to the Runtime tab, right-clicking on JBoss and selecting Start results in “port 8080 already in use”. Oh well, there’s a background tomcat instance running on this pc, it shouldn’t be difficult to make jboss use another port, i.e. 7070.

Googling easily produces “change the following file:
server/xxx/deploy/jbossweb-tomcat55.sar/server.xml” and indeed, if i then issue “jboss_dir/bin/run.sh” it picks up the change and it works.

BUT, from within NetBeans it doesn’t and there’s no way to make it work… googling doesn’t help either… it’s as if there’s a hardcoded configuration somewhere inside NB’s JBoss integration code… Let’s look for a workaround then. Right click to “Add Server” and then browse to the JBoss installation folder is quite interesting. NB informs us that the configured port is 7070 (cool!) but also that ‘The domain instance you want to add already exists’ (sad but correct).

My question of course is, since the instance already exists and since it can indeed read the 7070 value, why doesn’t it use it ???

Anyway, I ended up renaming the instance (just a folder rename) which allowed me to add the server in the previously described way. And this leaves us with:

Why, oh why, can’t I delete (or even rename) the original (and non-working) JBoss server registration ???

GREECE – USA : 101 – 95

GREECE – USA : 101 – 95
Yep, it’s basketball and … yep, it’s true!!!!!!

More Dojo Goodies : JavaScript Linker

More Dojo Goodies : JavaScript Linker

I couldn’t resist blogging this… it’s an awesome tool!

Go checkout svn co http://svn.dojotoolkit.org/dojo/trunk/tools/jslinker, read
the instructions at http://svn.dojotoolkit.org/dojo/trunk/tools/jslinker/docs/readme.txt and … use it!

So, let’s say i create a web app that makes use of dojo and of tacos.
Currently, tacos.js is 54kb and dojo is at least 150kb. So, how about reducing this? How about keeping only the functions and the files that are actually called from the html files?

Well, that’s exactly what the JavaScript Linker does.

For my first example, i run

java -Xms8m -Xmx200m -cp jsl.jar:sisc.jar:bcel.jar org.dojo.jsl.top.Top –verbose –prj jsl.prj –sources ../tests/test_tacos.html
and was left with a 2.3kb dojo.js and a 6.3kb tacos.js

Doesn’t this rock??? Thx dojo & Well done to everyone involved.

Tapestry in press – Beginning POJOs

Tapestry in press – Beginning POJOs

I recently came across
Beginning POJOs: Lightweight Java Web Development Using Plain Old Java Objects in Spring, Hibernate, and Tapestry. From the reviews i’ve found, it looked like a nice book and since it does contain a whole chapter on Tapestry, I thought it would be nice to add it in Tapestry‘s site.

So, in order to fill in some (Tapestry related) descriptions, I contacted the author, Brian Sam-Bodden, requesting a detailed table of contents for that chapter. I was pleasantly surprised with Brian’s reply: a 2MB email containing all 70 pages of that chapter – and all this so that I can write a few lines of description… Wow, thanks Brian!

Anyway, the Tapestry chapter is quite interesting, covering Tapestry 4.0.x versions. It starts by describing installation and configuration of the framework, then goes on to explain the concept of pages and components. Several form components are shown and then we learn how to configure and use Hivemind services, tie them to EJB3 services and make use of Application State Objects. Of course, Tapestry annotations are in the mix as well… The chapter ends with more than a dozen pages on AJAX and Tacos. Examples include dynamic user input validation and autocompleters.

Heck, had this book been written 2 months later, it would have also had my name in the tacos section : )

Tapestry: Building Trees with Tacos and Annotations

So, what’s it like using annotations in Tapestry along with complex, cool and ajaxified components?
Well, let’s find out!

Html Template

Assuming that we want our html template to be as clean as possible, our CategoryTree.html file will
look like this:

 <body jwcid="@Border" title="Tree Management">
   <div id="note" >
     <h2>Tree Management</h2>
     <p>
       <a jwcid="expandAllLink" href="#">Expand All</a> |
       <a jwcid="collapseAllLink" href="#">Collapse All</a>
     </p>
     <div id="treeArea">
 		<div jwcid="tree" id="tree" style="overflow: auto; width: auto; height: auto;">
 	        <a jwcid="nodeLink" href="folder.png">
 	            <img jwcid="icon" align="absbottom"/>
 	            <span jwcid="nodeLabel">Node 1</span>
 	        </a>
 		</div>
     </div>
   </div>
 </body>

This includes 2 links to expand and collapse all nodes and the tree component. Tacos tree component
can be thought of as a smart iteration component (think of For or ForeEach) but it also knows in which
order the (visible) nodes should be rendered and it knows the node depth of each one of them.

So, here’s how the template looks like if you directly preview it in a browser
,
and here how it looks when tapestry renders it
.

Page Class

Ok, now let’s move on to the only other file needed, the CategoryTree.java (we would need a
CategoryTree.jwc if we didn’t use annotations). Here it is:

 public abstract class CategoryTree extends BaseCmsPage
 {
 	@InjectObject("service:mobilecms.categoryService")
 	public abstract CategoryService getCategoryService();
 
 	@Bean
 	public abstract EvenOdd getEvenOdd(); 
 
 	@Persist
 	@InitialValue("new java.util.HashSet()")
 	public abstract Set getTreeState();
 
 	@Persist
 	public abstract Category getNodeToEdit();
 	public abstract void setNodeToEdit(Category node);
 
 	@Component(type="tacos:Tree", bindings={"contentProvider=contentProvider",
 			"keyProvider=keyProvider", "state=treeState", "value=current", "rowStyle=bean:evenOdd"} )
 	public abstract Tree getTree();
 
 	@Component(type="DirectLink", bindings={"listener=listener:editNode",
 			"parameters={current.id, current.name}"} )
 	public abstract DirectLink getNodeLink();
 
 	@Component(type="DirectLink", bindings={"listener=listener:collapseAll"} )
 	public abstract DirectLink getCollapseAllLink();	
 
 	@Component(type="DirectLink", bindings={"listener=listener:expandAll"} )
 	public abstract DirectLink getExpandAllLink();	
 
 	@Component(type="Insert", bindings={"value=current.langName",
 			"class=(nodeToEdit!=null and current.id == nodeToEdit.id) ? 'selected' : null"} )
 	public abstract Insert getNodeLabel();
 
 	public abstract Category getCurrent();
 
 	public IKeyProvider getKeyProvider() {
 		return new CategoryKeyProvider();
 	}
 
 	public ITreeContentProvider getContentProvider() {
 		return new CategoryTreeContentProvider(getCategoryService());
 	}	
 
 	public void editNode(String id, String name) {
 		setNodeToEdit(new Category(id, name, null, null));
 	}
 
 	public void collapseAll() {
 		getTreeManager().collapseAll();
 	}
 
 	public void expandAll() {
 		getTreeManager().expandAll();
 	}	
 
     public ITreeManager getTreeManager() {
         return new TreeManager(getTreeState(), getContentProvider(), getKeyProvider());
     }

Ok, so I lied (a bit). You still need a few extra classes to run this (i.e. your domain model)
but that’s obvious! Here, we make use of Category (our bean), CategoryService (our way of
finding Categories) and trivial implementations of IKeyProvider and ITreeContentProvider
(the tree’s way of accessing data).

Annotations Used

Now, from top to bottom, here are the annotations explained:

  1. @InjectObject: Inject the specified object-service in our class, simple and powerful. Services
    are defined using Hivemind or Spring -the one used here is a singleton.
  2. @Bean: Create (and inject) a simple javabean. The bean is constructed on each render. We use this
    to achieve alternate coloring of each tree’s node.
  3. @Persist: Store / remembers the value of the property across multiple renders. Uses session by default.
  4. @InitialValue: We don’t want that property to be null at the beggining, and we’re lazy to write java
    code to do this, so we simply add this annotation.
  5. @Component: This one defines the components that are used in this page. In 4.1.1+ versions of Tapestry
    the type attribute can be deduced by the framework if it matched the return type of the annotated method.
    The id of each component is not specified since the framework uses by default the related property name,
    i.e. getNodeLink() is for id nodeLink. This leaves us with the bindings attribute which i find quite
    easy to follow.

From then on, the code contains 6 more methods, all one-liners! Notice how easy it is to collapse or
expand all nodes, and how we add a specific style to the selected node (tip: see the bindings of
getNodeLabel() and the editNode() method).

Ajax Included???

Oh, and BTW, the tree you’ve just created is AJAX enabled! Clicking to expand or collapse a node will
result in only the tree refreshing. You’ll have to add a “nodeLinkAjax=false” to have normal, old-style
refreshes (http://tacos.sourceforge.net/components/Tree.html).

Hope you liked this annotations and tree tour! I’ll soon get back with some entries on Tapestry 4.1.1
new goodies. Always have fun!

Holidays

Holidays

I’ll be heading to Ikaria island in a few hours.
I’ve been there before and i can’t wait to be there again!

Ikaria is one of those little-known (at least to foreigners, who usually only know Myconos, Santorini, Rodos, Corfu and Crete ) greek islands that are perfect for couples but also perfect for large groups of youths…

Anyway, I’ll be staying at Gialiskari, no laptops included (TM)!
Just me, my girl and the sea. Oh, i may bump into some old friends, playing at the Ikaros International Chess Tournament.

Anyway, have fun and see you in many days!

dojo + tapestry = tacos

Tacos is getting closer and closer to
its final 4.0 release. I’ve just finished updating it to dojo 0.3.1, and added a nightly build at the usual place.

For an appetizer, here is the (new) demo site of the last beta release. Have fun!

Updating my Gentoo

Updating my Gentoo
Too busy updating my Gentoo these days…

 emerge --ask --update --newuse --deep world
 

resulted in 290 packages needing recompile…
Cool!

Edit POJOs in Tapestry

Well, the idea is simple, use something like

<span jwcid="@edit:EditObject" object="ognl:pojo"/>

and instantly generate insert-delete-update pages of the given pojo.

I think there’s such a component over at Trails but i’ve yet to find time to check this out as much as i want to.

Recently, there was a post by Hugo Duncan describing a similar component with source code attached.

And now, we have BeanForms by Daniel Gredler, which is a detailed description of yet another solution.

Wow! That’s amazing! I’ll try to get some time this week to play with it + see how AJAX and TACOS can fit to it… What a great community Tapestry has!

Java Hellenic User Group

Today, I attended an event organized by our local JUG and I must say I had a really good time. Saw plenty of familiar faces, met some new ones and heard lots of interesting stuff.

The event started with lots of coffee : ) I think it was 4 cups but they were needed – I was up all night coding more AJAX goodies for TACOS and TAPESTRY.

Anyway, after the coffee we heard a quick intro on the history of the JUG and the first presentation was on ‘JBoss Status Update, Business Model, Products and Roadmaps’ by Dimitris Andreadis. It was a short and pleasant intro on the JBoss company, its model, its products and its future. I liked it, but I was also shocked by a few questions from the audience. It seems, some people are still afraid of open source – they think there’s a trap somewhere. Could it be the “not built here” syndrome, or the “it’s free it’s crap” one?

Well, there followed an ‘Introduction to Java Data Objects (JDO 2)’ by G.Kostaras. I must say I didn’t enjoy this one – at least for me it was useless. There wasn’t even a comparision with Hibernate, apart from some marketing stuff. But again, judging from the audience, it seems that many people simply do not get ORM tools. It must be the same syndromes again. We really need more training + be more open-minded…

Then, there was ‘Practical Iterative Development’ by K.Flokos. Due to my fatigue, I was planning to take a nap on this, but I simply couldn’t. Mr Flokos is an excellent presenter and knows his stuff thoroughtly. I’m sure the material presented stems from personal experience as well as general knowledge, and I’d sure like to download it when it gets available. It would also be very interesting and educating ( I believe for both of us ) to work together, but there’s no way I’m going to Belgium : )

Finally, we had ‘The clustering architecture of JBoss’ again by Mr Andreadis and again an excellent and thought-provoking presentation. I’ve never needed to really use JBoss, but I’m downloading it right now to witness its clustering capabilities. And I know that TAPESTRY is a really cluster-friendly web framework.

All in all, it was a nice Saturday morning. I hope there’ll be more of this, and perhaps I can arrange to present TAPESTRY as well as some AJAX magic there…