ZK - Open Source Ajax Java FrameworkZK - Open Source Ajax Java Framework

Enable ZK Page to bind with non public properties of bean

sudarshan89
13 Jan 2012 18:34:00 GMT
13 Jan 2012 18:34:00 GMT

Hi,

Enable ZK Page to bind with non public properties of bean.

Say I have a domain object called Book which looks like

class Book{
private String name;

protected String getName(){
return name;
}

protected void setName(String name){
this.name = name;
}
}

I want to be able to bind a textbox using @{book.name} , at present I think to enble binding i will need to make the getter and setter as public.

Frameworks like hibernate can operate on non public properties as well, so why has zk choosen not too, an configuration change possible to enable this ??

Any suggestions would be great.

Thanks
Sudarshan

terrytornadoTop Contributor
14 Jan 2012 10:30:01 GMT
14 Jan 2012 10:30:01 GMT

Hibernate MUST have access to all properties for working well (i.e. check 'not null' fields). So in this case hibernate will change the visibility of the properties with reflection, if needed. It's dirty but needed.

best
Stephan

sudarshan89
16 Jan 2012 07:06:42 GMT
16 Jan 2012 07:06:42 GMT

I was just wondering that when other frameworks can/are doing it, why does ZK restrict itself to publicly accessible properties ?, and is there any way to work around this ?

jimmyshiau
6 Feb 2012 11:47:00 GMT
6 Feb 2012 11:47:00 GMT

Hi sudarshan89,
The databinding did not implement retrieve the data by reflection, we only support public method.
you can post a feature here: http://tracker.zkoss.org/secure/Dashboard.jspa