Posts Tagged ‘JBoss Seam’

I have been getting a lot of requests from freshers to guide them about their career. So I have decided to dedicate an article for that.

Pre-Fresher

I would describe someone who is in the last stages of finishing their formal education as Pre-Fresher. At this stage of your life, you need to be aware of industry trends, job market and salaries. Websites such as Tiobe Index should give you an idea of what is in demand. However, remember that what is in demand today may not remain in demand by the time you finish your degree. So its still a bit of a gamble. But if you have a broad skill set and good design and analytical skills, you can’t go wrong.

Don’t close yourself off. You may not be master of all skills. But as long as you are good at a few and know about a few others, you should be fine.

Industry experience is vital and would set you apart when you finish your education from your collegues. So I would suggest that at this stage you go for it even if you don’t get paid.

Skills worth looking at are: Java/J2EE stack, C/C++, VB, PHP, MySQL, PostgreSQL, Oracle and Linux.

Fresher

At this stage, you have finished your formal education and are ready to take on the world. You have to remember that humility, honesty and hard-work are the important attributes at this stage.

You don’t know everything. So don’t pretend you do. Don’t put things on your CV that you cannot justify. And if you don’t have a job, nothing is stopping you from downloading the latest JDK or Hibernate or JBoss Seam distribution and having a play around with it.

It is possible that you may not have access to a computer or internet. Be resourceful. I used to hire computers on an hourly basis to practice C Language.

Take any job. And once your contracted hours are over, with your manager’s permission you can spend time in some self-teaching. I am sure your manager would be more than happy to let you do that.

By this time, you should have a good idea about what skills attract you. So you can start concentrating on sharpening those skills. For example, if it is Java based Web Applications that interest you, make sure you have a look at JSF, RichFaces, JBoss Seam, JPA, Hibernate and JBoss.

There were no free databases when I had started my career. But today you are spoilt for choice. I would recommend PostgreSQL. Again, for operating systems, go for something with wide acceptance such as Fedora Linux. Have a look at distrowatch.com for other popular linux distributions.

Again, as far as an IDE is concerned, you are spoilt for choice. I would recommend Eclipse as that has a great set of available plug-ins.

Other things that you need to be aware of are Apache WebServer and Subversion (SVN) version management software.

A skillset such as that is going to give you a good start in your professional life.

One thing my teacher Dr. Mrs. Shirwaikar said to us which I follow to this day is “Your books don’t teach you everything”. And no matter how much you know, remember, you don’t know everything.

Another thing worth remembering is you may do everything correctly. But the outcome may not be what you expected. That doesn’t mean there is something wrong with what you did. Its just life – taken from Star Trek.

Recession or Credit Crunch time imposes heavy restrictions on a company’s spending. Generally where a company can hire 10 developers, they are forced to reduce this to 5 or less developers.

Not just that, each individual is required to pick up the work of 2 or more individuals and also, wear multiple hats such as analysis, development, mentoring, project management, deployment, testing and user training. This means that a smaller development team is required to develop the same size and quality of a project as a larger team did before.

A lot of time in the project is taken up for design. However, once the database design is in place, a team is required to develop a series of screens that allow the end users to quickly get a feel for the project and be able to do Create, Retrieve, Update and Delete operations on the underlying database.

Add to this, requirements such as search, filtration, pagination, etc. The requirements and expectations don’t stop there. You will have the higher management asking for Rich Internet Experience and Google-like search.

In the recent past, I have been involved in many projects where the requirements have been similar to what I have described above for some small to medium sized business clients.

So what tools and frameworks really work in such situations you may ask. I have been using the following:

  • Java / J2EE
  • JSF
  • RichFaces
  • JBoss Seam
  • Java Persistence API (JPA) driven by Hibernate
  • PostgreSQL database
  • JBoss Application Server
  • Linux

The above stack is not only fantastic for developer productivity, it also provides fantastic TCO (Total Cost of Ownership). Depending upon the kind of support requirements, the stack can cost anything from Free to GBP 100,000 a year apart from the hardware costs. As the above stack offers a high developer productivity, the cost of development goes down significantly as well. And so does the time. Of course, these two depend largely upon the complexity of the project.

Interesting isn’t it? Especially when you consider that many organizations spend a few Hundred Thousand Pounds on just keeping their applications running!!! Of course, for larger organisations and banks, this cost alone can run into Millions of Pounds.

There are 2 bugs in seam-gen of JBoss Seam 2.1.0.GA in the following 2 files:

view/view.xhtml.ftl – Line 100

property=parentParentPojo.indentifierProperty -> property=parentParentPojo.identifierProperty

view/edit.xhtml.ftl – Line 127

property=parentParentPojo.indentifierProperty -> property=parentParentPojo.identifierProperty

Once you have made the above changes, you will need to run seam delete-project and seam create-project before progressing further.

A copy of my presentation on JBoss Seam in PDF format is available here.

Feel free to mail me your feedback at ashish@ebizss.com.

JBoss have released 2.1.0.GA release of JBoss Seam. The highlights include identity management framework with ACL style permissions, an Excel reporting module, an embellished and more flexible seam-gen, first class support for Wicket, built-in support for URL rewriting and a technology preview of JAX-RS (REST) support through the RESTeasy project.

