how to know when an action was performed and close automatically the modal - wicket

Let's consider the situation where we send, for example, a request and we are waiting a response.
While we are waiting a modal pops-up with a glyphicon, showing that the request is being processed. The result of this process is going to be an object, when it is null it means that the request was accepted with success, otherwise this object will come with an error message.
I would like to close the modal after receiving the notification, no matter if it was successful or not
can anyone give me an hint of java and wicket?

Wicket gives you full control over ajax request life-cycle and you can implement your own listener as shown in the user guide

If you want to close the modal window after notification recieved, you can make this modal window invinsible, just:
public void recieveNotification(AjaxRequestTarget target) {
Notification notification = service.getNotification;
target.add(modalWindow.setVisible(false));
}
and you wouldn't see it.

Related

Listener above all code in the application - connection

I have the following situation, I created an ErrorInterceptor which I added to Dio. In ErrorInterceptor, if an error occurs, I check:
if (err.error is SocketException) {
//Here we must implement logic for show message about offfline mode
}
At this point, I would like to call code that displays a connection problem.
How can I do that a message is displayed with each request, regardless of where the request was called (LoginPage or another Nested View). I tried to add BlocListener at the very beginning of the application - unfortunately it doesn't work. I would not like to use a solution that is listening all the time.

Detect button press from CLLocationManager Authorization alert

I am detecting whether the user has accepted the request to use location services in my app, I have a toggle switch in the UI that is dependent on this acceptance. The first time they toggle the switch (on) the request to use location is triggered. I want to know which button they press in that alert. (accept or decline) Right now I'm just toggling it off and making the user press it again (then detect which option they picked).
It is kind of sloppy that way, so I'd like to know if there is a way to detect this specific alert or can't that be done since it is triggered by the OS, not the application? I haven't tried it yet, but was thinking I could use the UIAlertView delegate methods for just generic button presses, but was hoping for something more specific.
UPDATE
I was able to get this working by just registering a notification when I trigger the location request (and the authorization prompt is shown). The application is placed in an inactive state (much like pulling down the notification bar). I just trigger a notification when the application becomes active and I'm able to just query the authorization status there and update my UI. I hope this helps anyone else down the line if they want to handle the authorization status on the fly.
There is no way to intercept the alert. There is, however, a method on CLLocationManagerDelegate method called didChangeAuthorizationStatus. That's probably the closest you can get to intercepting the alert.
There is no way to know explicitly which button the user selects since, as you've said, this alert comes from the OS. You can however, find out if location services has been enabled for your app, and know that way. Use a method such as this:
-(BOOL)locationServicesIsEnabled
{
if (![CLLocationManager locationServicesEnabled] || ![CLLocationManager authorizationStatus])
return NO;
return YES;
}

lift disabling back button actions

I'm creating a transaction related site using lift. In here, there's a requirement to show a success page after the user action.
when i make action happen and press the browser's back button. it again goes to the previous page(before transaction page) making the transaction doable again. I need to limit this behavior. Is there any way of limiting the access to previous page by browser back button in lift.
There is no way to reliably stop the user from returning to the URL, but you can stop them from invoking the action more than once. Take a look at S.oneShot. From the Scala Doc:
All functions created inside the oneShot scope will only be called
once and their results will be cached and served again if the same
function is invoked
If you wrap the function that occurs when the button is pressed, even if the user does return to the page and click the button a second time, the body of the function shouldn't be invoked again.

Does Activity.onStop() get called when the tab closes or refreshes?

I thought I saw somewhere that GWT's Activity onStop() method allowed the app to react to page closing. However, in an experiment, this appears not to be the case. Is it supposed to work this way, or am I doing something wrong?
It's the method mayStop(), which is called when the Activity is closed or the page is closed. If you return a non null string it will be displayed in a window.confirm box where the user can dismiss leaving the activity or page.

glade aboutDialog doesn't close

I have an AboutDialog box made in glade, but the Close button doesn't work. I don't know how to connect this button to a separate function, since it sits in a widget called dialog-action_area.
Another problem is if I use the close button created by the window manager, I can't open it again because it has been destroyed.
How can I change this so it just hides?
As any other Dialog window, they require you to
Make use of the run method.
Make use of the "reponse" signal
The first will block the main loop and will return as soon as the dialog receives a response, this may be, click on any button in the action area or press Esc, or call the dialog's response method or "destroy" the window, the last don't mean that the window wil be destroyed, this means that the run() method will exit and return a response. like this:
response = dialog.run()
If you use a debugger, you will notice that the main loop stays there until you click on a button or try to close the dialog. Once you have received yout response, then you can useit as you want.
response = dialog.run()
if response == gtk.RESPONSE_OK:
#do something here if the user hit the OK button
dialog.destroy()
The second allow you to use the dialog in a non-blocking stuff, then you have to connect your dialog to the "response" signal.
def do_response(dialog, response):
if response == gtk.RESPONSE_OK:
#do something here if the user hit the OK button
dialog.destroy()
dialog.connect('response', do_response)
Now, you notice that you have to destroy your dialog
You need to call the widget's hide() method when you receive delete or cancel signals:
response = self.wTree.get_widget("aboutdialog1").run() # or however you run it
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
self.wTree.get_widget("aboutdialog1").hide()
You can find the Response Type constants in the GTK documentation