I am working on an application built around Activities and Places. I'm trying to do something that seems more difficult than it should be, which makes me doubt I am using Activities and Places in the correct manner.
The application contains 2 activities - one to search for a list of customers and another to view details of a selected customer. Selecting a customer changes Activity via the PlaceController, this all seems fine, history navigation works as expected. The problem comes when adding a filter to the search activity. The requirement is that as filters are selected, they perform client-side filtering of the search results and are also bookmark-able and part of the history. So when the user selects a filter, I don't want to start and stop the Activity (as this removes then adds the view, and the customer list is also retrieved from the server on start), but I do want to update the browser history so the user can press "back" to return to their previous filter and also bookmark selected filters. I've tried a few things: 1. Make the activity a Singleton so the Activity Manager will not start and stop the activity (as the default equals would return true, I suppose equals could also be implemented). Store a member variable in the Activity that can be used to indicate whether the activity has started or stopped. When the user selects a filter, create a Place Token for the current activity with the required filter values, then call PlaceController.goTo. When the ActivityMapper sets the filter values from the Place Token on the Activity, check if the activity is already started and then apply the filter if so. 2. Again, make the Activity a Singleton and perform the PlaceController.goTo method when applying a filter as above. Introduce a new sub-interface of Activity, RestartableActivity, that has an onRestart method. Amend (or copy in to a new class since the required members are private) the Activity Manager to call the onRestart method if the current activity equals the existing activity, and apply the filter in the onRestart method. 3. Have the Activity delegate to a singleton Presenter. Have the presenter maintain the initial search results (so they are not refreshed on the Activity start), and issue the PlaceController.goTo method above to apply filters. Rather than relying on a Activity start to refresh the list, explicitly refresh the list either periodically or on specific user actions. None of these seem like good solutions - in fact, they all seem like pretty bad solutions that are overly complicated for something that feels like it should should be simple to do. Personally, I liked the idea behind attempt 2 - a restart type method on the Activity - but this was such a hack to implement it just felt wrong. So my questions are: 1. Is this an appropriate use of Activities and Places? 2. Has anyone else implemented something similar? If so, how? Thanks Mike -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
