Archive for August 6, 2011

The call4all app – Call 4 papers app – Seam 3 example

[Note – Before reading this tutorial, would be nice if you read this post before – It tells you that these Seam posts are under incremental builds and are modified everyday]

Henry is a Computer Science student and he is also an Open Source enthusiastic. He decided to share his knowledge by speaking into some conferences.

Henry checks the Confbuzz app to see the dates of the conferences, and he finds out that there are lots of conferences he would like to speak at. All of them have their our own Call4Papers/talk submission process.

“Crap! I have to copy-paste lots of information…. Bio, email, phone number, Twitter, Facebook… And wth, some of these sites are horrible…. All these technical conferences should have a unified submission process…. would save me lots of time and would ensure that the talk submission process is friendly…. Wait a minute…”

So probably you and Henry got a perfect idea. Create a Call4Papers website example.

But Henry decided he would like to do more. “I’ll talk about it into a conference!”.

Henry started studying Seam 3 few weeks ago and he thinks he’s able to create de Call4All app using it. He starts to fill the form:

So let’s help Henry to create his app. He is a Maven lover, so he prefers to create the app without using Seam Forge. *(check this post for more information about creating a Seam 3 project, with or without Seam Forge)

Creating the project

Henry opens his Eclipse Indigo and install JBoss Tools *. Also he decided to use JBoss AS 7 as it is his favorite Application Server (in fact Henry is in love with that, he still cannot believe AS7 starts in less than 3 seconds). He creates a new Maven project, fills artifactId, groupId, version and package info about the project. Then, he just adds Seam dependencies, getting a pom.xml like this.

So let’s take an overview about these Maven dependencies: [Note: If you are a Maven beginner, you might skip this session and just truste me that this pom.xml really works. Otherwise, if you are ok with maven, take a look at this brief explanation]

< properties >  stuff helps us to control some dependencies version.

< dependencyManagement >  is used to import Seam and RichFaces dependencies.

