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);
}
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;
}
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;
}
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);
}
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();
}
Aggregations