Sending postback to ajax loaded user controls - ajax

I have a set of tabs, which all of them together contain alot of data. I am making the tabs load async. I have one button above the tabs used to save changes. I need this button to send a postback to all the loaded user controls (using this). I need the user control to handle this postback so it can save changes.
What do you think? Any suggestions?

Tried doing it, doesn't work. I am going to have to do some magic with updatepanels and a custom postback.

Related

spring form submission in a popup

I have a small problem in my first spring&hibernate application.
In my page, I would like to create a popup window (modal) which gives the possibility to send an email. So, this popup would display a spring form with a fied "subject" and a field "content".
The question is : how can I use the form binding mechanism of spring with this popup form if I don't want my main page (displayed behind the popup form) to be reloaded?
If i am not wrong, the content of the popup is a div present in the main page. So, If I submit the form in the popup, the whole page will be reloaded (through the mvc mechanism of spring) and this is exactly what I don't want.
Of course, I can submit my form via an ajax call to a spring controller, but in this case, how to handle the eventual errors in the form? I cannot use the spring form binding mechanism to display the errors on the popupform. Is it possible?
Do you know if there is a way to open a new window in a modal popup? So that this page and only this page would be reloaded during the submission of the form?
Actually, I am not sure of the best way to combine a popup containing a form and the form submission mechanism of spring. How to display the errors on the form in case of errors? after reload of the page, If there are some errors, I need to open my popup again in javascript and then display the errors on the popup, this is the only mean I see, but maybe there are easier solutions.
If you have, I would be happy to know it.
thanks a lot

Is AJAX only for dynamic content or can it also create buttons, and change css properties?

I was wondering, is Ajax only for dynamic content update or can it also, say, create a few buttons in a given div depending on what action a user chooses in another div? For example, if the login page and first page look very similar by only a few buttons, once proper login credentials are entered, can I use Ajax to make the other three buttons appear once logged in properly, rather than going to a whole another web page that has those buttons hard coded in the html/css? If this is possible, I'll take pointers to any tutorials. Thanks.
AJAX is just for creating HTTP requests using javascript, in order to prevent full page requests.
What you can do is to process the login request using AJAX and then, depending on the response you send, to display an error or update the DOM with the logged in interface.
If you just want to change the DOM, you use javascript directly (jquery would help) but no AJAX is needed.

Tablesorter disable pager button not working when using ajax

The disable pager functionality is not working as I would expect when using ajax with tablesorter. The pager controls are disabled but the complete set of rows is not retrieved and shown. When not using ajax, it works fine - ie the complete set of rows is shown.
I notice that clicking on the disable pager button triggers the showAllRows function in the jquery.tablesorter.pager file. Then showAllRows calls pagerArrows if ajax is being used. This last function only seems to manipulate the css for the pager controls and does not re-render the table. Is this working properly for others?
Thanks
This does sound like a problem. I would recommend opening an issue so that it can be tracked and addressed.
I am on a sabbatical at the moment, so if the caretakers of the repository are unable to take care of it, I will look into this issue upon my return. Sorry for the delay.

Lotus Web Form Scroll and Popup issue

I am trying to create a web form in Lotus Notes that is web enabled. So far this has all worked fine, however there are 2 issues.
When Creating a Java Script Alert in the OnLoad Event, it Pops up everytime a user selects a radio button or dropdown option since this reloads the page. Is there any way to make this only for the initial opening of the form?
When a user selects an option, the form reloads and puts that form field on the top which is proving to be very disorrienting for users. Is there a way to have it not scroll on reload?
Thanks in advance!
The best advice would be: use XPages for web development that is "state of the art". If you can't, you have to code a lot of JavaScript to make the form not behave like "havoc".
First of all: the field property "refresh fields on keyword change" is the reason for the jumping / reload.
What does domino do?
All events / formulas that occur when you normally press F9 or use the Option above (that can be field values, input translations, hide whens, etc.) are not "converted" to HTML and javascript but are executed by the server. Therefor each change in a field with the option set submits the form and adds an &Seq=x to the url to keep track of the state. X increments on every reload. Of course this reload causes all events to be triggered again.
For you this means:
Option
disable the option to reload the form after keyword change.
Unfortunately you have to recode every dependency / calculation / hide when with javascript. Using a framework like jquery or dojo this is possible, but a lot of work.
If there IS no dependency then just disable the option...
Option
Live with the "jumping" and let your onload event check for the existance of an URL- parameter called seq... And only if it does not exist, then it is a "real" OnLoad...
Both options are not quite nice and not very easy to code...
That's one reason why IBM started XPages... There all this stuff is already handled by default...

Call interrupted by page load

I am a beginner using ajax and I always thought that it is completely asynchronous. But I discovered that a call can be interrupted by a page reload or a page change (like clicking on a hyperlink). I was under the impression that when an ajax call is started, it is carried out no matter what the browser does afterwards. Is that wrong?
Now to the specific problem I am having: think of an online test where users answer questions (by typing into textboxes). When a textbox loses focus, an ajax call is triggered which persists the value of the textbox to a DB. That works well when changing between textboxes. However, I also have a submit button which triggeres a post action to another page (it is the submit button). When I enter something into a textbox and click on the button afterwards, the call is not carried out. Moreover, when I type into a textbox, click somewhere else (also triggering the call) and swiftly click on the submit button, the call is also not made. Is that expected behaviour?
The reason I am using ajax in the first place is to persist the values so when something unforseeable happens, like a browser crash, the already typed in text is already saved.
Is my way of thinking wrong? How would you go about solving this problem?
Thank you for your time!
AJAX is asynchronous.
When you send an AJAX request the javascript engine sends it off and sets up a handler for the response.
However, if you send an AJAX request to the server and then navigate away from the page before it is received, nothing will happen. Why? Because with each page load the entire Javascript environment is tore down and reinitialized, it has no idea what happened on the last page.
For your problem I would intercept the form submit action and do whatever you need to do with the data, and then submit the form.
Edit: In response to your comment. You are correct. If the ajax request is sent, and you're not depending on it's return value, then it should not matter.
I'd suggest debugging your problem with Firebug to see if the AJAX call is really being sent properly, and to confirm your server is properly processing it.
Unless you do something special with persistent local storage, all javascript and ajax calls are blown away when a new page is loaded over the current page. Also when a submit is done on a form.
To save things intra-page, save the data asap. Eg, perhaps save on key-up, perhaps periodically with a timer, not just on lose-focus.
Re submitting the page: change the on-click behavior to first store, then to go to a new page.
All of the effects that you are seeing are normal.
Also, be sure to test on both slow (ie 6 or 7) and fast browsers (chrome)

Resources