0

is this a ZK Bug? (window component ID)

asked 2011-10-12 09:06:46 +0800

carpolva gravatar image carpolva
155 4

Hi guys.

I have the following simple page:

todo.zul

<?page title="Todo Example"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>

<window id="win" width="360px" apply="${sessionScope.myController}">
	<grid model="@{win$composer.myList, load-after='btnAdd.onClick'}" width="360px">
		<columns>
    		<column width="100px">Item</column>
    		<column width="100px">Priority</column>
    		<column width="150px">Date</column>
    	</columns>
    	<rows>
    		<row self="@{each='event'}">
    			<label value="@{event.id}"/>
    			<intbox value="@{event.priority}" constraint="no negative,no empty"/>
    			<datebox value="@{event.date}"/>
    		</row>
    	</rows>
	</grid>
	<label value="New Registers"/><intbox id="myIntBox" value="0"/><button id="btnAdd" label="Add"/>
</window>

EventController.java

public class EventController extends GenericForwardComposer {

	ListModelList myList;
	Intbox myIntBox;
	
	public EventController(){
		myList = new ListModelList();
		for(int i=1; i<6; i++){
			TodoEvent evento = new TodoEvent(""+i, "Nombre"+i, i, new Date());
			myList.add(evento);
		}
	}
	
	public void onClick$btnAdd() {
		Integer size = myList.size()+1;
		Integer cantidad = myIntBox.getValue();

		for(int i=0; i<cantidad; i++){
			TodoEvent myBean = new TodoEvent(""+size, "Nombre"+size, size, new Date());
			myList.add(myBean);
			size++;
		}
	}

	public ListModelList getMyList() {
		return myList;
	}

	public void setMyList(ListModelList myList) {
		this.myList = myList;
	}
}

TodoEvent.java

public class TodoEvent implements Serializable{
	private String id;
	private String name;
	private int priority;
	private Date date;
	
	public TodoEvent(){}
	public TodoEvent(String id,String name,int priority,Date date){
		this.id = id;
		this.name = name;
		this.priority = priority;
		this.date = date;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public int getPriority() {
		return priority;
	}
	public void setPriority(int priority) {
		this.priority = priority;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}

Note that the window component has an ID equals to "win":

<window id="win" width="360px" apply="${sessionScope.myController}">

When I run this example everything is fine and the grid appears with some rows. BUT... if I change the window id by "mywin":

<window id="mywin" width="360px" apply="${sessionScope.myController}">

The grid appears empty, zero rows.

... any idea?? what could be happening?. My ZK version is: zk-bin-5.0.8

Regards.

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2011-10-12 10:23:58 +0800

RichardL gravatar image RichardL
768 4

Did you change win$composer.myList in the grid to mywin$composer.myList?

link publish delete flag offensive edit

answered 2011-10-12 10:30:50 +0800

carpolva gravatar image carpolva
155 4

Ohh RichardL jaja that's the cause!!, I'm very sorry :S ... the fact is I thought that word "win" into @{win$composer.myList} was a reserved or native ZK word and not the window ID. Well... it's a lesson to take care with every word wherever it is ;)

Thank you very much.

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: 2011-10-12 09:06:46 +0800

Seen: 183 times

Last updated: Oct 12 '11

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