• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Seam Book (Yuan & Heute) Hello World Example Annotation

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Michael & Thomas' Seam book, in the chapter 2 Hello World example, why is the "person" variable outjected? Doesn't the "@Name" annotation on the Person entity already make the "person" available to Seam?
Thanks!

SLSB:


Entity:


XHTML:

[ February 11, 2008: Message edited by: John Peters ]
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You use @Name to tell Seam that this is a Seam component and the component will be bijected under this name (you can override it however).
To actually outject a component you need to use @Out.
HTH.
 
John Peters
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey John, thanks for the reply. I think I'm following you, but I'd like some clarification, please:

I was playing around with the SLSB and removed the "@Out" annotation on the "person" variable, so the SLSB looks like this:

Afer redeploying the EAR, everything still worked without any problems. My confusion is why did the authors annotate the "person" class (that is injected in the SLSB) with "@Out" to begin with? It appears Seam was able to create an entity bean just by using the "@Name" annotation on the entity bean itself, and the "@Out" annotation on the SLSB for the "person" class was redundant. Is this correct or am I missing something?

Thanks again, for your help. I've been reading everything I can on bijection and still haven't had the epiphany I need.
 
Hussein Baghdadi
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of it in this way:
When you annotate a Seam component with @Out, you are telling Seam that you want to store this component under some scope.
Remember those lines:
PurchaseOrder po = new PurchaseOrder();
session.setAttribute("purchaseOrder", po);
When you are using @Out, you are doing the same thing.
Alternativley, when you are using @In, you are telling Seam you want to get the object from a desired scope (context in Seam parlance)
Remember this line:
session.getAttribute("purchaseOrder");
?
In your case, yes sure, you can remove @Out from person declaration but you can't write this in your view page:
<h utputText value="#{person.age}" />
Because it is not stored under a scope, you have to write:
<h utputText value="#{helloAction.person.age}" />
Actually, you have to avoid the excessive use bijection as it could harm the performance.
 
John Peters
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the late reply.
I think I'm getting it now, thanks to your help.

One thing I noticed that I think helped me finally get it was that when the @Out annotation was removed from:

the text box no longer was blank after a submit. I figured out that it wasn't blank because after the "person" variable was set to a new blank person, (person = new Person() )it wasn't "pushed" back out to Seam to pick up.

Let me restate it so I make sure I get it:
You're using the @In and @Out to inject and outject items from the Seam contexts which are held in different scopes (session,conversation,page,etc) under names defined by the @Name annotation.

When the xhtml form is submitted, it creates an entity bean (in this case, a Person)based off of how the "value" tags are set up on the "inputText". The @In annotation allows the SLSB to bring in that entity bean from the Seam context into the variable named "person" and persist it. After the entity is persisted, the "person" variable is set to a new, empty person, outjected back into the Seam context where it is rerendered on the xhtml page as a blank Person entity.
 
reply
    Bookmark Topic Watch Topic
  • New Topic