B4J Question [ABMaterial] Reading text from an ABMInput on sub table giving an error

John Naylor

Active Member
Licensed User
Longtime User
ABM 4.51, B4J 8.5

I'm experiencing a similar problem to one which I had here however without a container being involved.

I've created a table, each row of which can have multiple sub tables. Each of those sub tables has an ABMInput control on it.

I can access all the controls and can read text in all the normal fields. I can get a link to the ABMInput control. When i try to read the text that I've typed into it I get a NullPointerException.

Code that I'm using to check things...


B4X:
            'Ok that's the main table row done - now to whatever data is in the subtables
            
            Dim SubTable As ABMTable = StockSearchTable.GetComponent (0,"UID" & m.Get("id"))
            SubTable.PrepareTableForRetrieval
            
            For y = 0 To 999
            
                Dim s As Map
                s.Initialize

                s.Put("did",m.Get("id"))               
                s.Put ("sid",SubTable.GetString(y,0))    'This works fine and returns a value

                Dim stb As ABMInput = SubTable.GetComponent(y,"usetb" & y)  'This also works and I get the ABMInput control
                
                Dim t As String = stb.Text   'This throws an error
                
                s.Put ("QtyStock", t)
                
                
                stable.Add(s)
            Next

I've checked futuretext and it's not showing anything - as follows...

ABM1.png


error as soon as I try to read the text field

ABM2.png


Any thoughts? Bug? Something in my setup?

TIA!
 

John Naylor

Active Member
Licensed User
Longtime User
this look weird:

B4X:
For y = 0 To 999

Looking at your log ABM was able to get some of them. Is is just possible that y has reached a number where the "usetb" & y does not exist? Maybe put a log(y) in the loop.

Alwaysbusy

Sadly not - this is at its first itteration through the loop and there is definitely data there. The test table(s) have two rows in the main and 3 sub tables. I do as expected get an error when I have checked all of those.
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
if the above does not work, can you make a screenshot like the first one where I can see all the properties of the ABMInput?
No luck with that.

Screenshots attached - should I drill down further in any particular areas?
 

Attachments

  • 1.png
    1.png
    18 KB · Views: 161
  • 2.png
    2.png
    18.6 KB · Views: 163
  • 3.png
    3.png
    17 KB · Views: 158
  • 4.png
    4.png
    11.4 KB · Views: 158
  • 5.png
    5.png
    18.3 KB · Views: 157
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Maybe if you can just in the Browser - F12 check what the exact id of such an input is (it will probably be something like uid247_0_7__usetb0). I was hoping the ParentString in your screenshots would reveal that. I just don't get why the future is null, and without it, it can not retrieve the text value.

If we have the exact ID, we can then try this manually:
B4X:
Dim txt As JQueryElement = page.ws.GetElementById("whateverexactidwegot")
Dim text As Future = txt.GetVal
Log(text.Value)

It is in theory the same as what ABM does internally.

Alain
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Maybe if you can just in the Browser - F12 check what the exact id of such an input is (it will probably be something like uid247_0_7__usetb0). I was hoping the ParentString in your screenshots would reveal that. I just don't get why the future is null, and without it, it can not retrieve the text value.

If we have the exact ID, we can then try this manually:
B4X:
Dim txt As JQueryElement = page.ws.GetElementById("whateverexactidwegot")
Dim text As Future = txt.GetVal
Log(text.Value)

It is in theory the same as what ABM does internally.

Alain

Doing it this way logs the value that I've typed into the input box!
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
You must trap for null values - as I have found...
example:
B4X:
    ' you must be careful with NULL fields...  or you will crash!
            If tblFields.Get("casesummary") = Null Or tblFields.Get("casesummary") = "" Then
                Dim descs As String = "-" 'tblFields.Get("casesummary") is null or blank...
            Else
                Dim descs As String = tblFields.Get("casesummary")
            End If
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
You must trap for null values - as I have found...
example:
B4X:
    ' you must be careful with NULL fields...  or you will crash!
            If tblFields.Get("casesummary") = Null Or tblFields.Get("casesummary") = "" Then
                Dim descs As String = "-" 'tblFields.Get("casesummary") is null or blank...
            Else
                Dim descs As String = tblFields.Get("casesummary")
            End If

Not a null issue in this case as it falls over on the first iteration and there's definately data there.

My code was initially just to make sure I was getting what I expected - I'll make sure to trap null once I've figured out what's going on though.
 
Upvote 0
Top