GWT Activities and places: Reusing modal dialogs? - gwt

I am trying to get my head around GWT Activities and Places. And I am not sure how to implement a specific functionnality.
Let's assume here that I am also using MVP, and that my Activities are my Presenters.
Say I have an activity (let's call it activity A) (and its corresponding view) that is displaying a list of customers. The user can click on a "create customer" button in the view.
What I want to do is this: I want a "create customer" dialog to pop up on top of the current activity when the user clicks on the button. I also want all logic related to said dialog to be separated, so it can be reused later.
For example, the same dialog could be reused in a "create invoice" activity. So the user could click a similar "create customer" button in the "create invoice" activity, and be presented with the same dialog as used earlier.
Now, if I understand it correctly, I do not want to goTo() a new place, since it would terminate the current activity "list customers" or "create invoice".
I have thought about defining a "CreateCustomerPresenter" and a "CreateCustomerDialog" (which would be the corresponding view", and having my "list customers"/"create invoice" Activities (reminder: they also are my Presenters) extend the "CreateCustomerPresenter", but I don't know if it would be a wise idea...
What is the recommended way of reusing logic+view associated with a dialog in the context of an activity?

There are several valid approaches, but the one I usually prefer is this: Not to treat dialogs as places (activities) at all.
Reasoning: A place means, that you can reach it via bookmarks/browser history. Let's say I'm on the customer list, and I click "edit customer", a dialog opens. Do I want to "go back" to the list when I click the browser back button? And will the dialog open again when I click the browser forward button? I doubt it, and believe that a user wants to use the browser buttons to go back/forward entire 'pages' within the app (i.e. a concept that feels to the user like a page), but not open/close dialogs within the page.

I have done exactly this very recently.
The approach I took was to create an activity/view in the usual way for the content of the dialog. To launch, create the activity/view to embed in the dialog - I termed this a sub activity. Create the modal dialog and then call start on the sub-activity passing in the dialog content as the panel. In the main activity I then redirected the mayStop, stop etc to the sub-activity.
The tricky part was handling the dialog closing and passing control back to the main activity. I ended up adding a listener to the dialog and firing events on the event bus which were picked up my main activity. I am not 100% happy with this but it does work.
I have not used it but I think that GWTP supports this and other ways of creating sub-activities out-of-the box.

Related

Microsoft Access New Tab button in Form

What I'm trying to do is create a form where people input data. They're basically going to be tracking what they've done on a computer.
I'd like to have one main form that starts off with a brief intro and then a tab where they're going to be entering the information.
I'd like them to have the option of adding new tabs, so they can track their actions with multiple computers at once.
What would I need to have the button do in order to open a new tab next to the existing one?

When Browsing carousel is clicked it will open the browser. How can I return to my Action?

I have a Browsing carousel in my Action that opens a new page. From that page, I want to give the user an option to either continue on the website or to close the website and go back to the Action.
If they select the option to go back - how can I send them back to the Action?
You can't "go back" to the Action in the same way as if you clicked on a back button in the browser.
However, you can create a link on the page that you're showing the user that will re-start the Action or re-start it with a particular "deep linked" Intent. If you maintain the state of the user when they leave your Action, you can restore that state when they return, but that is up to you to manage.
To create a link to start the Action go to your Action console, select the "Actions" navigation on the left, and then the right arrow for the Intent that you want to be able to link to.
Towards the bottom of the screen that comes up, you may need to click on the "Links" header to expand that section, and then turn the switch on for "Would you like to enable a URL for this Action?"
The section will expand to prompt you for a Link Title (which is required, but not really used for anything) and will show you an HTML code snippet with the link. You are allowed to change this link however you want, but you must use a link - you can't do something clever like try to redirect to that page.

Propagating User intent in PlatForm UI events

Let us say that we have two buttons "Create Foo" and "Edit Foo". Both of them use the same Dialog for Foo but we want to show different fields depending on whether the user intended to create or edit. What is the best practice in propagating the user intent in Platform UI? (It appears that we are unable to access the dialog object in the button click event and thus have to manipulate the dialog in the coral before-open event).

Key Listener called again and again if I click on Browser's back Button with Activity and Places in GWT

I am creating search page and I have use activity and places in GWT. I have used Key Listener so when user press Enter it redirect user on result page.
Problem is that when user use browser back button and again press enter Key Listener call twice same if user again click back button next time it will call trice and so on. Is there any solution for this?
You're probably adding your listener when activity starts but never remove it (e.g. when activity stops).
The full solution depends how you code your activity (do you reuse activity instances? do you have a separate view with activity acting as a presenter/controller? if so, is the view a singleton, or at list lives longer than the activity and can be reused by another activity instance? etc.)

GWT activity mayStop and Hyperlink issue

I have an activity with a mayStop() method. I am having two issues with it that pertain to a hyperlink on the page.
The first issue is that if I hit refresh or the window's X I get a dialog box that wraps my mayStop() text with "Are you sure you want to navigate away from this page?" and "Press OK to continue, or Cancel to stay on the current page." That is fine.
When I hit the hyperlink, I only see my mayStop() text without the wrapping text. Why is that?
The second issue is that if I hit Cancel in response to the hyperlink click, hitting the link again results in not getting the mayStop() challenge at all. It is as if I am not hitting the hyperlink.
Has anyone run into these issues?
Any thoughts?
Thanks,
Doug
The difference in "behavior" is that the first dialog box is the one from the browser when you try to prevent the user from navigating away, while the other is PlaceController calling Window.confirm(). Each browser uses a different dialog box for the first case, so there's no way to mimic it for everyone, and it's probably not a good thing either (navigating away from the app vs. navigating within the app).
As for your second issue, the events are generated by the browser "history" changing; if you prevent navigating away (from the Place), the URL stays the same (there's noway to know what to do to "rollback" the change: History.back(), History.next(), History.newItem() but then you destroy the existing "next" history ?), so when you click again on the link, you don't make the URL change, and no event is fired.
It's expected that you use PlaceController.goTo to navigate when you use places, not Hyperlink or History.