2 * Copyright (C) 2012 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.client;
22 import com.google.gwt.place.shared.Place;
23 import com.google.gwt.place.shared.PlaceChangeEvent;
24 import com.google.gwt.place.shared.PlaceController;
25 import com.google.web.bindery.event.shared.EventBus;
28 * @author Murray Cumming <murrayc@murrayc.com>
31 public class PlaceControllerExt extends PlaceController {
33 private final Place defaultPlace;
34 private Place previousPlace;
35 private Place currentPlace;
37 public PlaceControllerExt(EventBus eventBus, Place defaultPlace) {
39 this.defaultPlace = defaultPlace;
40 eventBus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {
42 public void onPlaceChange(PlaceChangeEvent event) {
44 previousPlace = currentPlace;
45 currentPlace = event.getNewPlace();
50 public Place getDefaultPlace() {
55 * Navigate back to the previous Place. If there is no previous place then goto to default place. If there isn't one
56 * of these then it'll go back to the default place as configured when the PlaceHistoryHandler was registered. This
57 * is better than using History#back() as that can have the undesired effect of leaving the web app.
59 public void previous() {
61 if (previousPlace != null) {