It is important to mention that Seam based web applications can be deployed to all major Application Servers such as WebSphere, WebLogic, OC4J and now Glassfish. It can also be deployed to Tomcat. Make sure you check out the examples.

Read more about the new release here.

Download it from here.

Check out a screenshot-by-screenshot example here.

JBoss have released version 2.1.0.CR1 of JBoss Seam.

This includes a lot of bug fixes and new features. Notably, it now has support for Wicket.

Download it or read the release notes here.

I had the opportunity to talk on JBoss Seam at the UK Java User Group for Scotland (UK JUGS). Their events link is – http://ukjugs.org/display/main/Events

My presentation is available to download in PDF format – Introduction to JBoss Seam – Notes.pdf

You can get a glimpse of the demo that was a part of this presentation at – http://www.ebizss.com/wiki/index.php/HelloWorldSeam.

Before introducing JBoss SEAM Framework, I would like to put some background into perspective first.

Most Java Developers are aware of Model-View-Controller (MVC) frameworks such as Struts and more recently JavaServer Faces or JSF. JSF + Java Persistence API (JPA) combination have a lot of advantages over Struts + EJB 2 combination. These are as follows:

Fewer, finer grained artifacts

  • No Data Transfer Objects (DTOs) required
  • Clean MVC

Less noise

  • No Struts/EJB 2.x boilerplate code
  • No direct calls to HttpSession or HttpRequest

Simple Object-Relational Mapping (ORM)

  • Even simpler than the Hibernate API!

JSF is flexible and extensible

  • Custom UI widget suites (open source)
  • Good AJAX support

JPA

  • Powerful object/relational mapping, far beyond EJB 2.x CMP entity beans
  • All components are POJO so easily testable with TestNG or JUnit

Some disadvantages of using plain JSF are:

JSF

  • Backing bean couples layers and is just noise
  • Hard to refactor all the XML and String outcomes
  • No support for the business layer
  • Validation breaks DRY
  • XML is too verbose

How do we write our business layer

  • EJB3? – Unfortunately it can’t be used directly by JSF
  • EJB3? – It has no concept of scopes

And then there are some more challenges which are:

Workflow

  • Ad-hoc back buttoning not suppored
  • No stateful navigation
  • No support for long running business processes

Multi-tab/window support is not built in

  • All operations happen in the session – so there is memory leakage
  • No support for a conversation context – so wizards have to use Session Scoped objects
  • Memory leak – objects don’t get cleaned up quickly

However, JSF does provide certain advantages which are:

JSF

  • Validation code in the front-end – for example, required=”true” for input fields.
  • Provides converters for Dates, Amounts, etc.
  • Allows calling Business Layer functions directly.
  • Provides a way for outputting messages alongwith severity (error, info, etc.)

Let us now talk about what SEAM brings to the table.

SEAM allows us to Begin and End a conversation – State is maintained over multiple requests
between Begin and End.

For example:


@Name("itemEditor")
@Scope(CONVERSATION)
public class EditItemBean implements EditItem {

@In EntityManager entityManager;
Long id;
Item item;

// getter and setter pairs
@Begin public String find(Long id) {
item = entityManager.find(Item.class, id);
return item == null ? "notFound" : "success";
}

@End public String save(Item item) {
item = entityManager.merge(item);
return "success";
}

}

Following Scopes are available when we make use of SEAM:

Event – Same as Http Request Scope
Page – New to SEAM – Used just for rendering output
Conversation – New to SEAM – Spans several requests
Session
Application
Business Process – New to SEAM – Spans several conversations and even survives Server restart

As you can see, SEAM makes a few new Scopes available to us which are Page, Conversation and Business Process.

How does SEAM store the state information? Well, that depends upon the context we are talking about.

In Page context, the state information is stored in the component tree of the JSF view (page). It can also be stored in HttpSession or serialized to client.

For conversation context, SEAM stores the state information in a Segmented HttpSession. This information times out if not used thus, preventing Memory Leaks.

In Business Process context, the state information is Persisted to database, and is handled by jBPM.

What is Bijection?

Unlike Spring Framework, which only allows Dependency Injection, SEAM allows Dependency Bijection.


@Name("passwordChanger")
public class PasswordChanger {

@In EntityManager entityManager;
@In @Out User currentUser;

public void changePassword() {
entityManager.merge(currentUser);
}

}

In the above example, entityManager is being Injected whereas, currentUser is both injected as well as outjected.

As a result, currentUser’s value will be first made available to changePassword() and then, once it is done, the objected will be made available to whoever needs it.

Scope of currentUser itself will be governed by the scope of the User class.

A brief explanation about JPA Persistence Context

What is the Persistence Context (PC)?

  • It is a HashMap of all the objects I’ve loaded and stored
  • It holds (at most) one in-memory object for each database row while the PC is active
  • It is a natural first-level cache
  • It can do dirty checking of objects and write SQL as late as possible (automatic or manual flushing)

The Persistence Context has a flexible scope

  • default: same scope as the system transaction (JTA)
  • extended: the PC is bound to a stateful session bean

