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>
30 * See http://stackoverflow.com/questions/7672895/using-gwts-activities-and-places-can-i-navigate-to-a-previous-page-without-using?rq=1
33 public class PlaceControllerExt extends PlaceController {
35 private final Place defaultPlace;
36 private Place previousPlace;
37 private Place currentPlace;
39 public PlaceControllerExt(EventBus eventBus, Place defaultPlace) {
41 this.defaultPlace = defaultPlace;
42 eventBus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {
44 public void onPlaceChange(PlaceChangeEvent event) {
46 previousPlace = currentPlace;
47 currentPlace = event.getNewPlace();
52 public Place getDefaultPlace() {
57 * Navigate back to the previous Place. If there is no previous place then goto to default place. If there isn't one
58 * of these then it'll go back to the default place as configured when the PlaceHistoryHandler was registered. This
59 * is better than using History#back() as that can have the undesired effect of leaving the web app.
61 public void previous() {
63 if (previousPlace != null) {