ZK Component extractor
today we share a little tool for extracting components name and id from a standard zul file.
The idea behind this tool borns after readingÂ this small talk byÂ Ashish Dasnurkar and after a comment on his works. I think in ZK there are many ways to access components from controller class (i.e. getFellow(), Composer, CDI…) but none of them save us from writing component variable declaration. This is why i need this tool.
There is a working demo at this link. Here are the source of the standalone zul page. I used a regular expression (<(\w*) [^>]*id=[“|’](\w*)[“|’][^>]*) to parse the zul file, it sounds a simply and reasonable approach to me. Another approach could be to create the components via the Execution.createComponents() and iterating over component tree, but it will be a little more complex and involve security risk, so i choose the easy way.
Thank you and see you next time