Examples of ModelAndViewArtifact


Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Test
  public void shouldGetBeanFactoryFromSpringFacesContext() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    try {
      ViewArtifact viewArtifact = new ViewArtifact("artifact");
      ModelAndViewArtifact rendering = new ModelAndViewArtifact(viewArtifact, null);
      given(this.springFacesContext.getRendering()).willReturn(rendering);
      WebApplicationContext applicationContext = mock(WebApplicationContext.class);
      given(this.springFacesContext.getWebApplicationContext()).willReturn(applicationContext);
      assertThat(this.resolver.getBeanFactory(this.elContext), is(sameInstance((Object) applicationContext)));
    } finally {
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Test
  public void shouldCallStateHandler() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    ViewArtifact viewArtifact = new ViewArtifact("page.xhtml");
    ModelAndViewArtifact rendering = new ModelAndViewArtifact(viewArtifact, null);
    given(this.springFacesContext.getRendering()).willReturn(rendering);
    this.stateManager.setRenderKitId("HTML_BASIC");
    this.stateManager.writeState(this.context, this.state);
    verify(this.stateHandler).write(this.context, viewArtifact);
    verify(this.delegate).writeState(this.context, this.state);
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

    }
    return null;
  }

  private UIViewRoot createViewIfRenderingSpringMvcView(FacesContext context, String viewId) {
    ModelAndViewArtifact rendering = SpringFacesContext.getCurrentInstance().getRendering();
    if (rendering != null) {
      UIViewRoot viewRoot = super.createView(context, rendering.getViewArtifact().toString());
      context.getAttributes().put(ACTION_ATTRIBUTE, rendering.getViewArtifact().toString());
      SpringFacesModelHolder.attach(context, viewRoot, rendering.getModel());
      return viewRoot;
    }
    return null;
  }
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Override
  public UIViewRoot restoreView(FacesContext context, String viewId) {
    if (SpringFacesContext.getCurrentInstance() != null
        && SpringFacesContext.getCurrentInstance().getRendering() != null) {
      ModelAndViewArtifact rendering = SpringFacesContext.getCurrentInstance().getRendering();
      context.getAttributes().put(ACTION_ATTRIBUTE, rendering.getViewArtifact().toString());
      return super.restoreView(context, rendering.getViewArtifact().toString());
    }
    return super.restoreView(context, viewId);
  }
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  }

  private ModelAndViewArtifact mockModelAndViewArtifact() {
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("mk", "v");
    ModelAndViewArtifact modelAndViewArtifact = new ModelAndViewArtifact("mvc", model);
    return modelAndViewArtifact;
  }
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Test
  public void shouldCreateViewForMVCRender() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    UIViewRoot viewRoot = mockUIViewRootWithModelSupport();
    ModelAndViewArtifact modelAndViewArtifact = mockModelAndViewArtifact();
    given(this.springFacesContext.getRendering()).willReturn(modelAndViewArtifact);
    given(this.delegate.createView(this.context, "mvc")).willReturn(viewRoot);
    UIViewRoot actual = this.handler.createView(this.context, "anything");
    assertThat(actual, is(sameInstance(viewRoot)));
    verify(this.delegate).createView(this.context, "mvc");
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  }

  @Test
  public void shouldUseArtifactForRestoreViewOfMVCRender() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    ModelAndViewArtifact modelAndViewArtifact = mockModelAndViewArtifact();
    given(this.springFacesContext.getRendering()).willReturn(modelAndViewArtifact);
    this.handler.restoreView(this.context, "anything");
    verify(this.delegate).restoreView(this.context, "mvc");
  }
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Test
  public void shouldUseSelfPostbackForActionURLFromMVCRender() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    UIViewRoot viewRoot = mockUIViewRootWithModelSupport();
    ModelAndViewArtifact modelAndViewArtifact = mockModelAndViewArtifact();
    given(this.springFacesContext.getRendering()).willReturn(modelAndViewArtifact);
    given(this.delegate.createView(this.context, "mvc")).willReturn(viewRoot);
    this.handler.createView(this.context, "anything");
    String actionUrl = this.handler.getActionURL(this.context, "mvc");
    assertThat(actionUrl, is(equalTo("/rc/sp/si")));
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Test
  public void shouldUseSelfPostbackForActionURLFromMVCRenderWithoutPartialState() throws Exception {
    SpringFacesContextSetter.setCurrentInstance(this.springFacesContext);
    UIViewRoot viewRoot = mockUIViewRootWithModelSupport();
    ModelAndViewArtifact modelAndViewArtifact = mockModelAndViewArtifact();
    given(this.springFacesContext.getRendering()).willReturn(modelAndViewArtifact);
    given(this.delegate.createView(this.context, "mvc")).willReturn(viewRoot);
    this.handler.restoreView(this.context, "anything");
    String actionUrl = this.handler.getActionURL(this.context, "mvc");
    assertThat(actionUrl, is(equalTo("/rc/sp/si")));
View Full Code Here

Examples of org.springframework.springfaces.mvc.render.ModelAndViewArtifact

  @Test
  public void shouldHaveRenderingWhenRendering() throws Exception {
    FacesView view = mock(FacesView.class);
    given(view.getViewArtifact()).willReturn(new ViewArtifact("artifact"));
    Map<String, Object> model = new HashMap<String, Object>();
    final ModelAndViewArtifact modelAndViewArtifact = new ModelAndViewArtifact("artifact", model);
    Lifecycle lifecycle = mock(Lifecycle.class);
    given(this.lifecycleAccessor.getLifecycle()).willReturn(lifecycle);
    willAnswer(new Answer<Object>() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        assertThat(DefaultSpringFacesContextTest.this.springFacesContext.getRendering(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.