B4J Question Works in Debug but not in Release

Dogbonesix

Active Member
Licensed User
Longtime User
I have a WEB app that work fine in Debug but does not in Release
I am using jAWRRobot to launch a URL where the variable ndz is any URL I am using.

rbt.SystemOpenAddressInBrowser(ndz)

Work great in Debug but I can't get it to work in Release mode.

Or, is the a better way to launch a URL? Thanks for any help.
 

stevel05

Expert
Licensed User
Longtime User
Try
B4X:
fx.ShowExternalDocument(URL)
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
I found the library - jFX.
I loaded the library - Private fx As JFX
It compiled
BUT crashes as soon as I hit Module calling callind JFX
Below are a starting errors

Waiting for value (100 ms)
Waiting for value (100 ms)
java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
If it's a nonUI app the the fx.ShowExternalDocument is unlikely to work as it requires JavaFX.

Try this:



B4X:
ShowURI("http://google.com") 'Call


Public Sub ShowURI(Address As String)
    Dim Desktop As JavaObject
    Desktop.InitializeStatic("java.awt.Desktop")
    Desktop = Desktop.RunMethod("getDesktop",Null)
    Dim URI As JavaObject
    URI.InitializeNewInstance("java.net.URI",Array(Address))
    Desktop.RunMethod("browse",Array(URI))
End Sub

Tested on Windows, they are standard java classes so should work on Mac.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Then I would think there is something else going wrong within your app. Are there any messages in the log? Can you post an example project where it fails?
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
Apparently so. Running Debug presents no errors. I don't know how to trace the errors in Runtime.
I added the code to the Sub Class_Globals and on the Sub sendclicked_click(params As Map) I added ShowURI(ndz) where ndz is the URL.
JavaObject is in my Labrary. Any other resource needed? I will keep all posted.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I'm not sure I understand what you have done, Sub Class_Globals should only contain variable definitions. It would be much easier to help if you could post some example code.
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
Attach is one of the Modules. When extracted it is in ODF format and all the color is overwhelming but the areas of code are highlighted in Yellow. Is there a better way to display the code?
 

Attachments

  • Google.zip
    29.1 KB · Views: 167
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
I found the problem but not the fix.

In Debug it is using the correct link but in Release it is using the WRONG link!

If you run grok3.com use the Login Grok and PWD as 12. Select Grok, BlgID: 43 and the next screen there will be a button called Goo Docs - Click it.
A listbox will appear at the botton with the link: (which is correct)

Grok Link: https://docs.google.com/document/d/1r-2-Vc532noWtP8L4hNL8tv2FEY5dqnZ02Y27nBsotU/edit?usp=sharing

BUT when right click the link and copy the link you get:

*http://grok3.com/indexblg.html?blgid=43&blgname=Grok, Blg #
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
How is the link created?
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
The link is created by referencing a MySql table that has a field called Label and Link. When the record is saved the label is User Input and the Link is Pasted from google docs. A ListBox query is then run to populate the ListBox which concentrates the Label along with the Link (LabeNamel http Link). The Sub SendClicked_Click then extracts only the Link which I use the variable ndz (no particular reason). Then ShowURI(ndz) executes the Public Sub ShowURI(Address As String) as below

Public Sub ShowURI(Address As String)
Dim Desktop As JavaObject
Desktop.InitializeStatic("java.awt.Desktop")
Desktop = Desktop.RunMethod("getDesktop",Null)
Dim URI As JavaObject
URI.InitializeNewInstance("java.net.URI",Array(Address))
Desktop.RunMethod("browse",Array(URI))
End Sub
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
It looks to me as if the link on the page is not created properly. Although the link is displayed correctly I would guess that the href for the link points to the wrong address. It is not visible in the source code of the page.
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
I think I am making way too complicated. All I want to do start a new tab with the selected URL.

Something like this should work bldgp.sethtml("<a href=" & "'" & ndz & "'" & " Target = "_blank" rel="noopener noreferrer"></a>") but I can't get syntax right.

I there any to keep it simple?
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Use smartstrings, you don't have to worry about which quote you use.

something like
B4X:
 bldgp.sethtml($"<a href="${ndz}" Target = "_blank" rel="noopener noreferrer">${LinkName}</a>"$)
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
I've never worked with webapps, so don't know what options are available. If it works, that's great.
 
Upvote 0

Dogbonesix

Active Member
Licensed User
Longtime User
Solved
Original Query
retHtml = retHtml & "<li ><a href='#' class='blacktext nolist listboxitems' onclick=""copyClick('GooID=" & thing.Get("ID2") & "Label=" & thing.Get("Label") & "Link=" & thing.Get("Link") & "')"" >" & thing.Get("Label") & " Link: " & thing.get("Link") & "</a></li>"
Solution:
retHtml = retHtml & "<li ><a href='" & thing.get("Link") & "' class='blacktext nolist listboxitems' target='_blank' >" & thing.Get("Label") & " Link: " & thing.get("Link") & "</a></li>"
The solution does NOT use the ClickEvent - Just click the displayed line in the listbox
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…