0

Error in tree when I upgrade from version 6.0.0 to 6.0.01

asked 2012-05-28 16:53:35 +0800

erciarez gravatar image erciarez
12

In view model I have:

TreeModel files= new DefaultTreeModel(
  new DefaultTreeNode(null,
    new DefaultTreeNode[] {
      new DefaultTreeNode(new FileInfo("/doc", "Release and License Notes")),
      new DefaultTreeNode(new FileInfo("/dist", "Distribution"),
        new DefaultTreeNode[] {
          new DefaultTreeNode(new FileInfo("/lib", "ZK Libraries"),
            new DefaultTreeNode[] {
              new DefaultTreeNode(new FileInfo("zcommon.jar", "ZK Common Library")),
              new DefaultTreeNode(new FileInfo("zk.jar", "ZK Core Library"))
            }),
          new DefaultTreeNode(new FileInfo("/src", "Source Code")),
          new DefaultTreeNode(new FileInfo("/xsd", "XSD Files"))
        })
      }

In zul I have:

<tree model="${files}">
	<treecols>
		<treecol label="Path"/>
		<treecol label="Description"/>
	</treecols>
	<template name="model">
		<treeitem context="menupopup">
			<treerow>
				<treecell label="${each.data.path}"/>
				<treecell label="${each.data.description}"/>
			</treerow>
		</treeitem>
	</template>
</tree>

In version 6.0.0 all works ok but when I updated to version 6.0.1 when I try to deploy the children of a node in the tree the following error occurs: "Property 'data' not found in the type org.zkoss.bind.impl.ReferenceBindingImpl"


Thanks in advance.


.

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2012-05-29 02:32:26 +0800

MontyPan gravatar image MontyPan
435 3
http://xitop.blogspot.com...

I test ZK demo code in ZK-bin-6.0.1 , it's work fine.
Can you give more detail information?

Regards,
Monty Pan

link publish delete flag offensive edit

answered 2012-06-11 12:52:42 +0800

khcyt gravatar image khcyt
216 1 1

Hello Monty Pan,

i have same problem after upgrade. Here is a test case to reproduce the problem.
I use ZK PE

Kai

<?xml version="1.0" encoding="UTF-8"?>
<?page title="Auto Generated index.zul"?>

<zk>
    <zscript><![CDATA[
        ListModelList lm0= new ListModelList(); 

        class A
        {
            public A(String s, Long v)	{ s_= s; v_= v; }
            
            public String getData()		{ return s_; }
            
            String s_= null;
            Long v_= null;
        }
 
       // Make first entry in ListModel
        ListModelList list= new ListModelList();
        list.add(new A("RE: Bandbox Autocomplete Problem", 0L));
        list.add(new A("RE: It's not possible to navigate a listbox' ite", 1L));
        list.add(new A("RE: FileUpload", 2L));
	lm0.add(new Object[] {"Today", list });
        
        // Make second entry in ListModel
        list= new ListModelList();
        list.add(new A("RE: Opening more than one new browser window", 10L));
        list.add(new A("RE: SelectedItemConverter Question", 11L));
	lm0.add(new Object[] { "Yesterday", list });
        
        // Make third entry in ListModel
        list= new ListModelList();
        list.add(new A("RE: Times_Series Chart help", 30L));
        list.add(new A("RE: SelectedItemConverter Question", 31L));
	lm0.add(new Object[] { "Last week", list });
        
      
        class VM
        {
            public ListModel getLm0()		{ return lm0; } 
        }
	]]></zscript>


	<window title="Hello World!!" border="normal" width="800px" 
			apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('VM')" >    		    
	
	    <label value="You are using: ${desktop.webApp.version}"/>
    	    <listbox id="lb" model="@load(vm.lm0)" >
    		<listhead>
	    		<listheader hflex="3"/>
	    		<listheader hflex="6"/>
    		</listhead>
	        <template name="model">
	            <listitem>
				<custom-attributes inner_list="${each[1]}" scope="component"/>
	                <listcell>
	                	<label value="@load(each[0])"/>
	                </listcell>
	                <listcell>
			        <listbox model= "@load(inner_list)">
				       	<template name="model">
				       		<listitem>
				        		<listcell label="${each.data}">
				        		</listcell>
				        	</listitem>
				        </template>
				</listbox>
			</listcell>
	            </listitem>
	        </template>
	   </listbox>
     </window>
</zk>

link publish delete flag offensive edit

answered 2012-06-12 03:42:11 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2012-06-12 03:46:16 +0800

this is a bug when using zkbind(ex. @load) with zk el(${}) on reference or element of a collection.
for now, you could use <listcell label="@load(each.data)"> to solve it.

I also created a issue here : http://tracker.zkoss.org/browse/ZK-1188

link publish delete flag offensive edit

answered 2012-06-12 09:16:35 +0800

khcyt gravatar image khcyt
216 1 1

Hello Dennis,

in my concrete case I would like to use each.data as custom attribute.

...
<listitem>
    <custom-attributes whatever="${each.data}" scope="component"/>
    <listcell label="@load(each.data)"/>
</listitem>
...

This is not possible with bind mechanism. Do you have a solution for it?

Kai

link publish delete flag offensive edit

answered 2012-06-12 11:27:29 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2012-06-12 11:29:41 +0800

this is kind of EL tricky, zkbind use EL to set/get data,
<listitem attributes.whatever="@load(each)"></listitem>
in this case, it get data from each, and set to listitem.attributes.whatever(it do code like listitem.getAttributes().put('whatever',value) in java)

link publish delete flag offensive edit

answered 2012-06-12 12:00:22 +0800

khcyt gravatar image khcyt
216 1 1

Thank you very much, this can help me. Is it possible to find these tricky behaviour in the documentation?

Kai

link publish delete flag offensive edit

answered 2012-06-13 07:27:01 +0800

khcyt gravatar image khcyt
216 1 1

Works this feature to set attribute only with listcell items? I have tried it with listgroup and tree. I get the error message "Method setAttributes.whatever not found for class org.zkoss.zul.Listgroup/Tree
java.lang.IllegalArgumentException"

Kai

link publish delete flag offensive edit

answered 2012-06-13 07:31:59 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2012-06-13 07:33:00 +0800

it goes by the EL way, not zkbind magic, what is your zul syntax and the exception stack print?

link publish delete flag offensive edit

answered 2012-06-13 08:54:13 +0800

khcyt gravatar image khcyt
216 1 1

Hello Dennis,

sorry, that was my mistake. I also wanted to set additional custom attributes via EL expressions. For example, in order to set country-specific strings.
attributes.whatever = "$ {c: l ('catalog.doc.tree.comments')}"

In these cases the error occur.
The reason for the IllegalArgumentException is the combination fom listbox and model: group. See also forum thread "ZK 6 bind and model: group"

Thank you for your help ... and your patience :-)

Kai

link publish delete flag offensive edit

answered 2012-06-13 09:17:58 +0800

dennis gravatar image dennis
3679 1 6
http://www.javaworld.com....

updated 2012-06-13 09:21:23 +0800

It is a bit trouble for a new to zkbind2 user to know when to use @ and when to use $

${} is original EL of zk, it runs when creating a zul content to components.
for the case, <component attr="${somevalue}"/>the value is got by 'somevalue' and set to component.attr by reflection directly. (so in original EL, using attributes.whatever doesn't work)
You usually do this when you use MVC pattern to develop you application and for load only-once data.

@annotation is ZK annotation syntax and zkbind use it to help developer sets binding expression when using MVVM pattern to develop application, it is since ZK 6.0.0 , it runs after a zul content created (in afterCompose precisely)
for the case <component attr="@load(somevalue)"/>the value is got by 'somevalue' and set to component.attr by EL too.
so you can get/set any chain attribute by Bind EL if instance has it (EL did it).

in your case, if you want to set label of 'catlog....' by ${} to a custom attribute, you have to use <custom-attributes whatever="$ {c: l ('catalog.doc.tree.comments')}"></custom>

a simple way to choose when to use ${} and when @ for me.
it the value is static, loads only once, not comes from any instance that is related to object of MVVM development pattern. use ${}
if the value comes from some objects of MVVM pattern, the use @load, @bind...etc

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: 2012-05-28 16:53:35 +0800

Seen: 280 times

Last updated: Jun 13 '12

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