B4J Question [ABMaterial] ABMInput.Text = ABMInput.Text.Trim doesn't work


Active Member
Licensed User
I don't know if this is related to ABMaterial, but I encountered this in my ABMaterial project.

Just like the title says. I've setup a code for someone else to test:

Dim inpUsername As ABMInput = mLoginContainer.Component("inpusername")
Dim inpPassword As ABMInput = mLoginContainer.Component("inppassword")
Log ("orig ul: " & inpUsername.Text.Length & " orig pl: " & inpPassword.Text.Length)
inpUsername.Text = inpUsername.Text.Trim
inpPassword.Text = inpPassword.Text.Trim
Log ("trim ul: " & inpUsername.Text.Length & " trim pl: " & inpPassword.Text.Length)
Dim iu As String = inpUsername.Text
Dim ip As String = inpPassword.Text
iu = iu.Trim
ip = ip.Trim
Log ("string trim ul: " & iu.Length & " string trim pl: " & ip.Length)

it gives the following result :
orig ul: 15 orig pl: 10
trim ul: 15 trim pl: 10
string trim ul: 14 string trim pl: 10

I will cast the input.text as a string before trimming but it would be nice to know why it doesn't work directly with the Text property of ABMInput.


Licensed User
Longtime User
.Text is a wrapper around a SimpleFuture. It is a two step procedure:

inpUsername.Text = inpUsername.Text.Trim

The: inpUsername.Text.Trim gets the text from the browser and trims it.
The: inpUsername.Text 'prepares' to set the text for the browser (but does nothing at this point in the browser)

So when you call inpUsername.Text again:

Log ("trim ul: " & inpUsername.Text.Length & " trim pl: " & inpPassword.Text.Length)

you're actually asking the browser again, what do you have? --> so it returns the original text from the browser.

Only when a .refresh happens, the actual 'trim' version is pushed to the server.
Upvote 0