Package org.apache.empire.jsf2.app
Class WebApplication
java.lang.Object
org.apache.empire.jsf2.app.WebApplication
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddJavascriptCall(javax.faces.context.FacesContext fc, String function) adds a Javascript call to the requestprotected ResourceTextResolvervoiddestroy()protected StringextractErrorMessageDetail(String errorContext, Throwable e, int stackTraceElements) static javax.faces.component.UIComponentfindChildComponent(javax.faces.component.UIComponent parent, String componentId) finds a child component with the given id that is located below the given parent componentjavax.faces.component.UIComponentfindComponent(javax.faces.context.FacesContext fc, String componentId, javax.faces.component.UIComponent nearComponent) finds the component with the given id that is located in the same NamingContainer as a given componentprotected abstract DataSourceprotected ConnectionObtains a JDBC-Connection from the connection poolgetConnectionForRequest(javax.faces.context.FacesContext fc, DBDatabase db, boolean create) Obtains a JDBC-Connection for the current requestgetContextBean(javax.faces.context.FacesContext context, String beanName, BeanScope scope) Returns the bean for a particular scopegetContextLocale(javax.faces.context.FacesContext ctx) returns the active locale for a given FacesContextgetDefaultControlType(DataType dataType) returns the default input control type for a given data Typejavax.faces.application.FacesMessagegetFacesErrorMessage(javax.faces.context.FacesContext ctx, String errorContext, Throwable t) Returns a FacesMessage for an Exceptionreturn the interface for Implementation specific features that are specific for Mojarra or MyFacesjavax.faces.application.FacesMessagegetFacesMessage(javax.faces.context.FacesContext ctx, javax.faces.application.FacesMessage.Severity severity, String msg, Object... params) Returns a FacesMessagestatic <T extends WebApplication>
TReturns the one and only instance of the WebApplication (Singleton)getPartialSubmitComponentId(javax.faces.context.FacesContext fc) returns the componentId for which a partial submit has been performed.getRollbackManagerForRequest(javax.faces.context.FacesContext fc, boolean create) Obtains a DBRollbackManager for the current requestgetTextResolver(Locale locale) getTextResolver(javax.faces.context.FacesContext ctx) returns the web context path as returned from ServletContext.getContextPath()voidhandleException(javax.faces.context.FacesContext context, Page source, Throwable e) Handles an exeption, that could not be handled on the page level The application should redirect to the error page.booleanhasError(javax.faces.context.FacesContext fc) checks if the current context contains an errorprotected abstract voidinit(javax.servlet.ServletContext servletContext) final voidinit(FacesImplementation facesImpl, javax.faces.context.FacesContext startupContext) Init the Applicationprotected voidinitTextResolvers(javax.faces.application.Application app) booleanisPartialSubmit(javax.faces.context.FacesContext fc) returns true if a form input element has been partially submittedvoidonChangeView(javax.faces.context.FacesContext fc, String viewId) handle view changevoidonRequestComplete(javax.faces.context.FacesContext ctx) handle request cleanupvoidonViewNotFound(javax.faces.context.FacesContext fc, javax.servlet.http.HttpServletRequest req) handle view not foundvoidredirectDirectly(javax.faces.context.FacesContext fc, String url) Redirects to another page or urlvoidregisterManagedBean(Class<?> beanClass, BeanScope scope) Registers a ManagedBean for a particular scopevoidreleaseAllConnections(javax.faces.context.FacesContext fc) Releases all connections attached to the current request If an error is detected in the faces message list, a rollback will automatically be performed insteamd of a commmitvoidreleaseAllConnections(javax.faces.context.FacesContext fc, boolean commit) Releases all connections attached to the current requestprotected voidreleaseConnection(Connection conn, boolean commit, DBRollbackManager dbrm) Releases a JDBC-Connection from the connection poolvoidreleaseConnection(javax.faces.context.FacesContext fc, DBDatabase db) Releases the connection associated with a database from the request If an error is detected in the faces message list, a rollback will automatically be performed insteamd of a commmitvoidreleaseConnection(javax.faces.context.FacesContext fc, DBDatabase db, boolean commit) Releases the connection associated with a database from the requestvoidsetContextBean(javax.faces.context.FacesContext context, Object beanInstance, BeanScope scope) Sets a bean for a particular scope The beanName will be auto detected from the beanInstancevoidsetContextBean(javax.faces.context.FacesContext context, String beanName, Object beanInstance, BeanScope scope) Sets a bean for a particular scope
-
Field Details
-
APPLICATION_BEAN_NAME
-
textResolvers
-
-
Constructor Details
-
WebApplication
protected WebApplication()
-
-
Method Details
-
getInstance
Returns the one and only instance of the WebApplication (Singleton)- Type Parameters:
T- the application type- Returns:
- the WebApplication instance
-
init
protected abstract void init(javax.servlet.ServletContext servletContext) -
getAppDataSource
-
init
public final void init(FacesImplementation facesImpl, javax.faces.context.FacesContext startupContext) Init the Application- Parameters:
facesImpl- the faces implementationstartupContext- the startup context
-
destroy
public void destroy() -
onRequestComplete
public void onRequestComplete(javax.faces.context.FacesContext ctx) handle request cleanup- Parameters:
ctx- the faces context
-
onViewNotFound
public void onViewNotFound(javax.faces.context.FacesContext fc, javax.servlet.http.HttpServletRequest req) handle view not found- Parameters:
fc- the faces contextreq- the request
-
onChangeView
handle view change- Parameters:
fc- the faces contextviewId- the view id
-
addJavascriptCall
adds a Javascript call to the request- Parameters:
fc- the faces contextfunction- the javascript command
-
getFacesImplementation
return the interface for Implementation specific features that are specific for Mojarra or MyFaces- Returns:
- the faces implementation
-
getWebRoot
returns the web context path as returned from ServletContext.getContextPath()- Returns:
- the web root
-
getContextLocale
returns the active locale for a given FacesContext- Parameters:
ctx- the faces context- Returns:
- the context locale
-
getTextResolver
-
getTextResolver
-
getFacesMessage
public javax.faces.application.FacesMessage getFacesMessage(javax.faces.context.FacesContext ctx, javax.faces.application.FacesMessage.Severity severity, String msg, Object... params) Returns a FacesMessage- Parameters:
ctx- the FacesContextseverity- the message severitymsg- the message or message keyparams- the message params- Returns:
- the FacesMessage or null to ignore
-
getFacesErrorMessage
public javax.faces.application.FacesMessage getFacesErrorMessage(javax.faces.context.FacesContext ctx, String errorContext, Throwable t) Returns a FacesMessage for an Exception- Parameters:
ctx- the FacesContexterrorContext- the error context (optional)t- the exception- Returns:
- the FacesMessage or null to ignore
-
extractErrorMessageDetail
-
hasError
public boolean hasError(javax.faces.context.FacesContext fc) checks if the current context contains an error- Parameters:
fc- the FacesContext- Returns:
- true if the context has an error set or false otherwise
-
redirectDirectly
Redirects to another page or url- Parameters:
fc- the FacesContexturl- the target url
-
handleException
Handles an exeption, that could not be handled on the page level The application should redirect to the error page.- Parameters:
context- the faces contextsource- the page from which the exception originatede- the Exception to handle
-
isPartialSubmit
public boolean isPartialSubmit(javax.faces.context.FacesContext fc) returns true if a form input element has been partially submitted- Parameters:
fc- the Faces Context- Returns:
- the componentId or null if no partial submit was been performed
-
getPartialSubmitComponentId
returns the componentId for which a partial submit has been performed.- Parameters:
fc- the Faces Context- Returns:
- the componentId or null if no partial submit was been performed
-
findComponent
public javax.faces.component.UIComponent findComponent(javax.faces.context.FacesContext fc, String componentId, javax.faces.component.UIComponent nearComponent) finds the component with the given id that is located in the same NamingContainer as a given component- Parameters:
fc- the FacesContextcomponentId- the component idnearComponent- a component within the same naming container from which to start the search (optional)- Returns:
- the component or null if no component was found
-
findChildComponent
public static javax.faces.component.UIComponent findChildComponent(javax.faces.component.UIComponent parent, String componentId) finds a child component with the given id that is located below the given parent component- Parameters:
parent- the parentcomponentId- the component id- Returns:
- the component or null if no component was found
-
registerManagedBean
Registers a ManagedBean for a particular scope- Parameters:
beanClass- the bean class to registerscope- the bean scope
-
getContextBean
public Object getContextBean(javax.faces.context.FacesContext context, String beanName, BeanScope scope) Returns the bean for a particular scope- Parameters:
context- the FacesContextbeanName- the beanNamescope- the bean scope- Returns:
- the bean instance
-
setContextBean
public void setContextBean(javax.faces.context.FacesContext context, String beanName, Object beanInstance, BeanScope scope) Sets a bean for a particular scope- Parameters:
context- the FacesContextbeanName- the beanNamebeanInstance- the bean instancescope- the bean scope
-
setContextBean
public void setContextBean(javax.faces.context.FacesContext context, Object beanInstance, BeanScope scope) Sets a bean for a particular scope The beanName will be auto detected from the beanInstance- Parameters:
context- the FacesContextbeanInstance- the bean instancescope- the bean scope
-
getDefaultControlType
returns the default input control type for a given data Type- Parameters:
dataType- the data type- Returns:
- an Input Cnotrol type
- See Also:
-
initTextResolvers
protected void initTextResolvers(javax.faces.application.Application app) -
createResourceTextResolver
-
getConnection
Obtains a JDBC-Connection from the connection pool- Parameters:
db- the database for which to obtain a connection- Returns:
- the connection
-
releaseConnection
Releases a JDBC-Connection from the connection pool- Parameters:
conn- the connection to releasecommit- flag whether to commit changesdbrm- the rollback manager
-
getRollbackManagerForRequest
public DBRollbackManager getRollbackManagerForRequest(javax.faces.context.FacesContext fc, boolean create) Obtains a DBRollbackManager for the current request- Parameters:
fc- the FacesContextcreate- if true a DBRollbackManager will be created if not already present- Returns:
- the rollback manager
-
getConnectionForRequest
public Connection getConnectionForRequest(javax.faces.context.FacesContext fc, DBDatabase db, boolean create) Obtains a JDBC-Connection for the current request- Parameters:
fc- the FacesContextdb- the DBDatabase for which to obtain a connectioncreate- if true a Connection will be created if not already present- Returns:
- the connection
-
releaseAllConnections
public void releaseAllConnections(javax.faces.context.FacesContext fc, boolean commit) Releases all connections attached to the current request- Parameters:
fc- the FacesContextcommit- when true changes are committed otherwise they are rolled back
-
releaseAllConnections
public void releaseAllConnections(javax.faces.context.FacesContext fc) Releases all connections attached to the current request If an error is detected in the faces message list, a rollback will automatically be performed insteamd of a commmit- Parameters:
fc- the FacesContext
-
releaseConnection
Releases the connection associated with a database from the request- Parameters:
fc- the FacesContextdb- the DBDatabase for which to release the connectioncommit- when true changes are committed otherwise they are rolled back
-
releaseConnection
Releases the connection associated with a database from the request If an error is detected in the faces message list, a rollback will automatically be performed insteamd of a commmit- Parameters:
fc- the FacesContextdb- the DBDatabase for which to release the connection
-