Backing beans are Java beans which can be used to better manage the behavior of components on a JSP page. In practice, you can create different backing beans for one or more components on a page, however, it can be useful to have a one
Consider the case of a web page called logon.jsp, which contains a Logon
component. This page is used to provide a form that allows users to attempt to log on to BusinessObjects Enterprise.
When the logon form is submitted, an event handling method (referenced by the action
attribute of the Logon
component in the page) must determine the success or failure of the logon, and then return appropriate navigation strings that can be interpreted by the faces
file (see How do I define the navigation flow of my application?). In this case, a backing bean, called Logon.java, is a good location to create these methods in and handle the behavior of the logon.jsp page.
<managed
<managed
<managed
<managed
</managed
Note: This example assumes that the compiled Java bean (Logon.class) will be deployed as part of the pagecode
package in a JAR file contained in the WEB
directory of your application. Alternatively, you can store the compiled Logon.class file in a WEB
directory.
Here is an example of a backing bean for a simple logon page.
package pagecode;
import com.businessobjects.jsf.sdk.model.IIdentity;
import javax.faces.context.FacesContext;
public class Logon
{
protected IIdentity identity;
public IIdentity getIdentity()
{
if (identity == null) {
identity = (IIdentity) FacesContext.getCurrentInstance().getApplication().createValueBinding("#{identity}").getValue(FacesContext.getCurrentInstance());
}
return identity;
}
public void setIdentity(IIdentity identity)
{
this.identity = identity;
}
public String logonAction()
{
identity = getIdentity();
if (identity == null)
return "logon_failure";
if(!identity.isLoggedOn())
return "logon_failure";
return "logon_success";
}
}
Business Objects http://www.businessobjects.com/ Support services http://www.businessobjects.com/services/support/ |