Search in sources :

Example 1 with FacesContext

use of javax.faces.context.FacesContext in project oxAuth by GluuFederation.

the class LanguageBean method setCookieValue.

private void setCookieValue(String value) {
    FacesContext ctx = FacesContext.getCurrentInstance();
    if (ctx == null)
        return;
    HttpServletResponse response = (HttpServletResponse) ctx.getExternalContext().getResponse();
    Cookie cookie = new Cookie(COOKIE_NAME, value);
    cookie.setMaxAge(DEFAULT_MAX_AGE);
    cookie.setPath(COOKIE_PATH);
    response.addCookie(cookie);
}
Also used : Cookie(javax.servlet.http.Cookie) FacesContext(javax.faces.context.FacesContext) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Example 2 with FacesContext

use of javax.faces.context.FacesContext in project oxAuth by GluuFederation.

the class ServerUtil method getRequestOrNull.

/**
     * Safe retrieves http request from FacesContext
     *
     * @return http
     */
public static HttpServletRequest getRequestOrNull() {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    if (facesContext == null)
        return null;
    ExternalContext externalContext = facesContext.getExternalContext();
    if (externalContext == null)
        return null;
    Object request = externalContext.getRequest();
    if (request == null || !(request instanceof HttpServletRequest))
        return null;
    return (HttpServletRequest) request;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) FacesContext(javax.faces.context.FacesContext) ExternalContext(javax.faces.context.ExternalContext)

Example 3 with FacesContext

use of javax.faces.context.FacesContext in project opentheso by miledrousset.

the class FileBean_progress method getBundlePref.

/**
 * Récupération des préférences
 *
 * @return la ressourceBundle de spréférences
 */
private ResourceBundle getBundlePref() {
    FacesContext context = FacesContext.getCurrentInstance();
    ResourceBundle bundlePref = context.getApplication().getResourceBundle(context, "pref");
    return bundlePref;
}
Also used : FacesContext(javax.faces.context.FacesContext) ResourceBundle(java.util.ResourceBundle)

Example 4 with FacesContext

use of javax.faces.context.FacesContext in project ART-TIME by Artezio.

the class ReportedHoursIndicatorTest method testGetFilter.

@Test
public void testGetFilter() {
    hoursIndicator = new ReportedHoursIndicator();
    FacesContext facesContext = createMock(FacesContext.class);
    Application application = createMock(Application.class);
    FilterBean filterBean = createMock(FilterBean.class);
    Filter filter = new Filter();
    PowerMock.mockStatic(FacesContext.class);
    expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
    expect(facesContext.getApplication()).andReturn(application);
    expect(application.evaluateExpressionGet(facesContext, "#{filterBean}", Object.class)).andReturn(filterBean);
    expect(filterBean.getCurrentFilter()).andReturn(filter);
    PowerMock.replayAll(FacesContext.class, facesContext, application, filterBean);
    Filter actual = hoursIndicator.getFilter();
    PowerMock.verifyAll();
    assertSame(filter, actual);
}
Also used : FacesContext(javax.faces.context.FacesContext) Filter(com.artezio.arttime.filter.Filter) Application(javax.faces.application.Application) FilterBean(com.artezio.arttime.web.FilterBean) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with FacesContext

use of javax.faces.context.FacesContext in project ART-TIME by Artezio.

the class ContextUtilTest method testGetELContext.

@Test
public void testGetELContext() {
    PowerMock.mockStatic(FacesContext.class);
    FacesContext facesContext = createMock(FacesContext.class);
    ELContext elContext = createMock(ELContext.class);
    expect(FacesContext.getCurrentInstance()).andReturn(facesContext);
    expect(facesContext.getELContext()).andReturn(elContext);
    PowerMock.replayAll(FacesContext.class);
    ELContext actual = ContextUtil.getELContext();
    PowerMock.verifyAll();
}
Also used : FacesContext(javax.faces.context.FacesContext) ELContext(javax.el.ELContext) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

FacesContext (javax.faces.context.FacesContext)361 NodeRef (org.alfresco.service.cmr.repository.NodeRef)61 Node (org.alfresco.web.bean.repository.Node)44 UserTransaction (javax.transaction.UserTransaction)43 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)28 IOException (java.io.IOException)27 InvalidNodeRefException (org.alfresco.service.cmr.repository.InvalidNodeRefException)27 ExternalContext (javax.faces.context.ExternalContext)26 SelectItem (javax.faces.model.SelectItem)26 QName (org.alfresco.service.namespace.QName)25 FacesMessage (javax.faces.application.FacesMessage)24 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)22 Map (java.util.Map)21 ResourceBundle (java.util.ResourceBundle)20 HttpServletResponse (javax.servlet.http.HttpServletResponse)19 MapNode (org.alfresco.web.bean.repository.MapNode)18 UIViewRoot (javax.faces.component.UIViewRoot)17 HttpServletRequest (javax.servlet.http.HttpServletRequest)16 Serializable (java.io.Serializable)15