本文整理匯總了Java中javax.faces.context.ExternalContext.redirect方法的典型用法代碼示例。如果您正苦於以下問題:Java ExternalContext.redirect方法的具體用法?Java ExternalContext.redirect怎麽用?Java ExternalContext.redirect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.context.ExternalContext
的用法示例。
在下文中一共展示了ExternalContext.redirect方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onPoll
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
public void onPoll(PollEvent event)
{
if ( __model != null && (__model.getMaximum() <= __model.getValue()) )
{
//pu: This means the background task is complete.
// End the task and navigate off to a different page.
endProcess();
try
{
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
ec.redirect("../components/progressEnd.jspx?taskStatus=completed");
}
catch(IOException ioe)
{
_LOG.log(Level.WARNING, "Could not redirect", ioe);
}
catch (RuntimeException re)
{
_LOG.log(Level.SEVERE, "Could not redirect", re);
throw re;
}
}
}
示例2: loginWithRedirect
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
public void loginWithRedirect(HttpServletRequest request, ExternalContext externalContext, AuthenticationToken token, String rootUrl) throws IOException {
WebSubject subject = SecurityUtils.getSubject();
boolean sessionInvalidate = true;
if (subject.getPrincipal() != null && !subject.isAuthenticated()) {
// This is the case for the TwoStep scenario when OTP value is requested.
// In that case, we shouldn't invalidate the session since we already did it.
sessionInvalidate = false;
}
if (sessionInvalidate) {
sessionUtil.invalidateCurrentSession(request);
}
subject.login(token);
if (SecurityUtils.getSubject().isAuthenticated()) {
SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(request);
externalContext.redirect(savedRequest != null ? savedRequest.getRequestUrl() : rootUrl);
} else {
/*
FIXME
// Not authenticated, so we need to startup the Two Step authentication flow.
TwoStepProvider twoStepProvider = BeanProvider.getContextualReference(TwoStepProvider.class);
UserPrincipal principal = (UserPrincipal) SecurityUtils.getSubject().getPrincipal();
twoStepProvider.startSecondStep(request, principal);
externalContext.redirect(request.getContextPath() + octopusConfig.getSecondStepPage());
*/
}
}
示例3: logout
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
public void logout() {
//super.logout();
ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
try {
externalContext.redirect(logoutHandler.getLogoutPage(externalContext));
} catch (IOException e) {
throw new AtbashUnexpectedException(e);
}
}
示例4: redirectLogin
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private void redirectLogin(ExternalContext context) {
try {
context.redirect("/pse/login.xhtml");
} catch (IOException e) {
LOG.error("Can't redirect to /pse/login.xhtml");
}
}
示例5: shortCircuitRenderView
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public boolean shortCircuitRenderView(
FacesContext context) throws IOException
{
ExternalContext ec = context.getExternalContext();
if (isPartialRequest(ec))
{
Map<String, Object> requestMap = ec.getRequestMap();
UIViewRoot originalRoot = (UIViewRoot) requestMap.get(
TrinidadPhaseListener.INITIAL_VIEW_ROOT_KEY);
// If we're doing a partial update, and the page has changed, switch to a
// full page context.
if (context.getViewRoot() != originalRoot)
{
ViewHandler vh = context.getApplication().getViewHandler();
String viewId = context.getViewRoot().getViewId();
String redirect = vh.getActionURL(context, viewId);
String encodedRedirect = ec.encodeActionURL(redirect);
ec.redirect(encodedRedirect);
if (_LOG.isFine())
{
_LOG.fine("Page navigation to {0} happened during a PPR request " +
"on {1}; Apache Trinidad is forcing a redirect.",
new String[]{viewId, originalRoot.getViewId()});
}
return true;
}
}
// =-=AEW We could look for PPR requests that have no
// requested partial targets, in particular requests
// that simply need to launch a dialog.
return false;
}
示例6: validaUsuario
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private void validaUsuario(final String destino) {
try {
Pessoa pessoa = pessoaService.validarUsuario(loginUser, senhaUser);
System.out.println("Usuario logado: " + pessoa.getNome());
final ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
final HttpSession session = (HttpSession) ec.getSession(true);
session.setAttribute("usuario", pessoa);
//session.setAttribute("pessoa", pessoa);
ec.redirect(ec.getRequestContextPath() + destino);
} catch (Exception e) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Mensagem:", "Usuário ou senha invalido!"));
}
}
示例7: doLogout
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
public void doLogout() throws IOException {
String loginPage = adminConfig.getLoginPage();
if (loginPage == null || "".equals(loginPage)) {
loginPage = Constants.DEFAULT_INDEX_PAGE;
}
if (!loginPage.startsWith("/")) {
loginPage = "/" + loginPage;
}
Faces.getSession().invalidate();
ExternalContext ec = Faces.getExternalContext();
ec.redirect(ec.getRequestContextPath() + loginPage);
}
示例8: redirectToIdpLogout
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
public void redirectToIdpLogout() throws IOException {
ExternalContext externalContext = getFacesContext().getExternalContext();
externalContext.redirect(getSamlLogoutRequest());
}
示例9: _handleDialogReturn
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private void _handleDialogReturn(ExternalContext ec)
throws IOException
{
Map<String, Object> reqMap = ec.getRequestMap();
if(Boolean.TRUE.equals(reqMap.get(DialogServiceImpl.DIALOG_RETURN)))
{
/**
* We use pageflow scope so that if something fails on the redirect, we
* have a chance of getting cleaned up early. This will not always happen
* so the object may stick around for a while.
*/
Map<String, Object> sessionMap = ec.getSessionMap();
String uid = UUID.randomUUID().toString();
LaunchData data = new LaunchData((UIViewRoot)reqMap.get(RequestContextImpl.LAUNCH_VIEW), (Map<String, String[]>) reqMap.get(RequestContextImpl.LAUNCH_PARAMETERS));
sessionMap.put(_getKey(uid), data);
//Construct URL
//TODO: sobryan I believe some of this can be added to the RequestContextUtils to allow
// this url to be constructed for both portlet and servlet environments. We'll want to research.
HttpServletRequest req = (HttpServletRequest) ec.getRequest();
StringBuffer url = req.getRequestURL().append("?");
String queryStr = req.getQueryString();
if((queryStr != null) && (queryStr.trim().length() >0))
{
url.append(queryStr)
.append("&");
}
url.append(_LAUNCH_KEY)
.append("=")
.append(uid);
//Extensions to Trinidad may have alternatve means of handling PPR. This
//flag allows those extensions to for the <redirect> AJAX message to be returned.
if (RequestContext.getCurrentInstance().isPartialRequest(_PSEUDO_FACES_CONTEXT.get()) ||
Boolean.TRUE.equals(RequestStateMap.getInstance(ec).get(_FORCE_PPR_DIALOG_RETURN)))
{
//Special handling for XmlHttpRequest. Would be cool to handle this much cleaner.
HttpServletResponse resp = (HttpServletResponse) ec.getResponse();
XmlHttpConfigurator.sendXmlRedirect(resp.getWriter(), url.toString());
}
else
{
ec.redirect(url.toString());
}
}
}
示例10: redirect
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
/**
* Check the given URL for illegal characters and redirect.
*
* @param redirectUrl
* - the URL to redirect to.
* @throws IllegalArgumentException
* - if URL contains illegal characters
*
* @see ExternalContext#redirect(String)
*/
public static void redirect(ExternalContext extContext, String redirectUrl)
throws IllegalArgumentException, IOException {
extContext.redirect(validateHeader(redirectUrl));
}