B4J Question [ABMaterial] Get ABMInput text

Blueforcer

Well-Known Member
Licensed User
Longtime User
Hello,

i added the ABMInput in Class_Globals
B4X:
Dim inpText As ABMInput

Then i add the Component to the page with
B4X:
inpText.Initialize(page,"inpText",ABM.INPUT_TEXT,"Text",False,"")
page.Cell(7,2).AddComponent(inpText)

But with inpText.text i always get an empty String. What is the correct way to get the entered text?
 

alwaysbusy

Expert
Licensed User
Longtime User
Don't declare ABMInput in globals, just where you create it.

Then use .Component() when you use it (like you want to get the .Text). The reason for that is because .Component() does more than just 'getting' the components java object, it also syncs the java object with the html object in the browser.

So in short:

in connectPage() or wherever you add it to the page:

B4X:
...
Dim inpText As ABMInput
inpText.Initialize(page,"inpText",ABM.INPUT_TEXT,"Text",False,"")
page.Cell(7,2).AddComponent(inpText)
...

In e.g. a button click (or where you want to get the current text back):
B4X:
...
Dim inpText As ABMInput = page.Component("inpText") ' syncs the ABMInput object with the browsers value
log(inpText.Text)
...
 
Upvote 0
Top