- 浏览: 106682 次
- 性别:
- 来自: 济南
-
文章分类
最新评论
-
try-:
引用引用引用引用引用引用引用引用引用引用引用引用引用引用引用引 ...
SVN服务器设置及访问问题 -
try-:
引用引用引用引用引用引用引用引用引用引用引用引用引用引用引用引 ...
SVN服务器设置及访问问题 -
try-:
引用引用引用引用引用引用引用引用引用引用引用引用引用引用引用引 ...
SVN服务器设置及访问问题 -
try-:
...
SVN服务器设置及访问问题 -
try-:
[flash=200,200][flash=200,200][ ...
SVN服务器设置及访问问题
How to access resources in another application
1.Let us assume you have another application called app2. Then, you can access the resource by use of "~app2/your/resource/path".
For example,
<include src="~app2/main/foo.zul"/>
Notice that the Web container might prevent you from accessing other Web applications. In this case, org.zkoss.lang.SystemException(("Context not found or not visible to....") will be thrown. To enable it you have to configure the Web container properly.
2.In context.xml, specify crossContext="true" to the Context element:
<Context crossContext="true">
[edit] How to add a hyperlink?
Use toolbarbutton or button component and specify the href attribute. e.g. The following code would generate ZK - Simple and Rich hyperlink.
<toolbarbutton label="ZK - Simple and Rich" href="http://tw.yahoo.com"/>
<button label="Rich Internet Application" href="http://www.zkoss.org/zkdemo/userguide"/>
You can also mix xhtml and xul together so you can create normal hyperlinks e.g
<window title="mix HTML demo" xmlns:h="http://www.w3.org/1999/xhtml">
<button label="zul hyperlink button" href="http://www.google.com/"/>
<h:a href="http://www.google.com">xhtml hyperlink</h:a>
</window>
see the demo and the developer guide for more examples.
[edit] How to convert AWT Image to ZK Image
import java.io.ByteArrayOutputStream;
import java.awt.image.RenderedImage;
import javax.imageio.ImageIO;
import org.zkoss.image.Image;
import org.zkoss.image.AImage;
Image encode(RenderedImage image) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "png", os);
return new AImage("my-image.png", os.toByteArray());
}
Since 3.0.7 and 3.5.0, there is an utility class called org.zkoss.image.Images to simply the encoding job.
[edit] How to include the same page twice?
With the include component, you could include any page multiple times as follows.
<include src="/mypage.zul"/>
<include src="/mypage.zul"/>
However, if you want to access the component inside of them, you have to assign a unique identifier of the page being included. Here is what you can do.
<include src="/mypage.zul?pageId=first"/>
<include src="/mypage.zul?pageId=second"/>
In additions, in the page being include, i.e., mypage.zul in this example, you have to write
<?page id="${param.pageId}"?>
Then, you could access their component.
Path.getComponent('//first/asdf/');
Path.getComponent('//second/asdf/');
Notice that components are created as late as the Rendering phase, so you could access them only in the event listener for the following events:
<window>
<zscript><![CDATA[
/**
* in a real application we would use something like
* List iterateOverMe = sessionScope.get("listToRender");
*/
String[][] iterateOverMe = {
{"99", "Fred Flintstone"}
,{"8", "Wilma Flintstone"}
,{"65", "Barney Rubble"}
,{"32", "Betty Rubble"}
};
]]></zscript>
<tabbox mold="accordion">
<tabs>
<!-- more realisticly my iterateOverMe would be a List of
pojos so that I can write ${each.label} -->
<tab forEach="${iterateOverMe}" label="${each[1]}"/>
</tabs>
<tabpanels>
<!-- more realisticly my iterateOverMe would be a List of
pojos so that I can write ${each.id} -->
<tabpanel forEach="${iterateOverMe}" >
<include src="/render-item.zul?pageId=${each[0]}"/>
</tabpanel>
</tabpanels>
</tabbox>
</window>
In that page we pull in search-item.zul once for each object the search results list and we give the included page a pageId that is the identifier of the item that is to be rendered i.e. 99,8,65,32. Within render-item.zul:
<?page id="${param.pageId}"?>
<zscript>
// Here we have to use param.pageId to locate the object that we will render
Object itemToRender = ... // use param.pageId as the identifer to locate specific object to render at this time
</zscript>
<vbox>
<button label="${itemToRender.label}"/>
</vbox>
In this file is included four separate times and param.pageId differs each time i.e. 99,8,65,32. Each time the page is called we use the param.pageId to find the business item to be rended.
[edit] How to initialize a component if extending it to a custom class?
Say, we extend Tabbox with MyTabbox as follows.
public class MyTabbox extends Tabbox {
...
Then, you could initialize it using two methods: the constructor and the onCreate event.
public class MyTabbox extends Tabbox {
public MyTabbox() {
...//some init
}
public void onCreate() {
...//other init
}
}
The constructor is called before members are assigned with initial values, while onCreate is processed after the whole page is loaded.
However, the onCreate event will not be sent if you create the component programmatically, instead of declaring in a ZUML page.
[edit] How to redirect to another page when processing an event?
Use the sendRedirect method of the Execution interface to ask the browser to redirect to another page. All updates to the current page/desktop are dropped.
void onClick() {
if (some_condition)
Executions.sendRedirect("another_page");
}
[edit] How to refresh inner pages only?
First, use include component and specifies the src attribute to include whatever page you want (ZK, JSP, JSF or whatever) inside a ZK page. Second, you can dynamically change it by changing the src attribute. e.g. The following code would change the inner page from hello.zul to byebye.zul when an end user press the Bye! button.
<include id="inner" src="hello.zul"/>
<button label="Bye!" onClick="inner.src = "byebye.zul""/>
If you simply want to reload the same page(and not to change to another page), you have to set the src attribute to null first; then set the src attribute back to what it was. Because ZK optimizes operations, set same value to the same attribute would be deemed doing nothing. e.g. The following code would refresh the hello.zul page when an end user press the Reload button.
<include id="inner" src="hello.zul"/>
<button id="reload" label="Reload" onClick="String tmp=inner.src; inner.src=null; inner.src=tmp;"/>
If you want to programmatically call the reload button from the event handler of another button after doing some other work you can dispatch the current event to the button just by refering to it by id with
Events.sendEvent(reload,event)
as follows:
<button label="Do Lots Of Stuff Then Pass The Click To The Reload Button">
<attribute name="onClick">
{
doLotsOfStuff();
Events.sendEvent(reload, event);
}
</attribute>
</button>
[edit] How to lazy load tabs to speed up the loading of a very large page?
Cread the following page and two other pages "tab1.zul" and "tab2.zul" in the same folder. In tab1.zul and tab2.zul put a <window> containing any zul that you would like (hint go to the demo page and click the "Try Me" buttons and cut-n-paste some large source).
<?page id="main-page"?>
<window id="main-window">
<tabbox width="400px">
<attribute name="onSelect">{
//alert("selected index:"+self.selectedIndex);
if(self.selectedIndex > 0 ) {
Include inc = (Include)Path.getComponent("//main-page/main-window/tab"+self.selectedIndex);
inc.setSrc("tab"+self.selectedIndex+".zul");
}
}</attribute>
<tabs>
<tab label="Tab 0"/>
<tab label="Tab 1"/>
<tab label="Tab 2"/>
</tabs>
<tabpanels>
<tabpanel>This is panel 0 and it does not have an include</tabpanel>
<tabpanel>
<include id="tab1" src=""/>
</tabpanel>
<tabpanel>
<include id="tab2" src=""/>
</tabpanel>
</tabpanels>
</tabbox>
</window>
Only when you click on "Tab 1" and "Tab 2" are is the content of tab1.zul and tab2.zul loaded and their components created. To prove this to yourself comment out the line starting
inc.setSrc("tab"+self.selectedIndex+".zul");
then refresh the page and click on the tabs and you wont see any xul from tab1.zul or tab2.zul as these files will not be loaded after commenting out the event handler code that loads them.
[edit] How to specify line-break in Label's attribute
XML parses considers line breaks as regular whitespaces, so it won't work by using
<label value="line 1
line 2"/>
Instead, use the attribute element as follows:
<label>
<attribute name="value">line 1
line 2</attribute>
</label>
[edit] How to use "each" variable of "forEach" attribute in onXxx event handler?
[edit] Example1 (incorrect)
<window title="Countries" border="normal" width="100%">
<zscript><![CDATA[
// Here we have an array of countries
// We will generate a bunch of buttons per this array
// When the button is click, an alert window will show the country name.
String[] countries = {"China", "France", "Germany", "United Kindom", "United States"};
]]></zscript>
<hbox>
<!-- WARNING THIS IS INCORRECT USE "Example 3" -->
<button label="${each}" forEach="${countries}" onClick="alert(${each})"/>
</hbox>
</window>
The Example1 is not correct. The EL expression cannot be used in onXxx() event handler. It will throws an exception "Attempt to access property on undefined variable or class name" when button is clicked because the alert(${each}) in onClick is directly interpreted as java codes.
[edit] Example2 (incorrect)
<window title="Countries" border="normal" width="100%">
<zscript><![CDATA[
// Here we have an array of countries
// We will generate a bunch of buttons per this array
// When the button is click, an alert window will show the country name.
String[] countries = {"China", "France", "Germany", "United Kindom", "United States"};
]]></zscript>
<hbox>
<!-- WARNING THIS IS INCORRECT USE "Example 3" -->
<button label="${each}" forEach="${countries}" onClick="alert(each)"/>
</hbox>
</window>
Example2 rewrites alert(${each}) to alert(each). Because each is an implicit object, it should be ok to write it directly in onClick just like other implicit object. However, click the button would still throw an exception "Undefined argument: each". The reason is simple. While each is an implicit object, it is a temporary implicit object. It exists only when the zuml page is being evaluated. When the button is clicked, that original each has gone already.
Then how do we reference each variable of forEach attribute in onXxx() event handler? The key is to store the temporary each variable when the zuml page is evaluated and use that stored object when onXxx event is fired.
[edit] Example3 (correct)
<window title="Countries" border="normal" width="100%">
<zscript><![CDATA[
// Here we have an array of countries
// We will generate a bunch of buttons per this array
// When the button is click, an alert window will show the country name.
String[] countries = {"China", "France", "Germany", "United Kindom", "United States"};
]]></zscript>
<hbox>
<button label="${each}" forEach="${countries}"
onClick="alert(componentScope.get("country"))">
<custom-attributes country="${each}"/>
</button>
</hbox>
</window>
Example3 uses the button's custom-attributes map (componentScope) to store the temporary each object when the zuml page is evaluated and use that stored object later when the button is clicked.
[edit] How to make a Grid's row and column drag-n-drop?
By Bakoma
--------------------------------------------------------------------------------
A Grid consists of Columns and Rows where each Columns has columns as the Columns' children. Similarly, Rows has rows as its children.
Here is a simple Grid with head columns and three rows:
Name Age Grade
Mike 29 C
Todd 21 B
Tony 37 A
The following codes will put the above into a Grid with the rows and columns draggable and droppable. Here are the steps:
Create Grid
Add Columns, and specify each column is draggable and droppable provided that they are of the same type , columns.
<columns>
<column label="Name" draggable="col" droppable="col" onDrop="move(event.dragged)"/>gunawan
<column label="Age" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
<column label="Grade" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
</columns>
Add Rows, and specify each row is draggable and droppable.
<rows>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Mike" />
<label value="29" />
<label value="C" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Todd" />
<label value="21" />
<label value="B" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Tony" />
<label value="31" />
<label value="A" />
</row>
</rows>
Implement the event handling function. Make sure to move the corresponding cells as well when moving the columns.
void move(Component dragged) {
if(dragged.getClass().getName().endsWith("Column")) {
int maxRows=dragged.getGrid().getRows().getChildren().size();
int i= dragged.getParent().getChildren().indexOf(dragged);
int j= self.getParent().getChildren().indexOf(self);
//move celles for each row
for(int k=0; k < maxRows; k++)
self.getGrid().getCell(k,j).parent.insertBefore(self.getGrid()
.getCell(k,i),self.getGrid().getCell(k,j));
}
self.parent.insertBefore(dragged, self);
}
Put them together to get the complete codes:
<zk>
<grid>
<columns>
<column label="Name" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
<column label="Age" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
<column label="Grade" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
</columns>
<rows>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Mike" />
<label value="29" />
<label value="C" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Todd" />
<label value="21" />
<label value="B" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Tony" />
<label value="31" />
<label value="A" />
</row>
</rows>
</grid>
<zscript><![CDATA[
void move(Component dragged) {
if(dragged.getClass().getName().endsWith("Column")) {
int maxRows=dragged.getGrid().getRows().getChildren().size();
int i= dragged.getParent().getChildren().indexOf(dragged);
int j= self.getParent().getChildren().indexOf(self);
//move celles for each row
for(int k=0; k < maxRows; k++)
self.getGrid().getCell(k,j).parent.insertBefore(self.getGrid()
.getCell(k,i),self.getGrid().getCell(k,j));
}
self.parent.insertBefore(dragged, self);
}
]]></zscript>
</zk>
[edit] How to generate ©?
<html>Copyright &copy; Super Co.</html>
Explanation: & is a way to pass & to the content property of the html component. And, the html component directly outputs the content property to the browser.
On the other hand, it won't work if the label component, since label will encode its content.
<label>Copyright &copy; Super Co.</label>
[edit] How to set the forward property by program
org.zkoss.zk.ui.sys.ComponentsCtrl.applyForward(comp, "onClick");
[edit] How to enable logging in ZK
1. First, Set up the log configuration in your application's zk.xml file. I just used an empty string.
<zk>
<log>
<log-base></log-base>
</log>
</zk>
2. Create an i3-log.conf configuration file and place it in the Tomcat's /conf folder. It should include the following lines.
org.zkoss.testlog=DEBUG
org.zkoss=ERROR
3. Remember to modify the logging.properties file in your Tomcat's /conf folder. The default ConsoleHandler's level is INFO, so you won't see any DEBUG message otherwise. java.util.logging.ConsoleHandler.level = INFO to java.util.logging.ConsoleHandler.level = FINEST 4. If you want to output specific messages from your program
private static final Log log = Log.lookup(org.zkoss.testlog.Foo.class);
if(log.debugable()){
log.debug("a log for debug message");
}
if(log.infoable()){
log.info("a log for info message");
}
http://en.wikibooks.org/wiki/ZK/How-Tos/Frequently_Asked_Questions
1.Let us assume you have another application called app2. Then, you can access the resource by use of "~app2/your/resource/path".
For example,
<include src="~app2/main/foo.zul"/>
Notice that the Web container might prevent you from accessing other Web applications. In this case, org.zkoss.lang.SystemException(("Context not found or not visible to....") will be thrown. To enable it you have to configure the Web container properly.
2.In context.xml, specify crossContext="true" to the Context element:
<Context crossContext="true">
[edit] How to add a hyperlink?
Use toolbarbutton or button component and specify the href attribute. e.g. The following code would generate ZK - Simple and Rich hyperlink.
<toolbarbutton label="ZK - Simple and Rich" href="http://tw.yahoo.com"/>
<button label="Rich Internet Application" href="http://www.zkoss.org/zkdemo/userguide"/>
You can also mix xhtml and xul together so you can create normal hyperlinks e.g
<window title="mix HTML demo" xmlns:h="http://www.w3.org/1999/xhtml">
<button label="zul hyperlink button" href="http://www.google.com/"/>
<h:a href="http://www.google.com">xhtml hyperlink</h:a>
</window>
see the demo and the developer guide for more examples.
[edit] How to convert AWT Image to ZK Image
import java.io.ByteArrayOutputStream;
import java.awt.image.RenderedImage;
import javax.imageio.ImageIO;
import org.zkoss.image.Image;
import org.zkoss.image.AImage;
Image encode(RenderedImage image) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
ImageIO.write(image, "png", os);
return new AImage("my-image.png", os.toByteArray());
}
Since 3.0.7 and 3.5.0, there is an utility class called org.zkoss.image.Images to simply the encoding job.
[edit] How to include the same page twice?
With the include component, you could include any page multiple times as follows.
<include src="/mypage.zul"/>
<include src="/mypage.zul"/>
However, if you want to access the component inside of them, you have to assign a unique identifier of the page being included. Here is what you can do.
<include src="/mypage.zul?pageId=first"/>
<include src="/mypage.zul?pageId=second"/>
In additions, in the page being include, i.e., mypage.zul in this example, you have to write
<?page id="${param.pageId}"?>
Then, you could access their component.
Path.getComponent('//first/asdf/');
Path.getComponent('//second/asdf/');
Notice that components are created as late as the Rendering phase, so you could access them only in the event listener for the following events:
<window>
<zscript><![CDATA[
/**
* in a real application we would use something like
* List iterateOverMe = sessionScope.get("listToRender");
*/
String[][] iterateOverMe = {
{"99", "Fred Flintstone"}
,{"8", "Wilma Flintstone"}
,{"65", "Barney Rubble"}
,{"32", "Betty Rubble"}
};
]]></zscript>
<tabbox mold="accordion">
<tabs>
<!-- more realisticly my iterateOverMe would be a List of
pojos so that I can write ${each.label} -->
<tab forEach="${iterateOverMe}" label="${each[1]}"/>
</tabs>
<tabpanels>
<!-- more realisticly my iterateOverMe would be a List of
pojos so that I can write ${each.id} -->
<tabpanel forEach="${iterateOverMe}" >
<include src="/render-item.zul?pageId=${each[0]}"/>
</tabpanel>
</tabpanels>
</tabbox>
</window>
In that page we pull in search-item.zul once for each object the search results list and we give the included page a pageId that is the identifier of the item that is to be rendered i.e. 99,8,65,32. Within render-item.zul:
<?page id="${param.pageId}"?>
<zscript>
// Here we have to use param.pageId to locate the object that we will render
Object itemToRender = ... // use param.pageId as the identifer to locate specific object to render at this time
</zscript>
<vbox>
<button label="${itemToRender.label}"/>
</vbox>
In this file is included four separate times and param.pageId differs each time i.e. 99,8,65,32. Each time the page is called we use the param.pageId to find the business item to be rended.
[edit] How to initialize a component if extending it to a custom class?
Say, we extend Tabbox with MyTabbox as follows.
public class MyTabbox extends Tabbox {
...
Then, you could initialize it using two methods: the constructor and the onCreate event.
public class MyTabbox extends Tabbox {
public MyTabbox() {
...//some init
}
public void onCreate() {
...//other init
}
}
The constructor is called before members are assigned with initial values, while onCreate is processed after the whole page is loaded.
However, the onCreate event will not be sent if you create the component programmatically, instead of declaring in a ZUML page.
[edit] How to redirect to another page when processing an event?
Use the sendRedirect method of the Execution interface to ask the browser to redirect to another page. All updates to the current page/desktop are dropped.
void onClick() {
if (some_condition)
Executions.sendRedirect("another_page");
}
[edit] How to refresh inner pages only?
First, use include component and specifies the src attribute to include whatever page you want (ZK, JSP, JSF or whatever) inside a ZK page. Second, you can dynamically change it by changing the src attribute. e.g. The following code would change the inner page from hello.zul to byebye.zul when an end user press the Bye! button.
<include id="inner" src="hello.zul"/>
<button label="Bye!" onClick="inner.src = "byebye.zul""/>
If you simply want to reload the same page(and not to change to another page), you have to set the src attribute to null first; then set the src attribute back to what it was. Because ZK optimizes operations, set same value to the same attribute would be deemed doing nothing. e.g. The following code would refresh the hello.zul page when an end user press the Reload button.
<include id="inner" src="hello.zul"/>
<button id="reload" label="Reload" onClick="String tmp=inner.src; inner.src=null; inner.src=tmp;"/>
If you want to programmatically call the reload button from the event handler of another button after doing some other work you can dispatch the current event to the button just by refering to it by id with
Events.sendEvent(reload,event)
as follows:
<button label="Do Lots Of Stuff Then Pass The Click To The Reload Button">
<attribute name="onClick">
{
doLotsOfStuff();
Events.sendEvent(reload, event);
}
</attribute>
</button>
[edit] How to lazy load tabs to speed up the loading of a very large page?
Cread the following page and two other pages "tab1.zul" and "tab2.zul" in the same folder. In tab1.zul and tab2.zul put a <window> containing any zul that you would like (hint go to the demo page and click the "Try Me" buttons and cut-n-paste some large source).
<?page id="main-page"?>
<window id="main-window">
<tabbox width="400px">
<attribute name="onSelect">{
//alert("selected index:"+self.selectedIndex);
if(self.selectedIndex > 0 ) {
Include inc = (Include)Path.getComponent("//main-page/main-window/tab"+self.selectedIndex);
inc.setSrc("tab"+self.selectedIndex+".zul");
}
}</attribute>
<tabs>
<tab label="Tab 0"/>
<tab label="Tab 1"/>
<tab label="Tab 2"/>
</tabs>
<tabpanels>
<tabpanel>This is panel 0 and it does not have an include</tabpanel>
<tabpanel>
<include id="tab1" src=""/>
</tabpanel>
<tabpanel>
<include id="tab2" src=""/>
</tabpanel>
</tabpanels>
</tabbox>
</window>
Only when you click on "Tab 1" and "Tab 2" are is the content of tab1.zul and tab2.zul loaded and their components created. To prove this to yourself comment out the line starting
inc.setSrc("tab"+self.selectedIndex+".zul");
then refresh the page and click on the tabs and you wont see any xul from tab1.zul or tab2.zul as these files will not be loaded after commenting out the event handler code that loads them.
[edit] How to specify line-break in Label's attribute
XML parses considers line breaks as regular whitespaces, so it won't work by using
<label value="line 1
line 2"/>
Instead, use the attribute element as follows:
<label>
<attribute name="value">line 1
line 2</attribute>
</label>
[edit] How to use "each" variable of "forEach" attribute in onXxx event handler?
[edit] Example1 (incorrect)
<window title="Countries" border="normal" width="100%">
<zscript><![CDATA[
// Here we have an array of countries
// We will generate a bunch of buttons per this array
// When the button is click, an alert window will show the country name.
String[] countries = {"China", "France", "Germany", "United Kindom", "United States"};
]]></zscript>
<hbox>
<!-- WARNING THIS IS INCORRECT USE "Example 3" -->
<button label="${each}" forEach="${countries}" onClick="alert(${each})"/>
</hbox>
</window>
The Example1 is not correct. The EL expression cannot be used in onXxx() event handler. It will throws an exception "Attempt to access property on undefined variable or class name" when button is clicked because the alert(${each}) in onClick is directly interpreted as java codes.
[edit] Example2 (incorrect)
<window title="Countries" border="normal" width="100%">
<zscript><![CDATA[
// Here we have an array of countries
// We will generate a bunch of buttons per this array
// When the button is click, an alert window will show the country name.
String[] countries = {"China", "France", "Germany", "United Kindom", "United States"};
]]></zscript>
<hbox>
<!-- WARNING THIS IS INCORRECT USE "Example 3" -->
<button label="${each}" forEach="${countries}" onClick="alert(each)"/>
</hbox>
</window>
Example2 rewrites alert(${each}) to alert(each). Because each is an implicit object, it should be ok to write it directly in onClick just like other implicit object. However, click the button would still throw an exception "Undefined argument: each". The reason is simple. While each is an implicit object, it is a temporary implicit object. It exists only when the zuml page is being evaluated. When the button is clicked, that original each has gone already.
Then how do we reference each variable of forEach attribute in onXxx() event handler? The key is to store the temporary each variable when the zuml page is evaluated and use that stored object when onXxx event is fired.
[edit] Example3 (correct)
<window title="Countries" border="normal" width="100%">
<zscript><![CDATA[
// Here we have an array of countries
// We will generate a bunch of buttons per this array
// When the button is click, an alert window will show the country name.
String[] countries = {"China", "France", "Germany", "United Kindom", "United States"};
]]></zscript>
<hbox>
<button label="${each}" forEach="${countries}"
onClick="alert(componentScope.get("country"))">
<custom-attributes country="${each}"/>
</button>
</hbox>
</window>
Example3 uses the button's custom-attributes map (componentScope) to store the temporary each object when the zuml page is evaluated and use that stored object later when the button is clicked.
[edit] How to make a Grid's row and column drag-n-drop?
By Bakoma
--------------------------------------------------------------------------------
A Grid consists of Columns and Rows where each Columns has columns as the Columns' children. Similarly, Rows has rows as its children.
Here is a simple Grid with head columns and three rows:
Name Age Grade
Mike 29 C
Todd 21 B
Tony 37 A
The following codes will put the above into a Grid with the rows and columns draggable and droppable. Here are the steps:
Create Grid
Add Columns, and specify each column is draggable and droppable provided that they are of the same type , columns.
<columns>
<column label="Name" draggable="col" droppable="col" onDrop="move(event.dragged)"/>gunawan
<column label="Age" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
<column label="Grade" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
</columns>
Add Rows, and specify each row is draggable and droppable.
<rows>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Mike" />
<label value="29" />
<label value="C" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Todd" />
<label value="21" />
<label value="B" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Tony" />
<label value="31" />
<label value="A" />
</row>
</rows>
Implement the event handling function. Make sure to move the corresponding cells as well when moving the columns.
void move(Component dragged) {
if(dragged.getClass().getName().endsWith("Column")) {
int maxRows=dragged.getGrid().getRows().getChildren().size();
int i= dragged.getParent().getChildren().indexOf(dragged);
int j= self.getParent().getChildren().indexOf(self);
//move celles for each row
for(int k=0; k < maxRows; k++)
self.getGrid().getCell(k,j).parent.insertBefore(self.getGrid()
.getCell(k,i),self.getGrid().getCell(k,j));
}
self.parent.insertBefore(dragged, self);
}
Put them together to get the complete codes:
<zk>
<grid>
<columns>
<column label="Name" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
<column label="Age" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
<column label="Grade" draggable="col" droppable="col" onDrop="move(event.dragged)"/>
</columns>
<rows>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Mike" />
<label value="29" />
<label value="C" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Todd" />
<label value="21" />
<label value="B" />
</row>
<row draggable="row" droppable="row" onDrop="move(event.dragged)">
<label value="Tony" />
<label value="31" />
<label value="A" />
</row>
</rows>
</grid>
<zscript><![CDATA[
void move(Component dragged) {
if(dragged.getClass().getName().endsWith("Column")) {
int maxRows=dragged.getGrid().getRows().getChildren().size();
int i= dragged.getParent().getChildren().indexOf(dragged);
int j= self.getParent().getChildren().indexOf(self);
//move celles for each row
for(int k=0; k < maxRows; k++)
self.getGrid().getCell(k,j).parent.insertBefore(self.getGrid()
.getCell(k,i),self.getGrid().getCell(k,j));
}
self.parent.insertBefore(dragged, self);
}
]]></zscript>
</zk>
[edit] How to generate ©?
<html>Copyright &copy; Super Co.</html>
Explanation: & is a way to pass & to the content property of the html component. And, the html component directly outputs the content property to the browser.
On the other hand, it won't work if the label component, since label will encode its content.
<label>Copyright &copy; Super Co.</label>
[edit] How to set the forward property by program
org.zkoss.zk.ui.sys.ComponentsCtrl.applyForward(comp, "onClick");
[edit] How to enable logging in ZK
1. First, Set up the log configuration in your application's zk.xml file. I just used an empty string.
<zk>
<log>
<log-base></log-base>
</log>
</zk>
2. Create an i3-log.conf configuration file and place it in the Tomcat's /conf folder. It should include the following lines.
org.zkoss.testlog=DEBUG
org.zkoss=ERROR
3. Remember to modify the logging.properties file in your Tomcat's /conf folder. The default ConsoleHandler's level is INFO, so you won't see any DEBUG message otherwise. java.util.logging.ConsoleHandler.level = INFO to java.util.logging.ConsoleHandler.level = FINEST 4. If you want to output specific messages from your program
private static final Log log = Log.lookup(org.zkoss.testlog.Foo.class);
if(log.debugable()){
log.debug("a log for debug message");
}
if(log.infoable()){
log.info("a log for info message");
}
http://en.wikibooks.org/wiki/ZK/How-Tos/Frequently_Asked_Questions
发表评论
-
zk - 设置皮肤
2011-10-13 10:36 11551:前提 下载zk皮肤所需要的一些jar包,并把这些jar包放 ... -
(ZK-XF)组件开发三步走
2011-07-21 22:10 9741.3 开发组件三部曲(Tri ... -
(XF - 8)ZK 宏的使用与定义Demo
2011-04-02 11:32 1018这是一个文本框长度限制的例子(包括中文长度的限制) 里面有两个 ... -
(XF - 7)ZK 常用知识
2011-02-10 22:34 1401在一个页面中使用多种脚本语言 <zscript lan ... -
(XF - 6)ZK页面跳转与接收参数
2011-01-14 23:38 21951:Include include.setSrc(&qu ... -
(XF - 4)zk 应用之间访问
2011-01-11 22:30 955How to access resources in anot ... -
(XF - 3)ZK常见问题及解决办法
2010-12-23 20:10 16461:移除zk中Grid中的rows下的组件 Rows r ... -
(XF - 2)ZK 入门
2010-12-22 22:11 1180在看这篇文章之前对zk研究没有任何进展,可乐以后看了一下zkd ... -
(XF - 1)ZK - MVC 模式
2010-12-17 16:20 1304The ZK Team are always looking ...
相关推荐
在全球建筑行业不断追求节能与智能化发展的浪潮中,变风量(VAV)系统市场正展现出蓬勃的发展潜力。根据 QYResearch 报告出版商的深入调研统计,预计到 2031 年,全球变风量(VAV)系统市场销售额将飙升至 1241.3 亿元,在 2025 年至 2031 年期间,年复合增长率(CAGR)为 5.8%。这一令人瞩目的数据,不仅彰显了 VAV 系统在当今建筑领域的重要地位,更预示着其未来广阔的市场前景。 变风量系统的起源可追溯到 20 世纪 60 年代的美国。它犹如建筑空调系统中的 “智能管家”,能够敏锐地感知室内负荷或室内所需参数的变化,通过维持恒定的送风温度,自动、精准地调节空调系统的送风量,从而确保室内各项参数始终满足空调系统的严格要求。从系统构成来看,变风量系统主要由四个基本部分协同运作。变风量末端设备,包括 VAV 箱和室温控制器,如同系统的 “神经末梢”,负责接收室内环境变化的信号并做出初步响应;空气处理及输送设备则承担着对空气进行净化、加热、冷却等处理以及高效输送的重任;风管系统,涵盖新风、排风、送风、回风等管道,构建起了空气流通的 “高速公路”;而自动控制系统宛
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
内容概要:本文探讨了ChatGPT这种高级语音模式的人工智能聊天机器人与用户的互动对其情绪健康的影响。研究采用了两种互补的方法:大规模平台数据分析和随机对照试验(RCT)。平台数据部分通过对超过400万次对话进行隐私保护的大规模自动化分析以及对4000多名用户的调查,揭示了高频率使用者表现出更多的情感依赖和较低的社会交往意愿。RCT部分则通过近1000名参与者为期28天的研究,发现语音模型相较于文本模型能带来更好的情绪健康效果,但长时间使用可能导致负面后果。此外,初始情绪状态较差的用户在使用更具吸引力的语音模型时,情绪有所改善。 适合人群:对人机交互、情感计算和社会心理学感兴趣的科研人员和技术开发者。 使用场景及目标:本研究旨在为AI聊天机器人的设计提供指导,确保它们不仅能满足任务需求,还能促进用户的心理健康。同时,也为政策制定者提供了关于AI伦理使用的思考。 其他说明:研究强调了长期使用AI聊天机器人可能带来的复杂心理效应,特别是对于那些已经感到孤独或社交孤立的人来说,过度依赖可能会加剧这些问题。未来的研究应该更加关注这些极端情况下的用户体验。
Java 反射(Reflection)是一种强大的机制,允许程序在运行时检查和操作类的成员变量和方法。然而,传统的 `setAccessible(true)` 方式虽然便捷,但存在安全性问题,并且性能相对较低。在 Java 7 引入 `MethodHandle` 后,我们可以通过 `MethodHandles.Lookup.findVirtual()` 提供更优雅、高效的方式来访问对象属性。本文将对比这两种反射方式,并分析它们的优缺点。
loongdomShop.tar.gz
内容概要:本文探讨了不同交互模式(文本、中性语音、吸引人语音)和对话类型(开放式、非个人化、个人化)对聊天机器人使用者的心理社会效果(如孤独感、社交互动、情感依赖、不当使用)的影响。研究表明,在初期阶段,语音型聊天机器人比文本型更能缓解孤独感并减少情感依赖,但随着每日使用时间增加,这种优势逐渐消失,尤其是对于中性语音聊天机器人。此外,个人话题对话略微增加了孤独感,而非个人话题则导致更高的情感依赖。总体而言,高频率使用聊天机器人的用户表现出更多的孤独感、情感依赖和不当使用,同时减少了真实人际交往。研究还发现,某些个体特征(如依恋倾向、情绪回避)使用户更容易受到负面影响。 适合人群:心理学家、社会学家、人工智能研究人员以及关注心理健康和人机交互的专业人士。 使用场景及目标:①帮助理解不同类型聊天机器人对用户心理健康的潜在影响;②为设计更健康的人工智能系统提供指导;③制定政策和规范,确保聊天机器人的安全和有效使用。 其他说明:研究强调了进一步探索聊天机器人管理情感内容而不引发依赖或替代人际关系的重要性,呼吁更多跨学科的研究来评估长期影响。
MP4575GF-Z MP4575 TSSOP-20 降压型可调DC-DC电源芯片
界面设计_SwiftUI_习惯养成_项目管理_1742850611.zip
免安装版的logic软件包。支持波形实时查看。内含驱动文件。
1. **系统名称**:学生毕业离校系统 2. **技术栈**:Java技术、MySQL数据库、Spring Boot框架、B/S架构、Tomcat服务器、Eclipse开发环境 3. **系统功能**: - **管理员功能**:首页、个人中心、学生管理、教师管理、离校信息管理、费用结算管理、论文审核管理、管理员管理、留言板管理、系统管理。 - **学生功能**:首页、个人中心、费用结算管理、论文审核管理、我的收藏管理。 - **教师功能**:首页、个人中心、学生管理、离校信息管理、费用结算管理、论文审核管理。
配套文章:https://blog.csdn.net/gust2013/article/details/139608432
蓝凌OA系统V15.0管理员手册
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
mips-gcc520-glibc222编译工具链.zip
app开发
内容概要:本文档详细介绍了Swift编程语言的基础知识,涵盖语言特点、基础语法、集合类型、控制流、函数定义、面向对象编程、可选类型、错误处理、协议与扩展以及内存管理等方面的内容。此外还简要提及了Swift与UIKit/SwiftUI的关系,并提供了进一步学习的资源推荐。通过这份文档,读者可以全面了解Swift的基本概念及其在iOS/macOS/watchOS/tvOS平台的应用开发中的使用方法。 适合人群:初学者或者希望从其他编程语言转向Swift的开发者。 使用场景及目标:帮助读者快速上手Swift编程,掌握其基本语法和特性,能够独立完成简单的程序编写任务,为进一步学习高级主题如并发编程、图形界面设计打下坚实的基础。 阅读建议:由于Swift是一门现代化的语言,拥有许多独特的特性和最佳实践方式,在学习过程中应当多加练习并尝试理解背后的原理。同时利用提供的官方文档和其他辅助材料加深印象。
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
资源内项目源码是来自个人的毕业设计,代码都测试ok,包含源码、数据集、可视化页面和部署说明,可产生核心指标曲线图、混淆矩阵、F1分数曲线、精确率-召回率曲线、验证集预测结果、标签分布图。都是运行成功后才上传资源,毕设答辩评审绝对信服的保底85分以上,放心下载使用,拿来就能用。包含源码、数据集、可视化页面和部署说明一站式服务,拿来就能用的绝对好资源!!! 项目备注 1、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 2、本项目适合计算机相关专业(如计科、人工智能、通信工程、自动化、电子信息等)的在校学生、老师或者企业员工下载学习,也适合小白学习进阶,当然也可作为毕设项目、课程设计、大作业、项目初期立项演示等。 3、如果基础还行,也可在此代码基础上进行修改,以实现其他功能,也可用于毕设、课设、作业等。 下载后请首先打开README.txt文件,仅供学习参考, 切勿用于商业用途。
app开发