Which PC scope to use in JPA?

Transaction scoped & detached objects

  • LazyInitializationException
  • NonUniqueObjectException
  • Less opportunity for caching

An extended persistence context of a SFSB is

  • not available during view rendering (LIE again)
  • very complicated propagation rules

PC has no concept of a conversation

Advantage of SEAM managed persistence and transactions

  • SEAM managed PC is conversation scoped.
  • It remains active through conversation,
  • It is injected using @In – @In EntityManager entityManager
  • It allows use of manual flush mode

What else does SEAM give us?

  • Security – This can be configured to work at Page, Field, Class, Method or custom level.
  • Email templates
  • PDF templates
  • JavaScript Remoting
  • Asynchronicity (Java SE, EJB3 or Quartz)
  • Provide Google-style search in your app using Hibernate Search
  • Integration and Unit Testing
  • JSF components (deep integration into JPA)
  • Support for RichFaces, ICEFaces and Adobe Flex 3 RIA
  • Components in groovy
  • WebServices
  • More than 25 examples
  • Portal support
  • Validation
  • BPM support
  • Stateful navigation

SEAM 2.1 Roadmap – The near future

  • Providing Wicket as a view layer
  • Providing GWT as a view layer
  • First class support for other other containers (e.g. Websphere)
  • Identity Management
  • Single-Sign-On for security
  • Deeper integration with JBoss Portal (inter-portlet communication)

This week, CSS layouts kept me awake into the wee hours almost every single day. I think a bit of background is in order before I go any further here.

My company is busy developing the next generation shopping cart application. We are looking to break our usual mould and use some new technologies – well, some are old and established and some are new – such as CSS (so that we can optimise the shopping card for Search Engines), XHTML, Java EE, JBoss Seam, JSF, EJB3 and JPA.

In the past, I have used frames and tables to a very large extent for layouts. However, this has quite a few problems:

  • Search Engines cannot work with Frames particularly well
  • Screen readers cannot read Frames and Tables based websites properly
  • Coding Login and Logout using Frames requires JavaScript hacks
  • and many more…

So I decided to look for a way to use CSS for layouts. Initially I managed to get hold of a layout that got us off the ground. However, we quickly realised that if we were serious about our product, we needed a better layout…something that made better utilisation of the Screen real estate.

Most CSS layouts out there are lame, to say the least. They simply use a width of 800 pixels. Come on designers, most people have a monitor with 1024 pixels width these days…and even more so on wide screen laptops such as mine. So why waste this space?

So I set out to search for a layout that had a header, a top menu, 2 to 3 columns with one column having fluid width and a footer that stuck to the bottom of the screen/content. Easier said than done. It so happens that what I was looking for was the “Holy Grail of CSS”. And the search proved to be just as difficult and frustrating as the search for the real “Holy Grail”.

I searched on Google. I asked the question on LinkedIn Answers. And I tried many a times in vain to create a layout of my own.

Well, I must say, I had quite a few sleepless nights…and a lot of frustration. However, I kept at it. And finally, I have managed to come up with a set of my own layouts.

I have uploaded all my layouts in a single zip file here.

These layouts are as follow:

  • 1colsbottomfooter – 1 column with footer sticking to the bottom of the screen/content
  • 1colsleftnavslickbottomfooter – 1 column with footer sticking to the bottom of the screen/content and extra CSS for navigation
  • 1colstickyfooter – 1 column with footer sticking to the bottom of the content
  • 2colsleftnavbottomfooter – 2 columns with left nav and footer sticking to the bottom of the screen/content
  • 2colsleftnavslickbottomfooter – 2 columns with left nav and footer sticking to the bottom of the screen/content and extra CSS for navigation
  • 2colsleftnavstickyfooter – 2 columns with left nav and footer sticking to the bottom of the content
  • 2colsrightnavbottomfooter – 2 columns with right nav and footer sticking to the bottom of the screen/content
  • 2colsrightnavslickbottomfooter – 2 columns with right nav and footer sticking to the bottom of the screen/content and extra CSS for navigation
  • 2colsrightnavstickyfooter – 2 columns with right nav and footer sticking to the bottom of the content
  • 3colsbottomfooter – 3 columns – holy grail css – with foter sticking to the bottom of the screen/content
  • 3colsslickbottomfooter – 3 columns – holy grail css – with foter sticking to the bottom of the screen/content and extra CSS for navigation
  • 3colstickyfooter – 3 columns – holy grail css – with foter sticking to the bottom of the content

Quite a few of them…I didn’t realise until I actually started to write about them.

The following resources were useful in creating the above layouts:

These layouts are free to use. And if they help you sleep any better, feel free to link back to me or drop me an email :-) .

For those of you looking to get any modifications done, I am happy to do so at a reasonable charge. Feel free to contact me.

I hope you have found the true Holy Grail of CSS here.

JBoss have released Seam 2.0.2.GA, the premier Java EE framework.

This release focuses on stability, component updates and documentation improvements. They’ve fixed over 150 bugs since Seam 2 was released back in November, and, with over 70 000 downloads since then, Seam 2 has had pretty good exposure.

 More details…