Then, we add Seam modules (the ones whose groupId is org.jboss.seam ), joda time, prettyfaces (required dependencies for some modules) , richfaces, and adjust some other dependencies (like hibernate validator, we must exclude it from seam-validation and add another version for that, otherwise we will have some trouble with AS 7.

Then Henry runs a mvn clean install – and TA-DA! BUILD SUCCESSFUL!

Maybe you have some questions like “WTH is…. Arquillian?” Take a look here. [I’m also writing a short tutorial about it].

*current version for Indigo – 3.3.0 M2

So what’s next? Henry thinks about the Call4All app… “When i access this webpage, I want to login, auto-fill my personal data and just type the talk title and a brief description. I will forget about page layout for while, and just live h:”.

Good way to start. “But also” – thinks Henry – “I want that conferences may be able to register and access the call4all app via Rest… and then get the proposals, reports and statistics about submission themes, speakers profiles… And oh, would be nice integrate it to Twitter, so as soon as you submit a proposal you can tweet about it…. Or share into facebook… Or even more crazy, go to a voting page for community choose the best keynothes that will be presented….” And then Henry starts to have crazy ideas.

Now let’s see how to implement them using Seam 3 modules. In the next posts Henry will show:

  • Faces module – the base
  • Seam Security and the login page
  • The Brazilian speaker and the international module

August 6, 2011 at 3:23 pm Leave a comment

Seam 3 – creating a new project – with and without Seam Forge

Hi all!

[Note – Before reading this tutorial, would be nice if you read this post before – It tells you that these Seam posts are under incremental builds and are modified everyday]

This is the first post about Seam 3 examples!

The main point here is not to show a simple ‘Hello World’ app, but a more complex example, showing resources from 2 or more more modules.

So, let me tell you a short story…

Ben is a computer science student and he’s having some java classes. The subject now is web apps using Java.

– So – the teacher starts to talk – creating a java web app is pretty simple. As you can see, the only thing you have to do is open Eclipse, select ‘Dynamic web module’….. – and then he starts to say lots of things that should be done BEFORE start writing code.

[After 15 min talking, the teacher still explaining how to create a project] – And this is web.xml. And this one is faces-config.xml, and this is context.xml. Using Jboss AS 5 has some more extra confs, and with JEE 5, you just have to…

Ben thinks “OMG, NO WAY, THIS IS NOT SIMPLE!!!! HOW CAN YOU LIVE WITH THAT??”

And Ben is right, developing apps in that way is pretty boring, painful, and creates a false idea that “Java is a DSL for taking large XML files and converting them to stack traces“.

“I will never use this thing called ‘Java’ to develop my web apps. Ruby on Rails is much more simple and fast”, Ben says leaving the classroom after the class.

“The problem is that the teacher did not mention anything about JEE 6” – replied his classmate Susan.

– JEE 6? What does it do, take large JSON files and convert then to stack traces? haha.

– No, JEE gives you the power of CDI! – says Susan.

– I’ll just consider using it if you tell me that I can build Java web apps in a way as simple as Rails. Otherwise…

– Yes, YOU CAN DO IT! Let me introduce you to Seam Forge!

Ben still thinks that Susan is mocking him, but then she takes her MacBook and starts a little and fast class about Seam Forge.

– Let me introduce you to Seam Forge. Believe me, the only sad part of Java story is Maven downloading the internet for you if your .m2/repository is empty. There’s any other boring thing.

*****************************************

Seam Forge – Fast tutorial

“Ok”, you might be thinking after reading this story. “Show me what do I need to have Seam Forge up and running here on my computer.

Obviously you need JDK (6+). You can download Seam Forge here – go to the “artifact information” and download the zip file. After that, unzip it, and add $FORGE_HOME/bin to your path.

If you are into a UNIX based system (Linux or Mac), basically just add this to your .bash_profile or .basrc:

export FORGE_HOME=/{YOUR_LOCATION}/forge-1.0.0-SNAPSHOT
export FORGE=$FORGE_HOME/bin
export PATH=$PATH:$FORGE

change {YOUR_LOCATION} to the right path of seam-forge directory.

So now type forge into your terminal. You might see Seam Forge up and running, like this:

Explore some commands by typing list-commands -all. Remember that TAB key works pretty fine here 🙂

So now what about some ‘rails style’ development? Let’s do some scaffolding.

Be sure to have JBoss AS 6 or JBoss AS 7 downloaded. You should also have Maven and Git installed.

  1. Let’s create new sample project. Type new-project –named damnPonies –topLevelPackage com.ponies.damn –projectFolder /{YOUR_PATH_HERE/  
  2. Now let’s do scaffold setup. type scaffold setup. Forge will ask you some questions, answer yes.
  3. Choose the last version of Metawidget, and also choose the latest version of Seam persistence. Done!
  4. Now create an index – scaffold indexes –overwrite
  5. Setup your persistence – type  – You can change provider and container – Just use TAB to see other options 🙂
  6. Now let’s create an entity. Type entity –named Pony. Check that Forge creates an Entity called Pony for you (Very similar to Rails =] )
  7. Let’s add some fields – type field string –named color
  8. Type ls and examine the class Pony.java 
  9. Type scaffold from-entity to generate a scaffold for Pony entity.
  10. Then, type build to make maven build the project for you. 
  11. Done! Take a look at the project structure 

If you ever used Seam 2, maybe Forge reminds you a seam-gen enhanced version.

[Break time – You might be wondering why did I call this project ‘DamnPonies. Its related to a Brazilian tv commercial which has an annoying song that involves ‘Damn Ponies’. You can check it  here  – CAUTION – Really annoying song]

More information about Seam Forge:

http://seamframework.org/Seam3/Tooling

https://docs.jboss.org/author/display/SEAMFORGE/Home

*****************************************

Now let’s go back to our story. While Ben is learning about Seam Forge, his classmate Henry is at the library doing some research work. Henry is a Java enthusiastic boy, who really likes Maven world. He gets mad when people make fun of Maven saying it downloads the whole internet. Last week he read a tweet from Susan saying “Maaaaavvveeennn IIIII hhhaaaattteee yyyooouuuuu!”, and then he tweeted back – “go back to Ant then!”. Susan provoked back – “You keep saying you love Maven, but I never see you configure a new project from the beginning. You always use a tool or a stable Maven Archetype. Loser”.

Henry got really disappointed by hearing this from a girl, so he decided to turn the tide. He wants to prove her that HE CAN CREATE A SEAM 3 PROJECT WITHOUT SEAM FORGE. “I’ll curse her with Maven. She’ll see that I am the Maven guy.”

So let’s help Henry on his adventure to create a Seam 3 project without using Seam Forge.

[TODO – write about seam 3 architecture + module brief]

I will assume that you already know about Seam 3 modular architecture. If not, take a look here. Also, you will need Maven 3 and JDK 6+.

So, first step – start with weld archetype – Open your Terminal and type

mvn archetype:generate -DarchetypeArtifactId=jboss-javaee6-webapp -DarchetypeGroupId=org.jboss.weld.archetypes -DarchetypeVersion=1.0.1.CR1 -DarchetypeRepository=central

[TODO – write a better tutorial for this]

August 6, 2011 at 3:19 pm 14 comments

Seam 3 tutorials and examples – up and running

Hi all!

I know that you have been looking for Seam 3 tutorials, examples, and it’s a little hard to find it yet. But Seam 3 team is working hard and soon there will be lots of thing for the community. I will help them with some tutorials and exmaples.

I am going to publish lots of posts and update them [almost] everyday. So, if Google shows you a page of this blog one day, probably in the next 2 or 3 days there will be new content at the same page. Be sure to remember that, otherwise you will think “OMG, its missing lots of things in this post. It’s a crap”. It’s Aug 06 today – I really expect to finish solid information and very cool tutorials until the end of the month.

I also would like to thank all of you who send me feedbacks about this blog – it’s very important to me to always try to write better and useful things. So, if you get a free time, write a little review and send it to hannelita @ gmail, or just leave a comment here 🙂 Believe me, it’s very important to me.

Also, I’d like to ask you to be patient. I know all of you want information, tutorials, easy-to-read and lots of other things. But be aware this is community work – I also have to do lots of other things. I’m really glad to help and share knowledge, but sometimes its really hard to create content in one night. I sleep (sometimes). 🙂 Not only me, but Red Hat guys and all of the other Seam contributors have tons of things to do! Think about that before saying bad things. But we really welcome to suggestions, questions, and specially new contributors! Remember – you can access the forum anytime and post your questions, or join us at IRC – irc.freenode.net – #seam and #seam-dev channel. There’s [almost] always someone online there that might help you!

Feel free to email me anytime – hannelita @ gmail, or send me a Tweet @hannelita. Thanks for reading!

August 6, 2011 at 2:42 pm 1 comment


Calendar

August 2011
M T W T F S S
« Jul   Sep »
1234567
891011121314
15161718192021
22232425262728
293031  

Posts by Month

Posts by Category