-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello, all.
I recently started studying ZK and I think it is pretty awesome. However, the Java documentation seems to be lacking (I couldn't find documentation on Richlets - except the java doc). That's why I will try to phrase a few questions that remained unanswered:
1) How can one load a Stylesheet from a Richlet? I tried using the Stylesheet class, but with no result.
2) How can one load a piece of Groovy script into a Richlet? I tried using the ZScript, but with no result.
3) Is there any reading material on the "Richlet" topic, besides the java doc? I do not intend to use ZUML because of certain constraints.
Thanks in advance!
Best regards,
Dani
With Richlet you get a Page which you can use to add your components and what you add is simular to the components you have in a zul file. Even a zscript is a component and you can add it to the page and fill in your groovy script code as string (but in Richlet you probably need no script, since you can do everything in java). Each component/element you can add in zul has a corresponding Java Class you can append to your component tree in the richlet... as i believe also a stylesheet element.
I use a HTML Layout with stylesheets in Richlet and render from String with a createComponentsDirectly Method.
/thomas
ZScript is not a component:
public class ZScript
extends java.lang.Object
implements Condition, java.io.Serializable
Nor is Stylesheet:
public class StyleSheet
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable
Neither ZScript, nor Stylesheet have a setParent() method.
Can someone help with a small code snippet to illustrate how to use these two classes?
Thanks.
Dani
If you program a RichLet you shouldn't need Zscript.
You can find the documentation of how to do RichLets in the Developer's Guide.
To use stylesheet you have a couple of smalltak's on ZK site.
/fselva
That's the beauty of ZK: it lets you load different kinds of scripts. It should be possible to load a Groovy script written by a third party (you provide a basic API and the end-user writes his own custom scripts). Thus, it should be possible.
As for the Stylesheet, the only thing related to stylesheets in Small Talks is "Customizing Look and Feel, Part I - CSS" which is not useful (I know how to set a styles and a class for a component, but I do not know how to LOAD the CSS file).
Thanks.
BR,
Dani
hmmm... long time ago with an older zk release i have seen something concerning zscript and stylesheet in a debugger... probably stylesheet and zscript are stored as attributes somewhere in page or desktop... you might have a look at a zul page or desktop with stylesheets and zscripts with a debugger to find where to set them.
Ok, for #1 I have found the solution. So, in order to load a stylesheet from a Richlet:
Style style = new Style("/style/main.css");
style.setPage(page);
Any suggestions on the other two points?
BR,
Dani
Answer for #2 (west is a region in o BorderLayout - it's id must be "west"):
StringBuffer content = new StringBuffer();
content.append("west.setStyle(\"border: 3px solid red;\");");
ZScript z = new ZScript(null, "Groovy", content.toString(), null);
try {
new ZScriptInitiator(z).doInit(page, null);
} catch (Exception e) {
e.printStackTrace();
}
(Only supported in the Enterprise version)
Thank you all for the suggestions!
BR,
Dani
Asked: 2009-01-14 07:41:56 +0800
Seen: 342 times
Last updated: Jan 15 '09