B4J Question ABMaterial: Black screen when adding new page

techknight

Well-Known Member
Licensed User
Longtime User
So, its been a minute since I messed with ABMaterial but I am having a problem that I cant seem to figure out.

So, if I take an existing page/class, Copy, and Paste it, Rename and add it to the project, then change the Page name in the class to the name I had named the class.

I then go into Main, and add/initialize the added page.

However, if I load said page while the App is running, its just a black screen. And thats without changing anything in the page. The original that I copied from works perfect still.

But that copy/pasted page does not work. Even after being properly renamed, and added as an additional page. Its being weird.

if I view the Console in chrome, I get a js exception:

B4X:
BaseballLayoutVertical.1561476920759.js:27 ready to connect the websocket
core.4.38.min.js:1 Using RobustWebSocket
core.4.38.min.js:1 WebSocket opened, reconnected?: false
VM249:3 Uncaught ReferenceError: cans is not defined
    at eval (eval at b4j_eval (core.4.38.min.js:1), <anonymous>:3:114)
    at b4j_eval (core.4.38.min.js:1)
    at x.<anonymous> (core.4.38.min.js:1)
    at x.dispatchEvent (core.4.38.min.js:1)
    at WebSocket.<anonymous> (core.4.38.min.js:1)
eval @ VM249:3
b4j_eval @ core.4.38.min.js:1
(anonymous) @ core.4.38.min.js:1
x.dispatchEvent @ core.4.38.min.js:1
(anonymous) @ core.4.38.min.js:1
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat
BaseballLayoutVertical.1561476920759.js:22 heartbeat

The original page was BaseballLayout, and I pasted it/renamed it as BaseballLayoutVertical, and changed the pagename to that as well in the code.

I am at a loss. Any ideas?
 

alwaysbusy

Expert
Licensed User
Longtime User
Did you run the code in debug mode first? This is needed in this case because it has to investigate if this page needs the canvas javascript libraries.

This error gives the indication: Uncaught ReferenceError: cans is not defined
cans is part of the javascript that is needed to hold the canvas(es) for this page.
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
yea I can run it in debug mode. But my question is, Why would this happen to begin with? it works on the other page that I copied this from.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
mysterious framework
There is some logic in it ;-)

In debug mode, the B4J source code files are available to ABM and it is checked if a page uses certain 'special' components, like e.g. the Canvas. If they are, it is written in the .needs file. When running in release mode, the source files are not (always) available so it reads this .needs file instead. That is also the reason why you must put the .needs files next to your released .jar on your VPS server.

If you immediately run in release mode, this .needs file has not been updated, hence the extra javascript/css libraries for this component are not loaded for this page.

This system was build to make ABM as fast as possible, avoiding to load unneeded javascript/css files.

Alwaysbusy
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
There is some logic in it ;-)
That was what I was eluding to, as stated in the dummies tutes.
"When first it may fail, run it in debug to build the required requisite file(s)"...

As my new kitten (as of yesterday) is licking my ear - how sweet and precious it is...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…