-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I new on Zk, however I have this question:
If I change the value of Label by javascripts, how I can get this value and treat in the server side?
I always get the declered .zul value.
in my zul file:
<label id="tb" value="pippo" />
when I change pippo wirh pluto in the client side, in the server side i get pippo agein.... this is normal?
I createted the GenericAutowireComposer but it dosen't make effect.
If you want to interact with ZK at client side, you should read the "ZK Client-side Reference" first:
http://books.zkoss.org/wiki/ZK_Client-side_Reference
I wrote a example here, hope it helps you:
<zk xmlns:w="client">
<label id="tb" width="250px" value="hello" >
<custom-attributes org.zkoss.zk.ui.updateByClient="true"/>
</label>
<button label="chage at client-side">
<attribute w:name="onClick"><![CDATA[
var tb = zk.Widget.$(jq('$tb')),
val = 'world';
tb.setValue(val);
tb.smartUpdate('value', val);
]]></attribute>
</button>
<button label="get at server-side" onClick="alert(tb.value)"/>
</zk>
This work fine at the clinet side... I had rich this ponit.
I wold like to get the value of the label, changed by javascript using GenericForwardComposer.
I try to be more clearfull:
I have a Label or a textbox in a .zul has in your example.
Then my javascript change the value as in your example.
Then I try to get the actual value using GenericForwardComposer:
public class WindowWorkflowComposer extends GenericForwardComposer{
private Label tb; //the same is also using TextBox
public void onClick$submit(Event event) {
System.out.println("TB value : " + tb.getValue() );
}
}
If I change the value using the keybord, I can get the actual value using a GenericForwardComposer approach,
otherwise if I change the value using javascript the value
remain the previous.
In your example the button whit alert dosn't simulate the server side (I suppose).
kidleo,
The example from paowang was right on. With just a bit of tweaking, you get this:
package jg5ga0c$v1;import org.zkoss.zk.ui.*;
import org.zkoss.zk.ui.event.*;
import org.zkoss.zk.ui.util.*;
import org.zkoss.zk.ui.ext.*;
import org.zkoss.zk.au.*;
import org.zkoss.zk.au.out.*;
import org.zkoss.zul.*;public class TestComposer extends GenericForwardComposer{
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);}
public Label myLabel;
public void onClick$submit(Event event) {
alert(myLabel.getValue());
}
}
<zk xmlns:w="client">
<window id="main" apply="jg5ga0c$v1.TestComposer" style="padding: 25px;">
<label id="myLabel" width="250px" value="Hello">
<custom-attributes org.zkoss.zk.ui.updateByClient="true" />
</label>
<separator height="10px"/>
<button label="Change via JavaScript">
<attribute w:name="onClick"><![CDATA[
var lbl = zk.Widget.$(jq('$myLabel')),
val = 'World';
lbl.setValue(val);
lbl.smartUpdate('value', val);
]]></attribute>
</button>
<button id="submit" label="Submit"/>
</window>
</zk>
Hope that helps,
Todd
Hello,
I've been trying to use the solution mentioned in above posts for one of similar cases with HTML widget.
What I've discovered is that the soluton is working fine in ZK Release 5.0.6 but is not working in Release 5.0.7.1.
Can anybody please guide me as we are trying to upgrade our system and I really want this to work after the upgrade is complete.
Its urgent...
Regards
Nirav Dhirwani
Dear Todd,
Its not gonna help, coz system is being moved to version 5.0.7.1 and the components should work for the same version.
Regards
Nirav
Dear Todd,
I get a warning similar to mentioned below:
WARNING: Ignore update of content=This is <B><SPAN style="BACKGROUND: yellow"><B>HTML</B> text in ZK HTML control</SPAN></B> from client for class org.zkoss.zul.Html
Is there some configuration parameter that needs to be set for enabling updates from client side?
Nirav,
I am not aware of any specific parameters that needs to be set (e.g. in the ZK xml file).
If you can post a small, runnable example that reproduces the issue, the community will try to help.
Regards,
Todd
Asked: 2012-02-07 21:31:29 +0800
Seen: 1,601 times
Last updated: Mar 31 '14
ZK studio and eclipse outline problem
ZK Package configuration problem
Eclipse Autocomplete not working in ZUL files...
Syntax Error mark ... help me!
Manual Installation of ZK Studio
Can't see button text whilst running simple demo
Adding Vbox to Center layout in Java