-
1. Re: JavaBeans and SEAM Actions
norman Jun 25, 2008 11:09 PM (in response to coolex)JavaBean means POJO - just a regular Java object. (as opposed to an EJB3 component)
-
2. Re: JavaBeans and SEAM Actions
coolex Jun 26, 2008 9:44 AM (in response to coolex)Aaah, ok. Thank you very much.
Do I have to make some configuration in SEAM to make them available in my JSF files, e.g. to make entries in the components.xml? Should I create an interface like SEAM does it for actions?
Do I have to create them in a special directory?
I'm asking that question because I created a simple Java File that just return a single String value, lets sayHello World
. This value I wanted to print in my JSF Files but I don't see anything. -
3. Re: JavaBeans and SEAM Actions
coolex Jun 26, 2008 11:22 AM (in response to coolex)OK, I solved the problem. Now my simple (POJO) JavaBean does what I want: simple printout of a string on my JSF site.
BUT now I'm really confused about the difference of JavaBeans and SEAM Actions? The only difference I see is the interface that is created with when you create a new action. Additionally I wasn't able to make simple printouts out of the action in my JSF site like I can do it with simple JavaBeans.
Please give some hints.
-
4. Re: JavaBeans and SEAM Actions
mail.micke Jun 26, 2008 12:31 PM (in response to coolex)Hi
I think you need to pick up a book and/or read some tutorials on this subject!
But here is a little bit more information for you.
Actions in JSF are typically methods on beans called backing beans (or more usually components in Seam).
The backing bean (typically called backing bean because it
backs
a page with data) might contain POJOs or simple Objects which are accessed when rendering the page.A very simple Example:
(not compiled so probably full of errors)
@Name("hellWorldBacking") @Scope(ScopeType.PAGE) public class HelloWorldBacking implements Serializable{ private MyBean myBean = new MyBean(); public String myAction(){ System.out.println("Doing something with myBean: " +myBean.getId() ); return ""; } //skipping code for getter/setter for myBean }
public MyBean{ private long id; //skipping code for getter/setter for id }
The page using the backing bean could look like this:
<p> Value of the id property of myBean is : #{helloWorldBacking.myBean.id} </p> <h:form> <h:inputText value="#{helloWorldBacking.myBean.id}"/> <h:commandButton value="Set id" action="#{helloWorldBacking.myAction}"/> </h:form>