本文整理汇总了Java中javax.faces.application.NavigationHandler.handleNavigation方法的典型用法代码示例。如果您正苦于以下问题:Java NavigationHandler.handleNavigation方法的具体用法?Java NavigationHandler.handleNavigation怎么用?Java NavigationHandler.handleNavigation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.faces.application.NavigationHandler
的用法示例。
在下文中一共展示了NavigationHandler.handleNavigation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logout
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
public void logout() {
FacesContext fc = javax.faces.context.FacesContext.getCurrentInstance();
((HttpSession) fc.getExternalContext().getSession(false)).invalidate();
// FacesContext.getCurrentInstance().getExternalContext().getSessionMap().clear();
Application ap = fc.getApplication();
NavigationHandler nh = ap.getNavigationHandler();
//Generate Logout Dialog
List<String> buttonTextList = new ArrayList<String>();
buttonTextList.add(resolve("Login", new Object[]{}));
NotifyDescriptorExt n = new NotifyDescriptorExt(Constants.INFORMATION_ICON, resolve("Logouted", new Object[]{}), resolve("LogoutMessage", new Object[]{}), buttonTextList);
String page = n.setCallbackListener(new ButtonListener() {
public String buttonClicked(final int buttonId, NotifyDescriptorExtBean notifyDescriptorBean) {
return NavigationEnum.controller_CenterPanel.toString();
}
});
//Load the NotifyDescriptor because after logout the JSF logic is expired.
nh.handleNavigation(fc, null, page);
}
示例2: processAction
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
public void processAction(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();
UINamingContainer loginComponent
= (UINamingContainer)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
MethodExpression loginAction = (MethodExpression)loginComponent.getAttributes().get("cancelAction");
try {
loginAction.invoke(context.getELContext(), new Object[] {});
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Login-cancellation could not be fulfilled.", e);
} else {
LOG.info("Login-cancellation could not be fulfilled: " + e.getMessage());
}
}
NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
String outcome = (String)context.getExternalContext().getRequestParameterMap().get("outcome");
if (outcome != null) {
navigationHandler.handleNavigation(context, null, outcome);
}
}
示例3: handle
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
ExceptionQueuedEvent event = i.next();
ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
Throwable t = context.getException();
if (t instanceof ViewExpiredException) {
ViewExpiredException vee = (ViewExpiredException) t;
FacesContext facesContext = FacesContext.getCurrentInstance();
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
try {
// Push some useful stuff to the request scope for use in the page
requestMap.put("currentViewId", vee.getViewId());
navigationHandler.handleNavigation(facesContext, null, "/viewExpired");
facesContext.renderResponse();
} finally {
i.remove();
}
}
}
// At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them.
getWrapped().handle();
}
示例4: afterPhase
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
public void afterPhase(PhaseEvent event) {
FacesContext facesContext = event.getFacesContext();
String currentPage = facesContext.getViewRoot().getViewId();
boolean isLoginPage = (currentPage.lastIndexOf("login.jsp") > -1);
HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true);
String user = (String)session.getAttribute("userName");
if (!isLoginPage && user == null) {
NavigationHandler nh = facesContext.getApplication()
.getNavigationHandler();
nh.handleNavigation(facesContext, null, "loginPage");
}
}
示例5: gotoPage
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
/**
* 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
}
}
}
示例6: gotoPage
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
/**
* 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
}
}
}
示例7: handle
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
/**
* Method for handling done-editing action(e.g. "done_editing_doc")
* @param event Action Event
*/
public void handle(ActionEvent event)
{
setupContentAction(event);
FacesContext fc = FacesContext.getCurrentInstance();
NavigationHandler nh = fc.getApplication().getNavigationHandler();
// if content is versionable then check-in else move to dialog for filling version info
if (isVersionable())
{
nh.handleNavigation(fc, null, DIALOG_NAME);
}
else
{
checkinFileOK(fc, null);
nh.handleNavigation(fc, null, AlfrescoNavigationHandler.DIALOG_PREFIX + "browse");
}
}
示例8: afterPhase
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
@Override
public void afterPhase(PhaseEvent event) {
// Obtém o contexto atual
FacesContext contexto = event.getFacesContext();
// Obter o caminho do contexto
String caminho = contexto.getExternalContext().getRequestServletPath();
try {
// Verifica se o caminho contém o diretório 'admin'
if (caminho.indexOf("admin") > -1 && !(caminho.indexOf("menu") > -1)) {
security.isAutheticated(security.getUsername());
}
} catch (BusinessException be) {
// Em caso de exceção redireciona para a página de login
NavigationHandler nh = contexto.getApplication().getNavigationHandler();
nh.handleNavigation(contexto, null, "logoutSucesso");
}
}
示例9: handleExceptionMsgPage
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
/**
* Handle an exception with just redirects to an error page with a message
*
* @param i
* iterator to remove from on success
* @param facelet
* JSF view to redirect to
* @param msg
* message to display
*/
private void handleExceptionMsgPage( FacesContext fc, Iterator<ExceptionQueuedEvent> i, String facelet, String msg ) {
NavigationHandler nav = fc.getApplication().getNavigationHandler();
try {
final String msgKey = RandomPassword.getPassword( 10 );
Object sessionObj = fc.getExternalContext().getSession( true );
if ( sessionObj instanceof HttpSession ) {
((HttpSession) sessionObj).setAttribute( msgKey, msg );
}
nav.handleNavigation( fc, null, facelet + "?msgKey=" + msgKey + "&faces-redirect=true" );
fc.renderResponse();
}
catch ( Exception eee ) {
}
finally {
if ( i != null ) {
i.remove();
}
}
}
示例10: handle
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
Iterable<ExceptionQueuedEvent> events = this.wrapped.getUnhandledExceptionQueuedEvents();
for(Iterator<ExceptionQueuedEvent> it = events.iterator(); it.hasNext();) {
ExceptionQueuedEvent event = it.next();
ExceptionQueuedEventContext eqec = event.getContext();
if(eqec.getException() instanceof ViewExpiredException) {
FacesContext context = eqec.getContext();
if(!context.isReleased()) {
NavigationHandler navHandler = context.getApplication().getNavigationHandler();
try {
navHandler.handleNavigation(context, null, "home?faces-redirect=true&expired=true");
}
finally {
it.remove();
}
}
}
}
this.wrapped.handle();
}
示例11: handle
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
@Override
public void handle() throws FacesException {
Iterable<ExceptionQueuedEvent> events = this.wrapped.getUnhandledExceptionQueuedEvents();
for(Iterator<ExceptionQueuedEvent> it = events.iterator(); it.hasNext();) {
ExceptionQueuedEvent event = it.next();
ExceptionQueuedEventContext eqec = event.getContext();
System.out.println("eqec.getException()"+eqec.getException());
if(eqec.getException() instanceof ViewExpiredException || eqec.getException() instanceof AbortProcessingException) {
FacesContext context = eqec.getContext();
NavigationHandler navHandler = context.getApplication().getNavigationHandler();
try {
navHandler.handleNavigation(context, null, "main.xhtml?faces-redirect=true&expired=true");
}
catch(Exception e){
System.out.println("exp"+e);
}
finally {
it.remove();
}
}
}
this.wrapped.handle();;
}
示例12: handleViewExpiredException
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
private void handleViewExpiredException(ViewExpiredException vee) {
LOG.log(Level.INFO, " handling viewExpiredException...");
FacesContext context = FacesContext.getCurrentInstance();
String viewId = vee.getViewId();
LOG.log(Level.INFO, "view id @" + viewId);
NavigationHandler nav
= context.getApplication().getNavigationHandler();
nav.handleNavigation(context, null, viewId);
context.renderResponse();
}
示例13: handleNotFoundException
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
private void handleNotFoundException(Exception e) {
LOG.log(Level.INFO, "handling exception:...");
FacesContext context = FacesContext.getCurrentInstance();
String viewId = "/error.xhtml";
LOG.log(Level.INFO, "view id @" + viewId);
NavigationHandler nav
= context.getApplication().getNavigationHandler();
nav.handleNavigation(context, null, viewId);
context.getViewRoot().getViewMap(true).put("ex", e);
context.renderResponse();
}
示例14: handleNavigation
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
/**
* Handle the navigation request implied by the specified parameters,
* through delegating to the target bean in the Spring application context.
* <p>The target bean needs to extend the JSF NavigationHandler class.
* If it extends Spring's DecoratingNavigationHandler, the overloaded
* {@code handleNavigation} method with the original NavigationHandler
* as argument will be used. Else, the standard {@code handleNavigation}
* method will be called.
*/
@Override
public void handleNavigation(FacesContext facesContext, String fromAction, String outcome) {
NavigationHandler handler = getDelegate(facesContext);
if (handler instanceof DecoratingNavigationHandler) {
((DecoratingNavigationHandler) handler).handleNavigation(
facesContext, fromAction, outcome, this.originalNavigationHandler);
}
else {
handler.handleNavigation(facesContext, fromAction, outcome);
}
}
示例15: processAction
import javax.faces.application.NavigationHandler; //导入方法依赖的package包/类
public void processAction(ActionEvent actionEvent) {
FacesContext context = FacesContext.getCurrentInstance();
UINamingContainer loginComponent
= (UINamingContainer)context.getAttributes().get(UIComponent.CURRENT_COMPOSITE_COMPONENT);
MethodExpression logoutAction = (MethodExpression)loginComponent.getAttributes().get("logoutAction");
try {
Object result = logoutAction.invoke(context.getELContext(), new Object[0]);
String outcome;
if (result != null) {
outcome = result.toString();
} else {
outcome = context.getViewRoot().getViewId() + "?faces-redirect=true&includeViewParams=true";
String query = (String)context.getExternalContext().getRequestParameterMap().get("query");
if (query != null && query.length() > 0) {
outcome = outcome + "&" + query;
}
}
NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
if (outcome != null) {
navigationHandler.handleNavigation(context, null, outcome);
}
Object session = context.getExternalContext().getSession(false);
if (session instanceof HttpSession) {
((HttpSession)session).invalidate();
}
} catch (Exception e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Logout failed.", e);
} else {
LOG.info("Logout failed: " + e.getMessage());
}
}
}