2013-03-26 83 views

回答

5

你應該實現一個自定義的ConfigurableNavigationHandler,它將根據動作來源重新映射URL(我假設這裏並不是所有的重定向都是https目的地)。舉個例子:

public class NavigationHandlerTest extends ConfigurableNavigationHandler { 

private NavigationHandlerTest concreteHandler; 

public NavigationHandlerTest(NavigationHandler concreteHandler) { 
     this.concreteHandler = concreteHandler; 
} 


@Override 
public void handleNavigation(FacesContext context, String fromAction, String outcome) 
{ 
    //here, check where navigation is going to/coming from and based on that build an appropriate URL. 
    if(outcome.equals("someAction"){ 
     outcome = "https://foo.bar.baz"; //set destination url 
      } 


    concreteHandler.handleNavigation(context, fromAction, outcome); 

} 


    } 

註冊在您的實現faces-config.xml中

 <application> 
     <navigation-handler>com.example.NavigationHandlerTest</navigation-handler> 
    </application>