org.apache.empire.jsf2.app
Interface FacesImplementation

All Known Implementing Classes:
MojarraImplementation, MyFacesImplementation

public interface FacesImplementation


Method Summary
 Object getManagedBean(String beanName, javax.faces.context.FacesContext fc)
          Returns the parentComponent for a given ValueExpression.
 javax.faces.component.UIComponent getValueParentComponent(javax.el.ValueExpression ve)
          Return the parentComponent for a given ValueExpression.
 void initApplication(FacesApplication application)
          Init application
 void registerManagedBean(String beanName, String beanClass, String scope)
          Registers a managed bean Implementation for Mojarra: --------------------------- FacesContext fc = FacesContext.getCurrentInstance(); BeanManager bm = ApplicationAssociate.getInstance(fc.getExternalContext()).getBeanManager(); // check if (bm.getRegisteredBeans().containsKey(beanName)) throw new ItemExistsException(beanName); // register now ManagedBeanInfo mbi = new ManagedBeanInfo(beanName, beanClass, "view", null, null, null, null); bm.register(mbi); Implementation for MyFaces: --------------------------- FacesContext fc = FacesContext.getCurrentInstance(); RuntimeConfig rc = RuntimeConfig.getCurrentInstance(fc.getExternalContext()); // check if (rc.getManagedBeans().containsKey(beanName)) throw new ItemExistsException(beanName); // register now ManagedBean mbi = new ManagedBean(); mbi.setName(beanName); mbi.setBeanClass(beanClass); mbi.setScope(scope); rc.addManagedBean(beanName, mbi);
 

Method Detail

initApplication

void initApplication(FacesApplication application)
Init application

Parameters:
application - the FacesApplication instance Implementation example: --------------------------- ApplicationFactoryImpl applFactoryImpl = new ApplicationFactoryImpl(); // set implementation application.setImplementation(this, applFactoryImpl.getApplication()); applFactoryImpl.setApplication(application);

registerManagedBean

void registerManagedBean(String beanName,
                         String beanClass,
                         String scope)
Registers a managed bean Implementation for Mojarra: --------------------------- FacesContext fc = FacesContext.getCurrentInstance(); BeanManager bm = ApplicationAssociate.getInstance(fc.getExternalContext()).getBeanManager(); // check if (bm.getRegisteredBeans().containsKey(beanName)) throw new ItemExistsException(beanName); // register now ManagedBeanInfo mbi = new ManagedBeanInfo(beanName, beanClass, "view", null, null, null, null); bm.register(mbi); Implementation for MyFaces: --------------------------- FacesContext fc = FacesContext.getCurrentInstance(); RuntimeConfig rc = RuntimeConfig.getCurrentInstance(fc.getExternalContext()); // check if (rc.getManagedBeans().containsKey(beanName)) throw new ItemExistsException(beanName); // register now ManagedBean mbi = new ManagedBean(); mbi.setName(beanName); mbi.setBeanClass(beanClass); mbi.setScope(scope); rc.addManagedBean(beanName, mbi);


getManagedBean

Object getManagedBean(String beanName,
                      javax.faces.context.FacesContext fc)
Returns the parentComponent for a given ValueExpression. Implementation example: ----------------------- final ELContext elcontext = fc.getELContext(); final Application application = fc.getApplication(); return application.getELResolver().getValue(elcontext, null, beanName);


getValueParentComponent

javax.faces.component.UIComponent getValueParentComponent(javax.el.ValueExpression ve)
Return the parentComponent for a given ValueExpression. Implementation for Mojarra: --------------------------- if (ve instanceof ContextualCompositeValueExpression) { FacesContext ctx = FacesContext.getCurrentInstance(); ContextualCompositeValueExpression ccve = (ContextualCompositeValueExpression)ve; CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(ctx); UIComponent cc = manager.findCompositeComponentUsingLocation(ctx, ccve.getLocation()); // set Parent return cc; }



Copyright © 2008–2014 Apache Software Foundation. All rights reserved.