javax.faces.application.Application Java Examples

The following examples show how to use javax.faces.application.Application. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SessionBean.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * redirects to the specified page
 * @param page the name of the page to go to
 */
public void gotoPage(String page) {
    Application app = getApplication() ;
    if (app != null) {
        NavigationHandler navigator = app.getNavigationHandler();
        navigator.handleNavigation(getFacesContext(), null, page);
    }

    // if app is null, session has been destroyed
    else {
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("msLogin.jsp");
        }
        catch (IOException ioe) {
            // message about destroyed app
        }
    }
}
 
Example #2
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Integer evalInteger(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Integer)
        {
            return (Integer) r;
        } else
        {
            return Integer.valueOf(r.toString());
        }
    } else
    {
        return Integer.valueOf(expression);
    }
}
 
Example #3
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static void setMethodBinding(UIComponent component,
  String attributeName,
  String attributeValue, Class[] paramTypes)
{
  if (attributeValue == null)
  {
    return;
  }
  if (UIComponentTag.isValueReference(attributeValue))
  {
    FacesContext context = FacesContext.getCurrentInstance();
    Application app = context.getApplication();
    MethodBinding mb = app.createMethodBinding(attributeValue,
                       paramTypes);
    component.getAttributes().put(attributeName, mb);
  }
}
 
Example #4
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Boolean evalBoolean(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Boolean)
        {
            return (Boolean) r;
        } else
        {
            return Boolean.valueOf(r.toString());
        }
    } else
    {
        return Boolean.valueOf(expression);
    }
}
 
Example #5
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Double evalDouble(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Double)
        {
            return (Double) r;
        } else
        {
            return Double.valueOf(r.toString());
        }
    } else
    {
        return Double.valueOf(expression);
    }
}
 
Example #6
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Set a MethodBinding on a component - used by tags setProperties() method.
 */
public static void setMethodBinding(UIComponent component, String name, String value,
        Class[] paramTypes)
{
    if (value == null)
    {
        return;
    }
    if (UIComponentTag.isValueReference(value))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        MethodBinding mb = app.createMethodBinding(value, paramTypes);
        component.getAttributes().put(name, mb);
    }
}
 
Example #7
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Set a MethodBinding on a component - used by tags setProperties() method.
 */
public static void setMethodBinding(UIComponent component, String name, String value,
        Class[] paramTypes)
{
    if (value == null)
    {
        return;
    }
    if (UIComponentTag.isValueReference(value))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        MethodBinding mb = app.createMethodBinding(value, paramTypes);
        component.getAttributes().put(name, mb);
    }
}
 
Example #8
Source File: WindowScopeTest.java    From joinfaces with Apache License 2.0 6 votes vote down vote up
@BeforeEach
public void setUp() throws MalformedURLException {
	FacesContext facesContext = FacesContextMocker.mockFacesContext();
	ExternalContext externalContext = mock(ExternalContext.class);
	when(facesContext.getExternalContext()).thenReturn(externalContext);
	when(externalContext.getResource("/WEB-INF/portlet.xml")).thenReturn(null);
	Application application = mock(Application.class);
	when(facesContext.getApplication()).thenReturn(application);

	this.scopeMap = new WindowScopeManager.ScopeMap(FacesContext.getCurrentInstance());

	this.windowScope = new WindowScope() {
		@Override
		@NonNull
		WindowScopeManager.ScopeMap getScopeMap() {
			return WindowScopeTest.this.scopeMap;
		}
	};
}
 
Example #9
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Integer evalInteger(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Integer)
        {
            return (Integer) r;
        } else
        {
            return Integer.valueOf(r.toString());
        }
    } else
    {
        return Integer.valueOf(expression);
    }
}
 
Example #10
Source File: Tags.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Double evalDouble(String expression) {
	if (expression == null)
		return null;
	if (UIComponentTag.isValueReference(expression)) {
		FacesContext context = FacesContext.getCurrentInstance();
		Application app = context.getApplication();
		Object r = app.createValueBinding(expression).getValue(context);
		if (r == null)
			return null;
		else if (r instanceof Double)
			return (Double) r;
		else
			return new Double(r.toString());
	} else
		return new Double(expression);
}
 
