ZK Component extractor
Hello,
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.
Hoping some guys from zkoss will accept the feature request to integrate this feature directly in zk studio.
Comments appreciated,
Thank you and see you next time
3 risposte
Hi Riccardo,
This came real fast. You only mentioned it couple days ago. Very useful tool for those refactoring their zscript code into ZK MVC style programming or even just kick starting your Controller classes 😉
Thank you for taking time to work on this. Much appreciated.
– Ashish
Hi Ashish,
i am happy to contribute, and it takes only a couple of hour of work thanks to zk fast development (and regular expression power too…)
Riccardo un articolo veramente interessante !!