org.apache.empire.jsf2.app.impl
Class MojarraImplementation

java.lang.Object
  extended by org.apache.empire.jsf2.app.impl.MojarraImplementation
All Implemented Interfaces:
FacesImplementation

public class MojarraImplementation
extends Object
implements FacesImplementation


Constructor Summary
MojarraImplementation()
           
 
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);
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MojarraImplementation

public MojarraImplementation()
Method Detail

initApplication

public void initApplication(FacesApplication application)
Description copied from interface: FacesImplementation
Init application

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

registerManagedBean

public void registerManagedBean(String beanName,
                                String beanClass,
                                String scope)
Description copied from interface: FacesImplementation
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);

Specified by:
registerManagedBean in interface FacesImplementation

getManagedBean

public Object getManagedBean(String beanName,
                             javax.faces.context.FacesContext fc)
Description copied from interface: FacesImplementation
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);

Specified by:
getManagedBean in interface FacesImplementation

getValueParentComponent

public javax.faces.component.UIComponent getValueParentComponent(javax.el.ValueExpression ve)
Description copied from interface: FacesImplementation
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; }

Specified by:
getValueParentComponent in interface FacesImplementation


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