Ajax Refresh in 4.2

Ajax Refresh in 4.2

  
Hi,

I'm trying to change the typed value of a text field catching the onChange event of this field.

But it doesn't work.

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.

Does anyone know how to solve this?
Thanks, Gonçalo.
Hi Gonçalo,

Changing the text of the input would make the user loose the position of the text beam cursor and that could be annoying for end-users. Maybe what you are trying to do is to change the text when the focus moves out of that input. For that my best advice is to create an extended property onblur where in JavaScript you could click an invisible button (e.g. "document.getElementById('" + invisibleButtonName.Id+ "').click()" ) that would do what you want in Ajax.


Let me know if this helps.

Cheers,
Tiago Simões
In attachment I'm showing your example with the modifications I have suggested.
Cheers,
Tiago Simões

I am also trying to do something very similar to the original problem (with the very latest Community edition)

I have two fields on an single record Edit screen.  When the user types something into the first text field ('foo' say) I want to capture this and change the value in the other field to be some corresponding default value ('bar' to keep with tradition!)

I am trying to do this by capturing the change with an OnChange action on the first field which then tries to set the value of the bound attribute variable of the  second Web input widget (this is because you can't change the .Value of the widget (doesn't exist) - or the .TypedText value that is read only)

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!

Why doesn't it behave the way I expect?  Can it be done another way in Outsystems without resorting to new javascript events?

Rgds,
Paul.



 

Hi Paul,

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?


Best Regards,

Diogo C S Cordeiro

I think the attached example shows exactly what I am trying to do...  Please could you try running this to see what my problem is - If it was working as I wanted it then you would see:

foo
bar     bar

on this screen.

Rgds,
Paul.
Would anyone be able to look at my example model and anwer my query?

Rgds,
Paul.
Paul,

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?

cheers,
Hermínio Mira


Hermínio,

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?

Rgds,
Paul.
Paul,

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?
"
For that my best advice is to create an extended property onblur where in JavaScript you could click an invisible button (e.g. "document.getElementById('" + invisibleButtonName.Id+ "').click()" ) that would do what you want in Ajax.
"

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".

Cheers,
Hermínio
Hermínio,

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?

I take your point that what I really wanted was a 'OnLoseFocus' event which the OnBlur will give - but, as you say, you can't attach an Outsystems Action to this - it grates that I have to write hidden button javascript when I was wanting to try and use Outsystems actions for the whole interaction.

Thanks for your help so far,

Rgds,
Paul.


To finish this off...

The last comment in the following thread answers my question:

http://www.outsystems.com/NetworkForums/ViewTopic.aspx?Topic=Formatting-user-inputs

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.