This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes  what methods do managed bean and backing bean contain Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark " what methods do managed bean and backing bean contain" Watch " what methods do managed bean and backing bean contain" New topic
Author

what methods do managed bean and backing bean contain

hanumantha prem
Greenhorn

Joined: May 20, 2009
Posts: 13
1,I am in a very confusion.I am not able to recognize what methods (binding,action,validation,actionlistener)a backing bean(i.e bean for my jsp page) would contain and what methods my Managed bean generated by me contain(that i can add )?.
2.Why do you make ordinary bean as managed bean?
3.is it required to add entry in faces config for every faces jsp page?(means is entry necessory?)

please expalin me.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

Which development tool are you using?

There are lots of questions here. But, your backing bean and your managed bean is really the same thing, right? I have a feeling a devleopment tool might be creating backing beans for you, blurring the lines. But really, it's all the same.

What do you have on a form that you want to pass to the server and process? That's what goes in your managed bean. It's that simple! Anything that needs to get to the server, and potentially be validated prior to getting to the server, goes in a backing bean.

>>Why do you make ordinary bean as managed bean?

It depends on what you mean by ordinary bean.

Keep your backing beans simple. They just have properties that represent data on the client screen, the appropriate setters and getters, and of course, so 'do' action methods. Are they an ordinary bean? Well, I wouldn't say they were POJOs, but often the data in a backing bean is copied to a POJO before being passed to a deeper level of your application for processing or storage.

>>is it required to add entry in faces config for every faces jsp page

I know what you're getting at. It's all that navigation stuff, right? Yeah, I know, it seems onerous. But if you want to have Java ServerFaces help you with page navigation and such things, you're going to need alot of entries in your faces-config.xml file. Will every JSP go in there? Well, probably not fragments, or directly accessed pages, so there are exceptions, but for the most part, which is what I think you're asking, you'll have every JSP in there.

>>binding,action,validation,actionlistener

That gets deeper into the neat stuff that JSF does. Binding helps match data in JSP pages to Java classes, actions are your methods on the server that process data, validation provides routines for doing just that - validating data before it gets processed by your actions, and actionListeners are cool ways of making a web application more event based, so you can listen to drop down boxes being selected and stuff, as opposed to typical web applications that can only respond to submit buttons that deliver a form to the server.

JSF have many neat features. It can seem overwhelming, but if you tackle it all one piece at a time, eventually it will all make sense.

Good luck!

-Cameron McKenzie

hanumantha prem
Greenhorn

Joined: May 20, 2009
Posts: 13
Thanks a lot Cameron for your reply.
I am using Rad 6 which generates backing beans for me.(beans for my JSP page).
My question is which method goes where.?Means is there any restriction that my action,action Listener,validation should go inside the backing beans for my jsp page or in Managed beans.?
And the below entry for jsp page is required for every jsp?
<managed-bean>
<managed-bean-name>pc_Login</managed-bean-name>
<managed-bean-class>pagecode.Login</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951
    
  19

"Randy ortan K "

Have you seen our rules on display names? We're not real picky about most things on the JavaRanch, but we do insist on this one, since despite the moth-eaten moose logo, we do attempt to masquerade as professionals. http://www.javaranch.com/name.jsp

Managed/backing beans are not magic. They're simple JavaBeans, so they can contain any methods and properties you like, and it was an explicit design goal when JSF was created that they should never be required to implement ANY methods or properties just to be JSF-compliant.

In fact, I like to say that the best JSF beans don't even use JSF, although that's stretching it a little.

The management facility doesn't refer to the bean, it refers to the fact that the JSF framework will construct the bean automatically and wire in other beans as specified in the faces-config.xml file on demand. Backing Beans are simply beans that are referenced by JSF pages. But, like I said, in the end they're still just POJOs.


Customer surveys are for companies who didn't pay proper attention to begin with.
hanumantha prem
Greenhorn

Joined: May 20, 2009
Posts: 13
Thanks tim for your advice and your answer.I am very new to javaranch so dint know about naming and will follow the same.
 
Don't get me started about those stupid light bulbs.
 
subject: what methods do managed bean and backing bean contain
 
Similar Threads
Session variable question
JSF Mental Block
managing Faces-config in jSF ...please explain.
inter-frame submitting
JSTL to retrieve and pass request objects