haxeui / haxeui-html5

The HTML5 backend of the HaxeUI framework -
http://haxeui.org
MIT License
28 stars 14 forks source link

ComponentMacros.buildComponent - No class found for component #4

Closed hoseyjoe closed 7 years ago

hoseyjoe commented 7 years ago

"WARNING: no class found for component" occurs when ComponentMacros.buildComponent is called outside of the static calls

Expected Behavior

I expected the Macro to run wherever it is called?

Steps to Reproduce (for bugs)

  1. on the Main class of the application call new Main()
  2. in the new function call ComponentMacros.buildComponent

    Test app / minimal test case

Small.zip

Your Environment

This appeared to work in flash (maybe CPP) but did not work in HTML5

ianharrigan commented 7 years ago

In your test app its missing a "RecordListByUser.xml" file

ianharrigan commented 7 years ago

Ok, there are / were quite a few issues with the test app you posted, however, once i fixed all those the issue that you are having is you are calling:

mainView = ComponentMacros.buildComponent("assets/ui/main.xml");

in the constructor before you are calling Toolkit.init(). The Toolkit.init() is responsible for a number of things, one of which is populating the "component registry" based on scanning the classpath. So thats why it doesnt work (ie, the component registry is empty). Moving Toolkit.init() to the first line in the constructor solves the issue.

hoseyjoe commented 7 years ago

Sorry Ian.

ianharrigan commented 7 years ago

No probs... Easy mistake. :)

hoseyjoe commented 7 years ago

I uploaded a previous zip. I must not have re zipped what I thought was issue. I have the issue in my code base but it seems to follow the rules. If I can get repeat I will reopen

hoseyjoe commented 7 years ago

I am sure it is the initialization order. this compiles in haxeui-nme but throws "WARNING: no class found for component". Small.zip

My end goal was to have a tableview that gets its layout in xml but the DS is provided dynamically

ianharrigan commented 7 years ago

Agreed, something is wrong here. Even if i just move the <tableview/> into main.xml the same thing happens. Ill investigate.

ianharrigan commented 7 years ago

Actually, thats not true, the problem is that the code is built for AddATable.newComponent before the init macro has run and therefore populated the component registry.

ianharrigan commented 7 years ago

Ok, one line fix... :)

Can you retest and close if fixed?

Cheers, Ian

ianharrigan commented 7 years ago

Also, btw, there is an <import /> statement also, eg:

<vbox>
  <import resource="..." />
  <import resource="..." />
  <import resource="..." />
</vbox>

You dont have to use it of course, but in can help and remove duplication sometimes. :)