0

createComponentsDirectly with directive

asked 2023-05-27 06:06:41 +0800

agsiegel gravatar image agsiegel
6 1

updated 2023-05-27 06:08:34 +0800

Is it possible to use the following with createComponentsDirectly?

<?link rel="stylesheet" type="text/css" href="/css/theme.css"?> 
<vlayout>
    <label sclass="s1">Hello</label>
</vlayout>

Does not seem to work for me. The css link does not get processed.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-31 19:53:01 +0800

MDuchemin gravatar image MDuchemin
2560 1 6
ZK Team

Hey there,

The processing instruction will add the link (or script if using ?script) to the page headers during initial page rendering.

If you are creating this content with createComponents (or createComponentsDirectly), you are not creating a page. You are creating a set of components from a page definition.

As a result, that set of components doesn't contain a style component, since it's not in the page definition, but a processing instruction.

You have a few options here. You can move the style into the actual zul content with a style component

plus side: this will add the style as a component in the page, so you can do it at any point (initial page rendering, page update), and it will work through createComponents and derivated methods.

Other option would be to use org.zkoss.zk.ui.sys.PageCtrl.addAfterHeadTags(String) (from the page object) to add the tag manually into the page definition.

IMPORTANT NOTE: this will only work during page rendering. If you are loading this content post page creation, use style component instead.

link publish delete flag offensive edit

Comments

Thank you!!

agsiegel ( 2023-06-01 09:39:09 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2023-05-27 06:06:41 +0800

Seen: 6 times

Last updated: May 31 '23

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More