Added initial Seam support for Wicket

Yesterday, I committed initial Seam (2.2.0 beta) support for Wicket. For the moment, it is implemented as a test project: ‘wicket-seam-test’ in the wicket-stuff repository.

The project only has support for the @In annotation of Seam, allowing you to inject Seam components in Wicket components, and it has a simple example. Support for other Seam features might be added later if that makes sense.

The example is quity funny actually. It has this Seam component defined:

@Name("Greet")
@Scope(ScopeType.SESSION)
@AutoCreate
public class GreetService {

  private int count = 0;

  public GreetService() {
  }

  public String greet() {
    return "Hello! I've greeted you " + (++count)
         + " times in this session.";
  }
}

which is later used in a custom label like this:

public class GreetingsLabel extends Label {

  @In
  private GreetService greetService;

  public GreetingsLabel(String id) {
    super(id);
    setModel(new AbstractReadOnlyModel() {

      @Override
      public Object getObject() {
        return greetService.greet();
      }
    });
  }
}

It’s just a simple example, but the interesting thing is that GreetService for the SESSION scope. Every session gets it’s own Seam managed instance. Of course, you could have accomplished the same by using a custom Wicket session, but it is nice to see an alternative way. And Seam can handle many scopes, including e.g. business process scopes. I can imagine that such things would actually be handled much nicer by Seam than if you would hand code it with just Wicket. Definitively something to further look in to!

Read more about it in the README.

UPDATE: Wicket is now supported by Seam. See this presentation for an overview.

About these ads

10 thoughts on “Added initial Seam support for Wicket

  1. Joshua says:

    Hi there,

    I’m interested with this. When will the Wicket support for Seam be ready? Have you guys from Wicket team liassed with the Seam team regarding this? I think this will break the common perception that Seam is tightly coupled with JSF. Looking forward for this wicket-seam project

    Cheers

  2. Hi Joshia,

    Basic support is ready. I think when people would actually start using it, more feature requests might pop up. I’d prefer to develop the project that way rather than just wild-guessing. It is a wicket-stuff project for now, so anyone who is interested in it can work on it; we’re very liberal in giving commit access to wicket-stuff projects. I’d be happy to help out

    If you want to check it out, just get it from SVN (http://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/wicket-seam-test/), and take a look at the example. Run maven once to get the dependencies, and if you use Eclipse, you should be set. If you use other IDEs, you could probably run the respective maven commands.

  3. Clark Updike says:

    I think an alternative to JSF for Seam would be valuable. Seam + Facelets does make JSF more tolerable but not as painless as I hoped. It would be nice to get all the Seam goodies with the transparency of Wicket (note: I’m speculating on Wicket’s transparency here, I’m just learning Wicket now).

    I’m seeing a lot of “swirl” in the possible combinations of Seam, Groovy, Grails, Wicket, Spring, Guice, etc. Makes me wish I had a decent crystal ball :-)

  4. Support currently is pretty basic – but may already be enough. But please keep us/ me informed on your Seam/ Wicket adventures; you can help us make it better :-)

  5. Nicolas says:

    The possibility to work Seam-lessly with Seam & Wicket sounds like a very interesting one. Eventually, they were my two final choices for a Java web framework, having both interesting features. I hope this development will be pushed further in the future.

  6. Actually Nicolas, Wicket is now ‘natively’ supported in Seam. I haven’t got the chance to look at it myself, but it was implemented by Seam’s core developers after taking a look at my and another contribution.

  7. I don’t really understand the value Seam could bring to Wicket or vice versa. Could someone explain it to the readers? What part of Seam would benefit from having Wicket in place? Would the code from the repo – wicket-seam-test shed some light on it?

  8. Support for web applications is only a part of Seam, much of seam is about supporting IoC, stateful business layer components, ORM integration and supporting business processes. If I would use Seam with Wicket, it would be in a similar fashion as how I use Spring right now.

    As for the advantage of using Wicket instead Seam’s JSF support… well that just comes down to what programming model you prefer.

  9. I have never thought about Seam as a IoC container. There’re plenty of them – Plexus, Hivemind, Spring Framework or Guice, but Seam?! Hmm, I need to think about it harder and convince myself I’m not going into a wrong direction. I kept thinking about Wicket as an application framework competitive to Seam not cooperative to it. Seam is JSF+EJB3 whereas Wicket is…well, it’s not JSF+EJB3 certainly. When I create a page in Wicket I write a java class whereas with Seam I use facelets or jsf directly. I thought Seam is JSF-only and whereas I could understand GWT being added to Seam stack I can’t “digest” Wicket+Seam combo. Gotta check it out myself.

    Thanks for your answer, Eelco.

    Jacekk

Comments are closed.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: