Unhandled OutOfBoundsException

Well Greg,

You didn’t as for CurrentJobID in your earlier request but I just did that.

Session.LogDebugData(Str(CurrentJobID)) Session.LogDebugData(Str(Ubound(Session.JobData,1))) Session.LogDebugData(Str(Ubound(Session.JobData,2))) Session.LogDebugData(Str(WebPage1.ListBox_Jobs.LastIndex))
The application opens with a Current Job ID of zero If Job Selected returns True from querying the database for the Job data
As I Expected the log output in the IDE Debug mode after the application shown returned:

0 4188 10 4188

After clicking the second cell in the listbox the log held the following data:

0 4188 10 4188 1 4188 10 4188
Finally after scrolling to the last cell in the listbox and clicking it the log held the following data.

0 4188 10 4188 1 4188 10 4188 4188 4188 10 4188

When repeating the same steps on a build of the same code, replacing all files, libs, etc.) the result was:
at application shown:

0 4188 10 4188

After clicking the second cell in the listbox the “Unhandled OutOfBoundsException” immediatly occured.

One last thing, The exact same error occurs if I do nothing more than attempt to scroll the ContainerControl contents using either the mouse scroll wheel or clicking on the ContainerControl scroll bar.

However if I click on one of the WebImageView controls in the ContainerControl it gives the expected result of opening the medium-res image associated the thumbnail in a web dialog without any errors with the exception that the horizontal and vertical centering isn’t working the same way as in the IDE like the progress whell I mentioned in an earlier post^.

What works perfectly in the IDE fails miserably in the built app. I’m not trying to bash Xojo. I started using RB when it was version 2 and love the development environment. I’m not making this issue up and I’d really like to resolve what is causing it. It is not my array of data. I truly think there is a bug that hasn’t yet been identified but this back and forth hashing over the same idea that it’s an index problem in my code is getting tiresome. If that is the case why does the error occur during scrolling? zero code is being used then other than what is native to the ContainerControl and that is Xojo code NOT mine.

Can you show me what code runs when you click the cell?

It doesn’t matter what code is in the cell. It can simply be a MsgBox to display the row number and it fails with the same “Unhandled OutOfBoundsException” (scroll up for that previous experiment^).

However, here is the code that is supposed to be in the cell that works in the IDE and all the code it subsequently calls.

[code]WebPage1.CellClick(Row As Integer, Column As Integer)
Dim b As Boolean

b = Session.JobSelected(Row)

If b = True Then
Timer_HideThumbs.Mode = 1
Else
MsgBox “Error retrieving Job Data”
End If
[/code]

[code]Sub Session.JobSelected(CurrentJobID As Integer) As Boolean
Dim rs As RecordSet
Dim sqlStrng As String
Dim i,n As Integer

Session.LogDebugData(Str(CurrentJobID))
Session.LogDebugData(Str(Ubound(Session.JobData,1)))
Session.LogDebugData(Str(Ubound(Session.JobData,2)))
Session.LogDebugData(Str(WebPage1.ListBox_Jobs.LastIndex))

WebPage1.ThumbsCoreCC.Visible = False
WebPage1.ProgressWheel1.Visible = True
WebPage1.LabelLoadingThumbs.Visible = True
Session.ControlsEnableState(False)

// JOB_ARCHIVE_ID=0 JOB_NAME=1 JOB_NUMBERID=2 JOB_YEARID=3 CUSTOMER_NAME=4 CD_TRIM_SIZE=5 CD_BINDING=6 DELIVERY_CODE=7 NUMBER_OF_COPIES=8 ACTUAL_SHIP_DATE=9

Session.dbJobID = Session.JobData(CurrentJobID,0)
Session.dbJobName = Session.JobData(CurrentJobID,1)
Session.dbJobYearID = Session.JobData(CurrentJobID,3)
Session.dbJobCustomerName = Session.JobData(CurrentJobID,4)
Session.dbJobTrimSize = Session.JobData(CurrentJobID,5)
Session.dbJobBindingStyle = Session.JobData(CurrentJobID,6)
Session.dbNumPages = Session.JobData(CurrentJobID,7)
Session.dbJobDeliveryCode = Session.JobData(CurrentJobID,8)
Session.dbJobNumCopies = Session.JobData(CurrentJobID,9)
Session.dbJobShipDate = Session.JobData(CurrentJobID,10)

WebPage1.JobInfoCC.Label_dbJobName.Text = “Job Name: " + Session.dbJobName
WebPage1.JobInfoCC.Label_dbJobNumber.Text = “Job Number: " + NthField(Session.dbJobName,”-”,1)
WebPage1.JobInfoCC.Label_dbJobYear.Text = "Job Year: " + Session.dbJobYearID
WebPage1.JobInfoCC.Label_dbJobCustomerName.Text = "Customer Name: " + Session.dbJobCustomerName
WebPage1.JobInfoCC.Label_dbJobTrimSize.Text = " Trim Size: " + SelectTrimSize(Session.dbJobTrimSize)
WebPage1.JobInfoCC.Label_dbJobBindingStyle.Text = "Binding Style: " + SelectBindingStyle(Session.dbJobBindingStyle)
WebPage1.JobInfoCC.Label_dbJobNumPages.Text = "Pages: " + Session.dbNumPages
WebPage1.JobInfoCC.Label_dbJobNumCopies.Text = "Copies: " + Session.dbJobNumCopies
WebPage1.JobInfoCC.Label_dbJobDeliveryCode.Text = "Delivery: " + Session.dbJobDeliveryCode
WebPage1.JobInfoCC.Label_dbShipDate.Text = "Ship Date: " + ConvertDate(Session.dbJobShipDate)

// Re-dimension the Jobs Thumbnail and Medium Res image data for the core book pages
ReDim Session.ThumbsCoreData(-1,-1)

// Query the DB for the Job image data into a recordset
sqlStrng = “SELECT FILE_NAME, THUMBNAIL_PATH, MEDIUM_RES_PATH, PAGE_TYPE, PAGE_NUMBER FROM page_data WHERE JOB_ARCHIVE_ID = '” + Session.dbJobID + “’ AND PAGE_TYPE = ‘Core’”
// FILE_NAME=0 THUMBNAIL_PATH=1 MEDIUM_RES_PATH=2 PAGE_TYPE=3 PAGE_NUMBER=4

rs = Session.MySQLDB.SQLSelect(sqlStrng)

//Append each record into the ThumbsCoreData array
If rs <> NIL Then
n = rs.RecordCount - 1
i = rs.FieldCount -1
ReDim Session.ThumbsCoreData(n,i)
n = 0
While Not rs.EOF
For i = 1 To rs.FieldCount
Session.ThumbsCoreData(n,(i - 1)) = rs.IdxField(i).StringValue
Next
n = n + 1
rs.MoveNext
wend
Return True
Else
ShowAlert(“Database Error”,"Database Error " + EndOfLine + Session.MySQLDB.ErrorMessage + “.”,“Caution”)
Return False
End If
End Sub[/code]

WebPage1.Timer_HideThumbs.Action Session.HideThumbs

[code]Sub Session.HideThumbs
Dim i,n As Integer
Dim p As WebPicture

p = blankthumb
If Not p.Preload Then
// Browser was unable to preload the picture
// Not handling False condition
End If

n = (WebPage1.ThumbsCoreCC.ControlCount / 3) -1

For i = 0 To n 'Ubound(Session.ThumbsCoreData,1)

WebPage1.ThumbsCoreCC.ImageViewThumb(i).Visible = False
WebPage1.ThumbsCoreCC.ImageViewThumb(i).Top = 0
WebPage1.ThumbsCoreCC.ImageViewThumb(i).Left = -200
WebPage1.ThumbsCoreCC.ImageViewThumb(i).Picture = p

WebPage1.ThumbsCoreCC.LabelThumbName(i).Visible = False
WebPage1.ThumbsCoreCC.LabelThumbName(i).Top = 0
WebPage1.ThumbsCoreCC.LabelThumbName(i).Left = -200
WebPage1.ThumbsCoreCC.LabelThumbName(i).Text = ""

WebPage1.ThumbsCoreCC.LabelThumbType(i).Visible = False
WebPage1.ThumbsCoreCC.LabelThumbType(i).Top = 0
WebPage1.ThumbsCoreCC.LabelThumbType(i).Left = -200
WebPage1.ThumbsCoreCC.LabelThumbType(i).Text = ""

Next

WebPage1.Timer_RetrieveThumbs.Mode = 1
End Sub[/code]

WebPage1.Timer_RetrieveThumbs.Action Session.ThumbsCoreCreate

[code]Sub Session.ThumbsCoreCreate
Dim i,picWidth,picHeight As Integer
Dim b As Boolean
Dim img As FolderItem
Dim FilePath As String
Dim ImgBox As WebImageView
Dim DescName,DescType As WebLabel
Dim pic As WebPicture

// Retrieve the thumbnail paths and add WebPictures to the ControlSet creating controls if they don’t already exist
For i = 0 to UBound(Session.ThumbsCoreData,1)
If WebPage1.ThumbsCoreCC.ImageViewThumb(i) = Nil Then
ImgBox = WebPage1.ThumbsCoreCC.AddImageViewThumb
DescName = WebPage1.ThumbsCoreCC.AddLabelThumbName
DescType = WebPage1.ThumbsCoreCC.AddLabelThumbType
End If
FilePath = Session.ThumbsCoreData(i,1)
img = GetFolderItem(FilePath)
If Not (img = Nil) Then
If img .Exists Then
pic = WebImageView.Picture.Open(img)
// Preload the images to the web browser as the images are retrieved
If Not pic.Preload Then
// Browser was unable to preload the picture
// Not handling False for now
End If
Else
// Not Available images based on book Trim Size
If Session.dbJobTrimSize = “7” Then
pic = NA7
ElseIf Session.dbJobTrimSize = “8” Then
pic = NA8
ElseIf Session.dbJobTrimSize = “9” Then
pic = NA9
End If
End If
End If
picWidth = pic.Width
picHeight = pic.Height
WebPage1.ThumbsCoreCC.ImageViewThumb(i).Width = picWidth
WebPage1.ThumbsCoreCC.ImageViewThumb(i).Height = picHeight
WebPage1.ThumbsCoreCC.ImageViewThumb(i).Picture = pic
WebPage1.ThumbsCoreCC.LabelThumbName(i).Text = Session.ThumbsCoreData(i,0)
WebPage1.ThumbsCoreCC.LabelThumbType(i).Text = Session.ThumbsCoreData(i,3) + " Page"
Next

// Arrange the thumbnail images control sets in the ContainerControl
b = Session.ThumbsCoreArrange

// Make the Progress wheel invisible and the ContainerControl visible
If b = True Then
WebPage1.ProgressWheel1.Visible = False
WebPage1.LabelLoadingThumbs.Visible = False
Session.ControlsEnableState(True)

WebPage1.ThumbsCoreCC.Visible  = True

End If
End Sub[/code]

[code]Sub Session.ThumbsCoreArrange As Boolean
// Dimension the variables that need to be calculated
Dim idx,column,row,columnLeft,rowTop,rowCount,columnCount As Integer

// Dimension the number of pictures in the Picture Array ThumbsCore()
Dim ImageCount As Integer = Ubound(Session.ThumbsCoreData,1)

// calculate the desired image spacing variables
Dim Hspacing As Integer = 20
Dim Vspacing As Integer = 44
Dim posLeft As Integer = 0
Dim posTop As Integer = 0
Dim MaxWidth As Integer = 144
Dim MaxHeight As Integer = 192
Dim columnWidth As Integer = MaxWidth + Hspacing
Dim rowHeight As Integer = MaxHeight + Vspacing

// Calculate the number of columns
columnCount = WebPage1.ThumbsCoreCC.Width / columnWidth
If (WebPage1.ThumbsCoreCC.Width - (columnCount * columnWidth)) > (columnWidth / 2) Then
columnCount = columnCount + 1
End If

// Calculate the number of columns
rowCount = (ImageCount / columnCount)
If (ImageCount - (rowCount * columnCount)) > 0 Then
rowCount = rowCount +1
End If

// Set the image index to zero
idx = 0

// Arange the ContainerControl’s control sets in a grid og rows and columns
for row = 0 to rowCount
rowTop = (posTop + (row * rowHeight))
for column = 0 to columnCount -1
columnLeft = (posLeft + (column * columnWidth))
WebPage1.ThumbsCoreCC.ImageViewThumb(idx).Left = ColumnLeft + ((MaxWidth - WebPage1.ThumbsCoreCC.ImageViewThumb(idx).Width) / 2)
WebPage1.ThumbsCoreCC.LabelThumb(idx).Left = ColumnLeft
WebPage1.ThumbsCoreCC.ImageViewThumb(idx).Top = RowTop + (MaxHeight - WebPage1.ThumbsCoreCC.ImageViewThumb(idx).Height) / 2
WebPage1.ThumbsCoreCC.LabelThumb(idx).Top = (RowTop + 198)
WebPage1.ThumbsCoreCC.ImageViewThumb(idx).Visible = True
WebPage1.ThumbsCoreCC.LabelThumb(idx).Visible = True
If idx = ImageCount Then
Return True
Else
idx = idx + 1
End If
next column
next row

Return True
End Sub[/code]

[quote=134393:@Tom Dixon]After clicking the second cell in the listbox the “Unhandled OutOfBoundsException” immediatly occured.
[/quote]

I did not realize that was a JavaScript error, and not a Xojo code exception. Could it be a problem with the framework ? Maybe you could copy all the error report from the JavaScript black box and send that to Greg so he can check what is wrong ?

I though JavaScript executed in the browser, so it should not be influenced by the nature of the host, but since here it works in debug and not on the server… Would the app on the server be cgi ? That could account for the difference in behavior ?

Since you do not mention you are using JavaScript, I doubt you can do much to alleviate the error, anyway.

Maybe change the way your UI is laid out ? Take the container control out of the set ? Just hypothezing in the dark…

Michael,

Yes it is CGI. That is the default for a Xojo Windows build so it is how I installed the App on IIS. Other than that I have no other reason to use CGI if there is another method that Xojo apps orks with IIS. Also, I’m only using IIS since it is built into Windows server.

I actually had no clue that it was a javascipt error. There was noting in the error dialog to indicate that to me. This is my first Xojo Web app. I usually do Desktop Apps but this application was perfectly suited for a browser implementation. I started it over a year ago, put it aside and then picked it back up a couple weeks ago.

I would really hate to have to not use a ContainerContol and ConrolSets. That would be a lot of work to re-create what they do automatically and may still be equally unstable on the web server.

I also don’t have a clue where to start looking for the JavaScript black box error report or if Greg will find it usable. I’ll wait until I get a reply from him and continue to work on the app features until then.

Thanks for your input.

There are two ways to run a web app : standalone and cgi. When you run it in the IDE, it is standalone, so there is a big difference between debug and host. It may ultimately play a role in the way the page is handled.

What told me it is a JavaScript error and not a Xojo code error is this screen picture you posted :

The black frame with two boxes entitled “This application has encountered an error and cannot continue” is a JavaScript error, not a Xojo error. The top box hopefully contains an error dump, after the “Stack:” which can give a clue as to where exactly the error happened.

As I wrote, am shooting in the dark. The idea is not to undo what you have created, but to identify exactly what triggers the error. For instance, if the Listbox is part of the container control, maybe trying to put a copy of it on the window itself instead of the container control, do you still get the error in cellclick. Same thing for the container control which is, if I understand right, part of a control set. What happens if it was not part of a control set ? I would do that in a test project, copy of the actual project, just for experimentation …

Michael,

The Lisbox is on WebPage1 and not in a ContainerControl. It helps drive what is displayed in the ContainerControl which is one WebImageView and two WebLabels all indexed zero.

My code shown above creates additional controls in the ContainerControl to display the image data from a specific job retrieved from a MySQL database. You were mistaken that there was a control set of ContainerControls. The image below is the app running in the IDE and I have recently added a second ContainerControl to show covers and ensheets sparately.

This just shouldn’t be that difficult to accomplish and isn’t outside of what WE apps should be able to do.

Indeed.

I might be stumbling upon a similar issue. I started getting an outofbounds exception on the WebListBox when I called deleteAllRows and loaded in new content when the user had a row selected. Apparently after I removed the rows, it still thinks row ‘whatever’ is should still be selected even though it no longer exists.

For what it’s worth, this is NOT a JavaScript error. This is the Xojo exception being forwarded to the browser because you don’t have the UnhandledException handler defined, Or a try-catch around the offending code.

For what it’s worth, my current feeling is that this has to do with latency. Many users get caught by the fact that events from the browser happen in one particular order when debugging locally and a slightly different order when running on the web. This is because we don’t control how quickly packets get sent from point A to point B.

Tim, we still need to know where in that method this error occurs. When you get the JavaScript error dialog next time, do me a favor and do a select all on the text in the top section. I’d like to know if there’s more info that we can’t see.

Forgive the ‘back to basics’ question, but do you have any custom drawing in the celltext or cellbackground paint events?
And if so, do those check that the row is less than listcount?

Apologies if a red herring, but…

Jeff T, Nope. It’s a plain vanilla ListBox.

Greg, Select all reveals no additional information.

[code]Unhandled OutOfBoundsException
Message:

Stack:
[/code]

[quote=134603:@Jeff Tullin]Forgive the ‘back to basics’ question, but do you have any custom drawing in the celltext or cellbackground paint events?
And if so, do those check that the row is less than listcount?

Apologies if a red herring, but…[/quote]
This is a web project. Those events don’t exist.

[quote=134605:@Tom Dixon]Jeff T, Nope. It’s a plain vanilla ListBox.

Greg, Select all reveals no additional information.

[code]Unhandled OutOfBoundsException
Message:

Stack:
[/code][/quote]
Well I can honestly say that I’m stumped. Even if you were hitting a framework by, there’d be a stack.

This issue is still unresolved. I’ve continued to work on the app as time has permitted to finish up some features that were only roughed in. I just created a build and installed on the web server and the problem still exist along with a couple of other issues that do not occur in the IDE debug mode.

  1. Clicking on a cell in the listbox causes an out of bounds exception as before.

  2. attempting to scroll the thumbnail listbox causes a series of three out of bounds exceptions and yet it still scrolls correctly after the out of bounds error messages are closed.

  3. When the web page is shown the app it is supposed to calculate the horizontal and vertical center for displaying a WebDialog and also for calculating how many columns of thumbnails can be shown. That works fine in the IDE debug but there appears to be a limitation on width in the built app. The WebDialog shows off center to the upper left and there is unused screen real estate for additional thumbnail columns on the right.

I am more than willing to have someone look at my code, (Greg O’Lone?), ether via a WebEx I host or sending you the project. The WebEx may be the best option since I cannot send the database and image library. I am honestly stumped too. The app does exactly what I want it to do in the debugger but fails miserably when installed on my Web server. HELP!