I'm trying to change the typed value of a text field catching the onChange event of this field.
It refreshes the value of an expression placed on the same div as the text field, but doesn't change the typed value of the text field. The only way I found to change the value of the text field, was catching the onchange of a check box.
You can see my example in the attached oml.
In attachment I'm showing your example with the modifications I have suggested.
After setting the bound variable, I do an Ajax refresh of the second Web input widget and expect to see 'bar' as the widget should be updated with the value of the now changed bound attribute - But it shows nothing. I have traced the whole action and everything but the last ajax refresh step is working as expected.
I have changed the refesh to a full page Submit instead of Ajax and it all works - but it refreshes the whole form and that isn't what I wanted to do!
Does your variable has the value 'foo' (whatever you typed in the first input) inside the screen action that is called by the on change and has the ajax widget?
My guess is that the variable is not being updated. Perhaps trying to send the local variable as an input to the screen action?
Would anyone be able to look at my example model and anwer my query?
I just tried your oml and it worked fine, the only thing I needed to do was create a record with Foovalue = "foo" and DefaultBarValue = "bar".
Are you still having troubles with this?
Thanks for picking this up - I get the 'bar' in the temporary field but not in the one bound to the database field. I am wondering if it may be a configuration problem but I have tried two different machines and both have the problem with this test model. It doesn't work in IE 8 or Firefox (on either machine I have tried).
One thing to note is that I am using the default install of Outsystems 5.0.2.6 Community edition, generating out .NET and MSSQL. Both machines I have tested are using this edition and are using the default install of IIS that comes as part of this install. Neither machine had any version of Outsystems on them. I have checked the IE 8 is 'up-to-date'. One other thing is that my machine is vista x64 and the other is windows 7 - could this be the issue? I use the 32bit IE by default.
What environment did it work for you in?
That's strange... I've tried it on Chrome, IE8 and firefox 3.5.8 and it worked fine on all of them displaying the "bar" in both input boxes. I'm also using 5.0.2.6 community edition with default install and .NET and MSSQL... the only real difference is I'm using a 32bit windows XP but that doesn't seem like a probable cause for this difference in behavior.
Have you tried the approach suggested by Tiago Simões?
I've just tried it on your oml and works like a charm, and its a better solution than calling the action with the "onChange".
I have done some more digging and replicated the behaviour on XP too - but I can see what is happening now.
If I type very slowly "f"...."o"....."o".... without the tab - then it all works ok - I get both 'bar's!
There seems to be a race condition where if I type "foo-tab" very fast (as I was since I'm a touch typer!) then your cursor is already in the variable bound 'Bar Attrib' field at the time to on change action fires and it does not overwrite the contents of this field - the cursor just flickers a couple of times and the field stays blank. I have proven this by typing "foo-tab-tab" very quickly such that the cursor is in the temporary field - and in that case the the second bar is not displayed.
Is there something that inhibits the ajax-refresh action if the cursor is in the specified field?
Namely "Hi Drew, you can't change the displayed value of an input box (using AJAX) while it is on focus. This might be your problem."
At least thet explains the apparently inconsistent behaviour. I think this nugget of info needs to be easier to find and the solution explicitly brought out (in the training perhaps) - My guess is that it is a common problem that isn't easy to see why it doesn't work.