0

Databinder refreshes the whole page(!)

asked 2012-03-29 16:21:02 +0800

cyiannoulis gravatar image cyiannoulis
1191 10

Hi to all,

I am facing a weird problem. Below is a sample zul

<?page contentType="text/html;charset=UTF-8"?>
<zk>
<window id="winTestListbox" title="Test Listbox" border="normal" closable="false"
		apply="wwwsnippets.TestListboxController" height="100%" width="100%" >

		<vlayout vflex="true">
			<groupbox height="100px" closable="false" >
				<label value="Code" />
				<textbox id="txtCode" value="@bind( vm.customerCode )" />
				<label value="Name" />
				<textbox id="txtName" value="@bind( vm.customerName )" />
			</groupbox>

			<grid id="gridNonConformities" model="@bind( vm.addresses )" vflex="true" >
		
				<auxhead>
				    <auxheader label="Addresses" colspan="2" align="center" />
				</auxhead>
		    
				<columns>
					<column label="#" width="80px" />
					<column label="Location" hflex="true"/>
				</columns>
				
				<rows>
					<row self="@{each='address'}" >						
						<label value="" style="color: red" />
						<label value="@bind( address )" style="color: red" />
					</row>
				</rows> 			
			</grid>		
			
		</vlayout>

</window>
</zk>

and here is the composer

package wwwsnippets;

import java.util.ArrayList;
import java.util.List;

import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.select.SelectorComposer;
import org.zkoss.zk.ui.select.annotation.Listen;
import org.zkoss.zkplus.databind.AnnotateDataBinder;

public class TestListboxController extends SelectorComposer {

	private static final long serialVersionUID = 1L;
	
	/*
	 * Databinder / Models
	 */
	private AnnotateDataBinder binder;
	
	private String customerCode; 
	private String customerName;
	private List<String> addresses;
	
	@Override
	public void doAfterCompose(Component comp) throws Exception {
		
		try {
			super.doAfterCompose(comp);
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
		
		binder = new AnnotateDataBinder(comp);
		binder.bindBean("vm", this);
		
		createModels();
	}
	
	private void createModels() {
		
		addresses = new ArrayList<String>();
		for (int i = 0; i < 100; i++) {
			addresses.add( "Address no " + i);
		}

		customerCode = "1234";
		customerName = "Costas";
	}

	@Listen("onCreate = window#winTestListbox")	
	public void onCreate(Event event) {
		
		binder.loadAll();
	}

	public AnnotateDataBinder getBinder() {
		return binder;
	}

	public void setBinder(AnnotateDataBinder binder) {
		this.binder = binder;
	}

	public String getCustomerCode() {
		return customerCode;
	}

	public void setCustomerCode(String customerCode) {
		this.customerCode = customerCode;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public List<String> getAddresses() {
		return addresses;
	}

	public void setAddresses(List<String> addresses) {
		this.addresses = addresses;
	}
	
}

Scroll down the grid. Then try to change the code field and ops! ZK refreshes the whole page (including the grid) causing a very uncomfortable re-positioning at the top of the list. I remember that this was not the default behavior in ZK 5.

Please help...

Thank you

/costas

delete flag offensive retag edit
Be the first one to reply this discussion!
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: 2012-03-29 16:21:02 +0800

Seen: 91 times

Last updated: Mar 29 '12

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