當前位置: 首頁>>代碼示例>>Java>>正文


Java FacesContext.setViewRoot方法代碼示例

本文整理匯總了Java中javax.faces.context.FacesContext.setViewRoot方法的典型用法代碼示例。如果您正苦於以下問題:Java FacesContext.setViewRoot方法的具體用法?Java FacesContext.setViewRoot怎麽用?Java FacesContext.setViewRoot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.faces.context.FacesContext的用法示例。


在下文中一共展示了FacesContext.setViewRoot方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateSubscriptionId_ShowExternalConfiguratorIsFalse

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Test
public void validateSubscriptionId_ShowExternalConfiguratorIsFalse()
        throws Exception {
    // given

    model.setShowExternalConfigurator(false);

    UIViewRoot viewRoot = mock(UIViewRoot.class);
    viewRoot.setViewId(SUBSCRIPTIONADD_VIEWID);

    FacesContext context = mock(FacesContext.class);
    context.setViewRoot(viewRoot);

    // when
    UIComponent toValidate = mock(UIComponent.class);
    doReturn("").when(toValidate).getClientId();
    bean.validateSubscriptionId(context, toValidate,
            new String());

    // then
    assertEquals(Boolean.FALSE,
            Boolean.valueOf(model.isShowExternalConfigurator()));
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:24,代碼來源:SubscriptionWizardConversationTest.java

示例2: prepareFacesContextforNullUser

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
private void prepareFacesContextforNullUser() {
    final HttpSession session = new HttpSessionStub(Locale.ENGLISH) {
        @Override
        public Object getAttribute(String arg0) {
            return null;
        }
    };
    new HttpServletRequestStub(Locale.ENGLISH) {
        @Override
        public HttpSession getSession() {
            return session;
        }
    };

    FacesContext facesContext = new FacesContextStub(Locale.ENGLISH);
    UIViewRootStub vrStub = new UIViewRootStub() {
        @Override
        public Locale getLocale() {
            return Locale.ENGLISH;
        };
    };
    facesContext.setViewRoot(vrStub);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:24,代碼來源:UiDelegateTest.java

示例3: navigate

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
public void navigate(ValueChangeEvent vce)
{
  Object newValue = vce.getNewValue();
  if ((newValue != null) && !"".equals(newValue))
  {
    FacesContext fContext = FacesContext.getCurrentInstance(); 
    ViewHandler vh = fContext.getApplication().getViewHandler(); 
    UIViewRoot root = vh.createView(fContext, newValue.toString()); 
    fContext.setViewRoot(root); 
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:12,代碼來源:PartialDemoUtilBean.java

示例4: handleNavigation

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@Override
public void handleNavigation(
  FacesContext context,
  String       fromAction,
  String       outcome)
{
  if (_disableNavigationHandler(context))
  {
    _delegate.handleNavigation(context, fromAction, outcome);
    return;
  }
 
  RequestContext afc = RequestContext.getCurrentInstance();
  
  // We are interested for "dialog:" prefixed outcomes 
  if ((outcome != null) && (outcome.startsWith(afc.getDialogService().getDialogNavigationPrefix())))
  {
    // Handle "dialog:" URLs
    
    // First we try find a classic navigation case from faces-config.xml
    NavigationCase navigationCase = getNavigationCase(context, fromAction, outcome);
    
    // Then if there is no rule (but we are in dialog here) try interpret 
    // outcome as view id - JSF 2.0 Implicit Navigation.
    if (navigationCase == null)
    {
      navigationCase = getNavigationCase(context, fromAction, 
          outcome.substring(afc.getDialogService().getDialogNavigationPrefix().length()));
    } 
    
    UIViewRoot newRoot = null;
    UIViewRoot oldRoot = context.getViewRoot();
    
    if (navigationCase == null)
    {
      // Execute the old (pre-ConfigurableNavigation) code in case the navigation case
      // could not be determined
      
      // ViewMap is cleared during navigation, so save it here (we will be undoing the navigation
      // by restoring the old view root below)
      Map<String,Object> viewMap = oldRoot.getViewMap(false);
      Map<String,Object> cloneMap = (viewMap == null) ? null : new HashMap<String, Object>(viewMap);
      
      _delegate.handleNavigation(context, fromAction, outcome);
      
      newRoot = context.getViewRoot();
      
      if (newRoot != oldRoot)
      {
        // Navigate back to the original root
        context.setViewRoot(oldRoot);
        
        // Restore the old ViewMap because it gets cleared during setViewRoot()
        if (cloneMap != null)
        {
          oldRoot.getViewMap().putAll(cloneMap);
        }
      }
    }
    else
    {
      newRoot = context.getApplication().getViewHandler().createView(context, navigationCase.getToViewId(context));
    }
   
    if (newRoot != oldRoot)
    {
      // Give ourselves a new page flow scope
      afc.getPageFlowScopeProvider().pushPageFlowScope(context, true);
      // And ask the component to launch a dialog
      afc.getDialogService().queueLaunchEvent(newRoot);
    }
  }
  else
  {
     // not a dialog, call the wrapped NavigationHandler
    _delegate.handleNavigation(context, fromAction, outcome);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:79,代碼來源:NavigationHandlerImpl.java

示例5: popView

import javax.faces.context.FacesContext; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void popView(boolean navigateToPoppedView)
{
  FacesContext context = _getFacesContext();
  // Pop the view, and navigate back
  if (navigateToPoppedView)
  {
    UIViewRoot poppedView = peekView();
    if (poppedView == null)
      throw new IllegalStateException(_LOG.getMessage(
        "POPVIEW_NO_VIEW_PUSHED"));

    // Set the view root
    context.setViewRoot(poppedView);

    // Re-execute any "binding" attributes
    _executeBindings(context, poppedView);
    _LOG.fine("Popped view {0}", poppedView.getViewId());
  }

  // Make a copy of the List;  never mutate the original list
  List<Object> list = (List<Object>) _getPageFlowScope().get(_PUSHED_VIEWS_KEY);
  if (list == null)
  {
    // For starters, this should only happen if we weren't navigating
    assert(!navigateToPoppedView);
    // But even then, it's an illegal state
    throw new IllegalStateException(_LOG.getMessage(
      ">POPVIEW_NO_VIEW_PUSHED"));
  }
  else if (list.size() == 1)
  {
    _getPageFlowScope().remove(_PUSHED_VIEWS_KEY);
  }
  else
  {
    list = new ArrayList<Object>(list);
    list.remove(list.size() - 1);
    _getPageFlowScope().put(_PUSHED_VIEWS_KEY, list);
  }
}
 
開發者ID:apache,項目名稱:myfaces-trinidad,代碼行數:43,代碼來源:DialogServiceImpl.java


注:本文中的javax.faces.context.FacesContext.setViewRoot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。