Package org.springframework.springfaces.mvc.navigation

Examples of org.springframework.springfaces.mvc.navigation.NavigationOutcome


    assertThat(dam.getDestination(), is(sameInstance(destination)));
  }

  @Test
  public void shouldAllowNullPreRenderComponentEvent() throws Exception {
    NavigationOutcome outcome = new NavigationOutcome(new Object());
    DestinationAndModel dam = new DestinationAndModel(outcome, (PreRenderComponentEvent) null);
    assertThat(dam.getComponent(), is(nullValue()));
  }


    assertThat(dam.getComponent(), is(nullValue()));
  }

  @Test
  public void shouldObtainComponentFromPreRenderComponentEvent() throws Exception {
    NavigationOutcome outcome = new NavigationOutcome(new Object());
    UIComponent component = mock(UIComponent.class);
    PreRenderComponentEvent preRenderComponentEvent = new PreRenderComponentEvent(component);
    DestinationAndModel dam = new DestinationAndModel(outcome, preRenderComponentEvent);
    assertThat(dam.getComponent(), is(sameInstance(component)));
  }

    assertThat(dam.getComponent(), is(sameInstance(component)));
  }

  @Test
  public void shouldAllowNullActionEvent() throws Exception {
    NavigationOutcome outcome = new NavigationOutcome(new Object());
    DestinationAndModel dam = new DestinationAndModel(outcome, (ActionEvent) null);
    assertThat(dam.getComponent(), is(nullValue()));
  }

    assertThat(dam.getComponent(), is(nullValue()));
  }

  @Test
  public void shouldObtainComponentFromActionEvent() throws Exception {
    NavigationOutcome outcome = new NavigationOutcome(new Object());
    UIComponent component = mock(UIComponent.class);
    ActionEvent actionEvent = new ActionEvent(component);
    DestinationAndModel dam = new DestinationAndModel(outcome, actionEvent);
    assertThat(dam.getComponent(), is(sameInstance(component)));
  }

  @Test
  public void shouldBuildModel() throws Exception {
    Map<String, Object> implicitModel = new HashMap<String, Object>();
    implicitModel.put("implicit", "value");
    NavigationOutcome outcome = new NavigationOutcome(new Object(), implicitModel);
    UIComponent component = mock(UIComponent.class);
    ActionEvent actionEvent = new ActionEvent(component);
    final ModelBuilder modelBuilder = mock(ModelBuilder.class);
    DestinationAndModel dam = new DestinationAndModel(outcome, actionEvent) {
      @Override

    // FIXME put something in flash scope to be displayed on hotel screen
    ModelMap model = new ExtendedModelMap();
    model.addAttribute("country", hotel.getCity().getCountry());
    model.addAttribute("city", hotel.getCity().getName());
    model.addAttribute("hotel", hotel.getName());
    return new NavigationOutcome("@hotel", model);
  }

  public Object onSearch(CitySearchCriteria criteria) {
    City city = findSingleCity(criteria);
    if (city != null) {
      ExtendedModelMap model = new ExtendedModelMap().addAttribute("country", city.getCountry()).addAttribute(
          "name", city.getName());
      return new NavigationOutcome("@showCity", model);
    }
    return "@performSearch";
  }

TOP

Related Classes of org.springframework.springfaces.mvc.navigation.NavigationOutcome

Copyright © 2018 www.massapicom. 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.