Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

ZK Component extractor

Digital Innovation Partner

ZK Component extractor

Hello,

today we share a little tool for extracting components name and id from a standard zul file.

schermata-component-extractor-google-chrome-1

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

Tags: , , , , ,

3 risposte

  1. Ashish ha detto:

    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

  2. Riccardo ha detto:

    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…)

  3. Ivan ha detto:

    Riccardo un articolo veramente interessante !!

Lascia un commento