wicket ajaxButton onError called - wicket-6

I am working on wicket 6.0. I used an AjaxButton to save a form. When I press the button, nothing happens on User Interface. However I checked the log and the onError method was called. What does it mean? How to fix it?
Moreover I checked on FireBug to see Ajax events, I have no events when I press the button.
Thanks

AjaxButton is a form submitting component. If its #onError() is called that means some FormComponent in the submitted form didn't pass its validation/conversion.
If #onError() is called then there is an Ajax call for sure!

Related

DeviceMotionEvent.requestPermission() throws NotAllowedError

I have a web page that I'm loading in Safari on iOS 13.4.1. The web page calls DeviceOrientationEvent.requestPermission() and in the .catch following the .then I'm seeing this error:
NotAllowedError: Requesting device orientation or motion access requires a user gesture to prompt
However there is no pop-up requesting permission.
Does anyone know what I'm missing?
Late reply, hoping it might be useful to others.
The call DeviceOrientationEvent.requestPermission() in your code must be performed as a reaction to some user gesture.
So e.g. you would show a dialog to user with a message and a button, explaining what's going to happen next. In button click handler, you hide the dialog and actually call that method.
An example of click handler is given here: https://dev.to/li/how-to-requestpermission-for-devicemotion-and-deviceorientation-events-in-ios-13-46g2 .

How can I avoid a postback message?

I am relatively new in programming and I have a doubt about postback. I searched in some pages, but I couldn't solve my question.
I created a web page and I use postback in it that updates some informations in the page. That works without any problems. However, after the postback is fired, if the user presses F5, a message appears asking to confirm the form re-submit.
Why exactly this message appears and how can I avoid it?
If the user would press F5, I want the page reload, without any alerts.
I'm sorry if my question wasn't clear enough, but I really don't understand postback how much I'd like.. =)
By Default ,
The method is post means it will confirm while reloading the page.
The method is get means it wont ask anything.
Why this happens,Whenever the post method called severe action gonna happen in server,so it just confirms from the user.There is no need in the case of get Method.
I hope u are clear with this solution.
One way to avoid your issue is to place a hidden field on the page. When the form is submitted, check the hidden field. If no value, process the form, and populate the hidden field with a value. If it has a value, then do nothing.
I prefer using an on-click event on a button, instead of using the postback event.
As to why it happens, a refresh sends a request along with the form data back to the server causing another postback.
This is known as page re-submission.
When you refresh the browser, it will resend the last request you did. If it was a POST request (like you do in case of postback) then it will re-post the information but before doing it you'll see the warning message you describe.
To prevent this:
Page.Response.Redirect(Page.Request.Url.ToString(), true);
Which changes the response to a GET instead of a POST. Prevents the 'Form Resubmission' dialog.
I thought in the following code to solve my problem, using a javascript event:
$(document).keydown(function (event) {
if (event.keyCode == 116) {
location.href = 'pedidos.aspx';
return false;
}
});
It solves my problem, because I avoid the postback message as I want and the page is reloaded.
But is this a good solution?

asp.net mvc expected controller and action not getting invoked

I have a weird issue. I loaded a page using "LoadMyPageController" and there is an ajax_submit_button1 which can be used submit the page.
Also there is another ajax_submit_button2 to print the page. This button submits the view model of the page as a whole to the "PrintController" which has a "PrintData" action.
Now when I hit the "ajax_submit_button2", my PrintController.PrintData is not invoked. Instead when I check my fiddler tool the request is made as
http://localhost:18484/LoadMyPage/PrintData?Length=14
which is an invalid URL.
I have contructed my ajax_submit_button2 in such a way that it should invoke
http://localhost:18484/Print/PrintData?Length=14
But I don't know why LoadMyPage controller is present in my URL.
Any thoughts or comments would be appreciated. By any chance does asp .net MVC decides that it will take a default controller on its own if it can't find the controller action for any reason.
The code is a kind of tightly coupled so can't post it. I want to know if anyone experienced a problem like this.
This has nothing to do with the routing on the server since the request being made by the client has the wrong controller in it. I suspect that your code generating the url for the submit button is not correct -- i.e., not specifying the controller to be used -- or that you have a form around the submit button that is actually being invoked instead of (or in addition to) the ajax code. Note that if your submit handler doesn't return false, the default form action will be invoked and the form submitted normally. If you do have a form, make sure that the url on it is correct and that your submit handler returns false.
$('#printForm').submit( function() {
$.ajax({
url: $(this).attr('action'),
...
});
return false; // this is important!
});

Messagebox in ASP.NET 3.5 with AJAX

I have a ASP.NET 3.5 web site with an AJAX update panel. I simply need to process some server side code and then issue a user prompt that says "Code processing complete".
I know there is supposed to be support for Msgbox-esque methods in ASP.NET but I can't find them and any other JavaScript based solutions don't work effectively when you have an update panel.
Help.
Couldn't find a direct example for this, so you can see how this is being used, and change it for your needs. On the client, there is a get_isInAsyncPostback() method to check if an updatepanel will be performing an async postback.
This link shows you how to cancel an update: http://www.asp.net/ajax/documentation/live/Tutorials/CancelAsyncPostback.aspx
Using the themes in this, instead of the beginRequest, you can tap into the endRequest event, and if an async postback, you can post an alert here. This assumes that the code works successfully, which are you adding that detection?
HTH.
MsgBox doesn't exist, but look at the javascript alert() function. That'll popup the message for you.
here is a link with more information on javascript popups
If you want to inject javascript from the server-side code, you can use this:
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Code processing complete.');",True)

Quiting the page before a form submission

In my application I am showing the warning message when the user want to leave the page before submitting the form. I am using window.onbeforeunload() in the script. My application has a Master page.
I have four different views for a single form. I am inserting record in first view itself.
When user quits the page I want to make some DB change(deletion of record). That's why I want to call a server side function from the script.
How to do it ? Can anybody suggest something ?
Thanks
Try using jQuery + ajax in your onbeforeunload handler.
The URL that the JavaScript calls should be a form with an onLoad method that does wha tyou need.

Resources