ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

jquery functions in composite component

jaan
15 Dec 2011 10:37:38 GMT
15 Dec 2011 10:37:38 GMT

Hi,

I've created a composite component (statusMessage)
This is my zul file:

<?page title="" contentType="text/html;charset=UTF-8"?>
<zk>
	<div
		style="position: absolute; border:solid 1px #333; background:#00b; 
				color:#000;top:10px;left:50%;margin-left:-50px;width:100px; z-index:99999;text-align:center;"
		xmlns:w="http://www.zkoss.org/2005/zk/client" >
		<label id="lblStatus" />
		<attribute w:name="setVisible">
			function (value) { 
				var sm = this; 
				if(value) {
					jq(sm).fadeIn('fast'); 
					setTimeout(function() { jq(sm).fadeOut('slow') } , 3000); 
				} 
			}
		</attribute>
	</div>
</zk>

The javaclass that create this component:

public class StatusMessage extends Div implements IdSpace {
	private static final long serialVersionUID = 5994732340875475703L;
	/***************** WIRED ************************/
	private Label lblStatus;
	
	/******* C'tor *************************/
	public StatusMessage() {
		Executions.createComponents("/WEB-INF/composite/statusmessage.zul", this, null);
		Components.wireVariables(this, this, '$', true, true);
		Components.addForwards(this, this, '$');
	}
	
	/******* Properties*********************/
	public String getValue() {
		return lblStatus.getValue();
	}
	public void setValue(String value) {
		this.lblStatus.setValue(value);
	}
}

I've added the component to lang-addon.xml so I can call <statusmessage value="blablabla" />

I can let the statusmessage appear by changing visibility (in zk 6: visible="@load(not empty vm.statusMessage)" )
But the jquery function to fadeout the message does not work.

If I use the same code directly in my page (the content of the zul file) the div is dissapearing as expected.
What am I doing wrong?

jaan