views:

397

answers:

2

After seeing very usefull features of other languages or frameworks, i would like to know hidden features of Seam framework.

I'm constantly developing web applications using Seam, and very often, the documentation it's not very clear or profounded so i think would be nice to hear from others problems they struggled with and solution discovered surprisingly :).

So: what hidden feature of Seam framework do you know ?

+5  A: 

Not really hidden, but not really out there either, the event/oberserver/asynchronous/quartz combo :

You can raise Events (like signals) with the builtin Seam component Events :

Events.instance().raiseEvent("event name", params ...);
Events.instance().raiseAsynchronousEvent("event name", params ...);

You can catch those events with @Observer :

@Observer("event name")
public void fonction(param1, param2, etc) {}

You can create a job with Quartz and Seam which will raise an event every time the scheduler activates :

org.jboss.seam.async.QuartzDispatcher.instance().scheduleTimedEvent("event name", Scheduler);

You can create a CronScheduler:

new CronSchedule(firstExecution, "cronSchema", "event name");

You can have a handle on this quartz job, for pausing, resuming, and stopping this job :

org.jboss.seam.async.QuartzTriggerHandle handle = QuartzDispatcher.instance().scheduleTimedEvent( blabla );

Cool eh ?

Maxime ARNSTAMM
Regarding this tip: if i have a factory method (session scope) and a simple method, both with @Observer (observing the same event), i do not understand why the factory is fired after that simple method is fired.
Cristian Boariu
I can't say for sure, but what i know is that when seam search for a component (with @name) it starts from the littlest scope (stateless) to the biggest (application). It may be working the same here. I never thought of that, its good to know there's an order :)
Maxime ARNSTAMM
A: 

Seam-gem uses Ant to generate your app. Its build.xml file is located in the /seam-gen/build.xml

Some Ant Target uses a Ant Tool called hbmtemplate. It is a Template based Engine in which can be controlled by a user provided template or class. So if you want a custom behavior, you should provide your own Freemarker template. In /seam-gen/view directory, you can see a lot of Template files (.flt extension)


The major class in Seam is org.jboss.seam.core.Init, declared as <core:init in components.xml file. There, you can see how Seam works behind the scenes.


If you want to see how Seam Transaction Management works, take a look at SeamPhaseListener class.

Arthur Ronald F D Garcia