from http://groundside.com/blog/DuncanMills.php?p=457&more=1&c=1&tb=1&pb=1
So what is a Backing Bean?
I was chatting with Grant about his quest to clarify all things JSF and ADF for mortals and the question of how best to define a Backing Bean came up.
It's a constant sticking point with JSF newbies and those of us already in the club are notoriously sloppy about our usage of backing bean and managed mean.
The question often comes up as What's the difference between a Managed Bean and a Backing Bean?
The answer is of course none at all.
What makes a Backing Bean is the relationship it has with a JSF page, it acts as a place to put component references and Event code. It "backs" the page, geddit?
So here's a rough set of guidelines about what defines a Backing Bean:
Backing Beans should:
- Be defined in the request scope
- Exist in a one-to-one relationship with a particular page
- Hold all of the page specific event handling code
Backing Beans should not:
- Hold state
How the bean is created (automatically or manually) does not matter although in the case of other IDEs then there may be a more "hardcoded" relationship between the page and its Backing Bean.
In JDeveloper you will see that automatically created Backing Beans (from the JSF page wizard) will be marked with a comment in the faces config:<!--oracle-jdev-comment:managed-bean-jsp-link:1p1.jsp-->
This comment (along with a corresponding one in the page) is used by the IDE to automatically create component references in the bean as those components are added to the page. However, this is just a convention used by the IDE and has no meaning in purely JSF terms.
Perhaps we should try and strike the term Backing Bean from the lexicon to prevent this confusion in the first place, however, I find it a useful concept and will no doubt continue to use it.
Do you have a better defintion of Backing Bean? Let me know in a comment and we'll see if we can come up with a grand unified defintion.
Comments:
private DCBindingContainer bindingContainer;
public void setBindingContainer (DCBindingContainer bc) {this.bindingContainer = bc;}
public DCBindingContainer getBindingContainer() {return bindingContainer;}
Plus you get this property of the managed bean in faces-config.xml:
<managed-property>
<property-name>bindingContainer</property-name>
<property-class>oracle.adf.model.binding.DCBindingContainer</property-class>
<value>#{bindings}</value>
</managed-property>
Thanks!
Shawna
I would like to see the backing bean as a request scoped bean, where as a Managed bean can be of any scope, includng request scope.As the backing bean containg references to the components in the jspx pages directly, we cannot have a backing bean with session scope or of higher scope.
Here is my doubt!
What if we need to access the component's value in a session scoped managed bean ?
Should we import the backing bean's class in the session scoped bean and use the getter and setter methods?
Waiting for your answer,
Samba.
Why I'm asking is...
When I have a backing bean(request scoped),used like:
I'm getting the value enterd in the inputtext field,username.
But When I try to get the same from a session Scoped bean I'm getting null value.
Is there any special way to bind to a Session scoped bean?
Thanking you, Samba.
If you're not seeing the data you expect to see check the constructor of the session scoped bean to make sure that it is executing as expected
Hi,Duncan!
I'm getting ADF Faces and Facelets working properly with pages written in jspx format, but the Faces Servlet being mapped to jsf format.
The problem I'm getting is while displaying ADF Tables with data retrieved from the database using Toplink and bindings provided by ADF Databindings.
The following is the Web.xml mappings for Faces Servlet and ADF bindings filter:
Faces Servlet
javax.faces.webapp.FacesServlet
1
resources
/adf/*
Faces Servlet
*.jsf
adfBindings
oracle.adf.model.servlet.ADFBindingFilter
adfBindings
*.jsp
adfBindings
*.jspx
I'm getting the ADF tables displayed using ADF Bindings, if the faces servlet is mapped for jspx format;but, at the cost of losing Facelets...Facelets is not working with Faces Servlet mapped to jspx format(though written in jspx format, the faces servlet mappping has to be made for jsf format.
On the other hand, if I use faces servlet mapping for jsf pages I'm getting Facelets working but ADF Databindings are not working ,(I guess) and hence ADF Faces Tables are not being displayed(I'm getting Access Denied message).
I even tried to change the ADF binding filter mappings
---- from ---- jsp &jspx---- to ----- jsp and jsf ----
But I got the same Access denied message.
I read a similar post on Oracle's JDeveloper forum by Mr.Ashish Kumar who said he is using java script and automatic form submission, to refresh the page and that gave him the table working.
as quoted in the post:
http://forums.oracle.com/forums/thread.jspa?threadID=421336&tstart=105
Why should the page be refreshed at all. I Guess , the Faces Servlet is not being invoked by the ADF Bindings Filter/Servlet, and for this , I suppose , Mr.Ashish is using java script to provide the action required.
And one more thing which that Automatic Refreshing of page using JavaScript cannot do.
Suppose,
I need customised display, rather than just a Table or Form,like:
public String getEmp() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding("findAllEmp");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}
List res=(List)result;
for(int i=0;i
What I'm getting is a disabled button.
Why doesn't ADF bindings servlet invoke the faces Servlet?
Can't we make ADF Bindings Servlet invoke Faces Servlet by configuring in the web.xml?
Can't we get ADF Bindings filter mapped to work with jsf pages?
Won't ADF Bindings work with jsf pages, will they work only with jspx pages?
This may not be a proper place to ask this question, but I tried so many forums, but could not get the answer!
Simply put,
Can't we get ADF Bindings work in pages with .jsf extension?
When the bindings are working with .jspx pages, why can't we get those working with .jsf pages?
Please Help me.
Thanking you,
Samba
Thanks