0

ZK with Java Questions

asked 2009-01-14 07:41:56 +0800

zknewbie gravatar image zknewbie
108 2

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

delete flag offensive retag edit

7 Replies

Sort by ยป oldest newest

answered 2009-01-14 10:52:25 +0800

oberinspector gravatar image oberinspector
219 2 2

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

link publish delete flag offensive edit

answered 2009-01-14 11:41:15 +0800

zknewbie gravatar image zknewbie
108 2

updated 2009-01-14 11:41:36 +0800

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

link publish delete flag offensive edit

answered 2009-01-14 12:12:25 +0800

fselva gravatar image fselva
66 1

updated 2009-01-14 12:12:57 +0800

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

link publish delete flag offensive edit

answered 2009-01-14 12:27:21 +0800

zknewbie gravatar image zknewbie
108 2

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

link publish delete flag offensive edit

answered 2009-01-14 13:40:37 +0800

oberinspector gravatar image oberinspector
219 2 2

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.

link publish delete flag offensive edit

answered 2009-01-15 11:35:51 +0800

zknewbie gravatar image zknewbie
108 2

updated 2009-01-15 11:36:09 +0800

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

link publish delete flag offensive edit

answered 2009-01-15 14:56:15 +0800

zknewbie gravatar image zknewbie
108 2

updated 2009-01-15 14:56:59 +0800

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

link publish delete flag offensive edit
Your reply
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: 2009-01-14 07:41:56 +0800

Seen: 342 times

Last updated: Jan 15 '09

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