Key Listener called again and again if I click on Browser's back Button with Activity and Places in GWT - 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.)

Related

How to clear routing without moving to another page Flutter Getx

I can go to my page PgMain by a lot of way (end of action, logout, button go to menu, button back, system back button, etc.). I want clear my routing every time, where I open PgMain page. How to do it inside PgMain class, for example inside build method? As I said previously, I have a lot of ways to go to PgMain, and not at every case I can use Get.offAll() method
Use
Get.offAll(PgMain()); Get.off(PgMain());
whenever you navigate to PgMain page.

How to unregister GWT eventbus handlers in a Popup/DialogBox?

I have a dialog box, which contains a button and a TabLayoutPanel. The button is outside the TabLayoutPanel. Tab contents are separate custom widgets.
The problem: I want to respond to clicks on the button by performing an action inside one of the tab content widgets.
I tried using the GWT EventBus this way:
fire an event upon button click
add handler for this event inside the tab
But here's the problem: if I close/open the tab multiple times, the event handler will be registered again. And when the button is clicked, the event handler will start multiple times (for every handler registration/however many times the tab was opened).
Since my dialog box doesn't have an activity/place, I cannot use GWT's Activity.start(... EventBus eventBus) for automatic activity deregistration.
A possible solution is to manually remember registered HandlerRegistration(s) and .removeHandler() them when I navigate away from the tab. But this is a rather ugly solution.
Question: Is there a way to unregister events in a dialog box without remembering them?
It's hard to give a concrete answer without code, but I'd do it like this:
Add ClickHandler to the button when the Popup/Dialog gets opened.
If this button is clicked, check which tab is the active one and call a specific method on the widget in that tab.
getSelectedIndex() and getWidget(index) should be the methods on the TabLayoutPanel to use to determine which widget is the active one.
Unregister the clickhandler after the Popup/Dialog got closed.
This way, you have only one Handler to remove what should be the normal way, e.g. with the onClose() event of the DialogBox.

Presenter saves the textbox value in gwtp, gwt

I tried to develop a shopping cart application.
I am able to process the deal. but when the user click the fresh start after completing the deal the first page starts with the value which I have entered previously.
I am using gwtp, uibinders, I have back, cancel, next functionality in series of screens.
what to do to make sure the screen is blank for every new start of deal.
I don't know which design pattern you use, but usually a "view" keeps its state after it is hidden. When you show your view the second time, you have to reset the values of all fields (textboxes, inputs, etc.), or they will show their state from the previous time.

GWT Activities and places: Reusing modal dialogs?

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.

Skillbuilders save before exit

I am using the Skillsbuilders Save Before Exit Oracle ApEx plugin within one of my pages but for some reason, I do not want it to fire when the user presses the "Save" button on the page that basically branches back to itself, when they change something on the page.
Now the "Save" button is fired as part of a Dynamic Action, which basically first calls a JavaScript function, followed by PL/SQL and then performs a apex.submit("SUBMIT") JavaScript call.
With this plugin, how can I prevent it from firing when the user presses the "Save" button because when a user changes a field on the screen and then proceeds to press the "Save" button, this plugin fires and displays the dialog to the user that changes have been made, which is not what I want. I just want it to save the changes and stay on the page.
See here for plugin details:
http://apex.oracle.com/pls/apex/f?p=46685:SAVE_BEFORE_EXIT:0:::::
I have read documentation http://skillbuilders.com/download/download-resource.cfm/instructions.pdf?file=Oracle-Apex/plugins/save_before_exit//instructions.pdf
You must change attribute of the plugin named "Disable Warning Selector". Specify jquery selector, applied for all buttons which you want to fire the dialog.