Example #11
Source File: Tags.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Integer evalInteger(String expression) {
	if (expression == null)
		return null;
	if (UIComponentTag.isValueReference(expression)) {
		FacesContext context = FacesContext.getCurrentInstance();
		Application app = context.getApplication();
		Object r = app.createValueBinding(expression).getValue(context);
		if (r == null)
			return null;
		else if (r instanceof Integer)
			return (Integer) r;
		else
			return new Integer(r.toString());
	} else
		return new Integer(expression);
}
 
Example #12
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Set an action on a component - used by tags setProperties() method.
 * Handles method bindings.
 */
public static void setAction(UIComponent component, String value)
{
    if (value == null)
    {
        return;
    }
    if (UIComponentTag.isValueReference(value))
    {
        setMethodBinding(component, "action", value, new Class[] {});
    } else
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        MethodBinding mb = new ActionMethodBinding(value);
        component.getAttributes().put("action", mb);
    }
}
 
Example #13
Source File: Tags.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Double evalDouble(String expression) {
	if (expression == null)
		return null;
	if (UIComponentTag.isValueReference(expression)) {
		FacesContext context = FacesContext.getCurrentInstance();
		Application app = context.getApplication();
		Object r = app.createValueBinding(expression).getValue(context);
		if (r == null)
			return null;
		else if (r instanceof Double)
			return (Double) r;
		else
			return new Double(r.toString());
	} else
		return new Double(expression);
}
 
Example #14
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Double evalDouble(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Double)
        {
            return (Double) r;
        } else
        {
            return Double.valueOf(r.toString());
        }
    } else
    {
        return Double.valueOf(expression);
    }
}
 
Example #15
Source File: SessionBean.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * redirects to the specified page
 * @param page the name of the page to go to
 */
public void gotoPage(String page) {
    Application app = getApplication() ;
    if (app != null) {
        NavigationHandler navigator = app.getNavigationHandler();
        navigator.handleNavigation(getFacesContext(), null, page);
    }

    // if app is null, session has been destroyed
    else {
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("Login.jsp");
        }
        catch (IOException ioe) {
            // message about destroyed app
        }
    }
}
 
Example #16
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Double evalDouble(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Double)
        {
            return (Double) r;
        } else
        {
            return Double.valueOf(r.toString());
        }
    } else
    {
        return Double.valueOf(expression);
    }
}
 
Example #17
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static String eval(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        return "" + app.createValueBinding(expression).getValue(context);
    } else
    {
        return expression;
    }
}
 
Example #18
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Set a MethodBinding on a component - used by tags setProperties() method.
 */
public static void setMethodBinding(UIComponent component, String name, String value,
        Class[] paramTypes)
{
    if (value == null)
    {
        return;
    }
    if (UIComponentTag.isValueReference(value))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        MethodBinding mb = app.createMethodBinding(value, paramTypes);
        component.getAttributes().put(name, mb);
    }
}
 
Example #19
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Set an action on a component - used by tags setProperties() method.
 * Handles method bindings.
 */
public static void setAction(UIComponent component, String value)
{
    if (value == null)
    {
        return;
    }
    if (UIComponentTag.isValueReference(value))
    {
        setMethodBinding(component, "action", value, new Class[] {});
    } else
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        MethodBinding mb = new ActionMethodBinding(value);
        component.getAttributes().put("action", mb);
    }
}
 
Example #20
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Boolean evalBoolean(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Boolean)
        {
            return (Boolean) r;
        } else
        {
            return Boolean.valueOf(r.toString());
        }
    } else
    {
        return Boolean.valueOf(expression);
    }
}
 
Example #21
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Boolean evalBoolean(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Boolean)
        {
            return (Boolean) r;
        } else
        {
            return Boolean.valueOf(r.toString());
        }
    } else
    {
        return Boolean.valueOf(expression);
    }
}
 
Example #22
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Integer evalInteger(String expression)
{
    if (expression == null)
    {
        return null;
    }
    if (UIComponentTag.isValueReference(expression))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        Object r = app.createValueBinding(expression).getValue(context);
        if (r == null)
        {
            return null;
        } else if (r instanceof Integer)
        {
            return (Integer) r;
        } else
        {
            return Integer.valueOf(r.toString());
        }
    } else
    {
        return Integer.valueOf(expression);
    }
}
 
