0

ZK 6 Composite component getter not working in view model

asked 2012-01-14 13:42:54 +0800

jaan gravatar image jaan
88 3

Hi,

I'm a very newbie in ZK and Java. But I do love the technology by now.
After a lot of trial (and more error) I bumped into the following problem.
I've created a composite component following this smalltalk: Define Composite Component using Java Annotation in ZK6


@Composite(name="testcomposite")
public class TestComposite extends Textbox implements IdSpace {
	private String someProp;
	
	public TestComposite() {
		
	}

	public String getSomeProp() {
		return this.getValue(someProp);
	}
	public void setSomeProp(String someProp) {
		this.setValue(someProp)
	}
}

Now if I bind some data from a viewModel to this someProp-property it is set (setSomeProp is called).
So when I try :
<testcomposite someProp="@bind(vm.selected.website)" />

the textbox is filled with the website data.
But when I try to save the data nothing is changed in vm.selected. It never updates the website value.

I'm doing stupid things? Am I forgetting something?

jaan

delete flag offensive retag edit

20 Replies

Sort by ยป oldest newest

answered 2012-02-06 04:49:10 +0800

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

hi,
you need addition information(annotation) to support save-binding in composite or other custom component.
please follow this feature request. http://tracker.zkoss.org/browse/ZK-833

link publish delete flag offensive edit

answered 2012-03-16 10:15:29 +0800

pmq gravatar image pmq
27

Hi Dennis,

I have the same troubles with composite component.

I did getter and setter for Date value (in my case).

I send event onChange, when internal component is updated.


Events.postEvent(Events.ON_CHANGE,this,null);


Different is only in my annotations:
<testcomposite someProp="@{vm.selected.website,save-when='self.onChange'}" self="@action(recalculate,when='onChange')"/>

Action "recalculate" works fine, but data binding works only for setter.

When can I expect solution for this issue?

pmq

link publish delete flag offensive edit

answered 2012-03-19 09:30:19 +0800

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

updated 2012-03-19 09:40:47 +0800

@jaan
this feature was resolved by http://tracker.zkoss.org/browse/ZK-883 already,
following is the example to enable binding for imagelabel in the smalltalk http://books.zkoss.org/wiki/Small_Talks/2011/December/Define_Composite_Component_using_Java_Annotation_in_ZK6.

@ComponentAnnotation({"description:@ZKBIND(ACCESS=both,SAVE_EVENT=onAfterEdit)","title:@ZKBIND(ACCESS=both,SAVE_EVENT=onAfterEdit)"})
public class ImageLabel extends Div implements IdSpace {..}

link publish delete flag offensive edit

answered 2012-03-19 09:32:36 +0800

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

@pmq
form the syntax, you are trying zkbind1
did you try zkbind2 ? it is more powerful and easier than zkbind1
you can read document here. http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM

link publish delete flag offensive edit

answered 2012-03-19 13:49:58 +0800

pmq gravatar image pmq
27

updated 2012-03-19 14:33:42 +0800

Hi Dennis,
Where can I find package for Componentannotation?
I cannot find library with org.zkoss.zk.ui.annotation.ComponentAnnotation

pmq

link publish delete flag offensive edit

answered 2012-03-20 00:50:11 +0800

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

it is after zk 6.0.1, it is freshly now. try here, http://www.zkoss.org/download/freshly/

link publish delete flag offensive edit

answered 2012-03-20 12:07:24 +0800

shumy gravatar image shumy
244 1

updated 2012-03-20 12:08:39 +0800

Adding to this. Is there any support for child components? Like the one I describe in ZK 6 Composite Feature

link publish delete flag offensive edit

answered 2012-04-08 20:24:58 +0800

ws13 gravatar image ws13
45 1

Hi,

I follow the small talk to composite a component and and it making an error to deploy:

Caused by: java.lang.IncompatibleClassChangeError: Found class org.objectweb.asm.AnnotationVisitor, but interface was expected

It seems that the 3 jars added + zk 6.0.1 make this error. (in the original version 6.0 also).

thanks in advance

link publish delete flag offensive edit

answered 2012-04-08 22:59:14 +0800

ws13 gravatar image ws13
45 1

Hi,

I have been trying to deploy your example and it was impossible. I have been learning how to make the composite components with the example that is found in the demo components: ListBox:DualListBox. It was impossible that this component updated the status populating the input listbox in MVVM, bumping into the same problem

<emailDualListbox id="dualLBox" candidateModel="@init(initEmailDualBox)"/>

thank in advance

link publish delete flag offensive edit

answered 2012-04-09 07:04:06 +0800

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

I think you have multiple asm jars in the project and they conflict.

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-01-14 13:42:54 +0800

Seen: 1,526 times

Last updated: Aug 27 '12

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