Search code examples
htmlzk

ZK Component won't show under html tag


I want to show a hyperlink <a /> component under a html tag and then do some instructions onClick="@command('')" :

<zk>
 <html>
   <a label="show me" onClick="@command('showMe')" />
 </html>
</zk>

but the componet won't show. I tried adding <zk xmlns:zk="zk" xmlns:z="zul>" and then <z:a> and <zk:a> but it didn't work.

--->If I remove the <html> tag the component appears.

Don't ask me why the html tag I just need to use it or I'll change a lot of things


Solution

  • Do you need the <html> tag to be rendered in the output HTML ?

    Maybe try the native namespace :

    <zk xmlns:n="native">
      <n:html>
        <a label="show me" onClick="@command('showMe')" />
      </n:html>
    </zk>
    

    But it may not keep the <html> tag in the rendered HTML.

    I think you have to go with the XHTML Component Set (be aware that as stated in the documentation it has some limitations and lower performances, you should use it only if there is no better way).

    Your code would be something like :

    <html xmlns:zk="zk" xmlns:z="zul">
      <a label="show me" zk:onClick="@command('showMe')" />
    </html>
    

    If your file extension is .zul, it will automatically generate <html>, <head>, and <body> tags so it may not help. But if you want to control it by yourself, use .zhtml, .xhtml, .html or .htm file extension.

    You also cannot use the HTML component (<![CDATA[ ... ]] notation) as it will replace the <html> tag with a <span>.