Example #23
Source File: Tags.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public static Boolean evalBoolean(String expression) {
	if (expression == null)
		return null;
	if (UIComponentTag.isValueReference(expression)) {
		FacesContext context = FacesContext.getCurrentInstance();
		Application app = context.getApplication();
		Object r = app.createValueBinding(expression).getValue(context);
		if (r == null)
			return null;
		else if (r instanceof Boolean)
			return (Boolean) r;
		else
			return new Boolean(r.toString());
	} else
		return new Boolean(expression);
}
 
Example #24
Source File: TagUtil.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * Set a MethodBinding on a component - used by tags setProperties() method.
 */
public static void setMethodBinding(UIComponent component, String name, String value,
        Class[] paramTypes)
{
    if (value == null)
    {
        return;
    }
    if (UIComponentTag.isValueReference(value))
    {
        FacesContext context = FacesContext.getCurrentInstance();
        Application app = context.getApplication();
        MethodBinding mb = app.createMethodBinding(value, paramTypes);
        component.getAttributes().put(name, mb);
    }
}
 
Example #25
Source File: DataSourceIteratorRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 6 votes vote down vote up
protected Converter findConverter(FacesContext context, UIDataSourceIterator c, ViewDefinition viewDef, ValueColumn vc, Object value) {
    // Explicit converter
    Converter converter = vc.getConverter();
    if(converter!=null) {
        return converter;
    }

    Class<?> converterType = value.getClass();
    if (converterType == null || converterType == String.class || converterType == Object.class) {
        return null;
    }
    
    // Acquire an appropriate converter instance.
    try {
        Application application = context.getApplication();
        return application.createConverter(converterType);
    } catch (Exception e) {
    }
    
    return null;
}
 
Example #26
Source File: OpenntfDominoImplicitObjectFactory.java    From org.openntf.domino with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the "cheap" objects
 */
@Override
public void createImplicitObjects(final FacesContextEx ctx) {
	if (!implicitsDone_) {
		implicitsDone_ = true;
		if (!ODAPlatform.isAPIEnabled(null))
			return;

		Session session = Factory.getSession(SessionType.CURRENT);

		Database db = session.getCurrentDatabase();
		Map<String, Object> ecMap = TypedUtil.getRequestMap(ctx.getExternalContext());

		ecMap.put("openSession", session);
		ecMap.put("openDatabase", db);

		// Attach NSA
		if (ODAPlatform.isAppFlagSet("nsa")) {
			Application app = ctx.getApplication();
			if (app instanceof ApplicationEx) {
				NSA.INSTANCE.registerApplication((ApplicationEx) app);
				NSA.INSTANCE.registerSession((ApplicationEx) app, (HttpSession) ctx.getExternalContext().getSession(true));
			}
		}
	}
}
 
Example #27
Source File: TemplateBaseListener.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Helper method to look up template backing bean.
 * @param context the faces context
 * @return the backing bean
 * @throws FacesException
 */
protected TemplateBean lookupTemplateBean(FacesContext context) throws
    FacesException
{
  TemplateBean templateBean;
  //FacesContext facesContext = FacesContext.getCurrentInstance();
  ApplicationFactory factory = (ApplicationFactory) FactoryFinder.getFactory(
      FactoryFinder.APPLICATION_FACTORY);
  Application application = factory.getApplication();
  templateBean = (TemplateBean)
      application.getVariableResolver().resolveVariable(context, "template");
  return templateBean;
}
 
Example #28
Source File: DojoComboBoxRenderer.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public String convertValue(FacesContext context, UIComponent component, Converter converter, Object value) throws ConverterException {
    if(value!=null) {
        if(converter==null) {
            Application application = context.getApplication();
            converter = application.createConverter(value.getClass());
        }
        // Format it using the converter if necessary, or just converter it to a simple string
        String strValue = converter!=null ? converter.getAsString(context, component, value) 
                                          : value.toString(); 
        return strValue;
    }

    return "";
}
 
Example #29
Source File: CustomSelectOneRadioTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public ValueBinding getValueBinding(String valueRef) {
	ApplicationFactory af =
		(ApplicationFactory) FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
	Application a = af.getApplication();

	return (a.createValueBinding(valueRef));
}
 
Example #30
Source File: SyllabusShowAreaTag.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public static void setValueBinding(UIComponent component,
    String attributeName, String attributeValue)
{
  FacesContext context = FacesContext.getCurrentInstance();
  Application app = context.getApplication();
  ValueBinding vb = app.createValueBinding(attributeValue);
  component.setValueBinding(attributeName, vb);
}