-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
This was just answered in the paragraph above your question.
http://forum.zkoss.org/question/99821/zk-8-form-object-how-to-get-value/?answer=99825#post-id-99825
I'll add this again here, maybe in got lost in the mixed answer.
If you need to initialize and pre-populate some values in the Form you can manually create a proxy:
Pojo originalPojo;
Pojo pojoForm = ProxyHelper.createProxyIfAny(originalPojo); //form proxy around the pojo
pojoForm.setIcdVersion(123456); //will set the value in the form only
//does not affect the originalPojo
public Pojo getPojoForm() {
return pojoForm;
}
/*getter setter for originalPojo*/
and use it in the zul file:
<groupbox form="@id('fx') @init(vm.pojoForm) @load(vm.originalPojo)
@save(vm.originalPojo, before='savePojo') " >
I hope that clarifies the usage for you
2 | No.2 Revision |
This was just answered in the paragraph above your question.
http://forum.zkoss.org/question/99821/zk-8-form-object-how-to-get-value/?answer=99825#post-id-99825
I'll add this again here, maybe in got lost in the mixed answer.
If you need to initialize and pre-populate some values in the Form you can manually create a proxy:
Pojo originalPojo;
Pojo pojoForm;
@Init
public void init() {
//retrieve original Pojo ...
//create a proxy around the originalPojo
pojoForm = ProxyHelper.createProxyIfAny(originalPojo); //form
//set a value in the form proxy around the pojo
pojoForm.setIcdVersion(123456); //will set the value in the form only
//does not affect the originalPojo
originalPojo direcly, only after successful saving
pojoForm.setIcdVersion(123456);
}
public Pojo getPojoForm() {
return pojoForm;
}
/*getter setter for originalPojo*/
and use it in the zul file:
<groupbox form="@id('fx') @init(vm.pojoForm) @load(vm.originalPojo)
@save(vm.originalPojo, before='savePojo') " >
I hope that clarifies the usage As you can see there is no need for you
3 | No.3 Revision |
This was just answered in the paragraph above your question.
http://forum.zkoss.org/question/99821/zk-8-form-object-how-to-get-value/?answer=99825#post-id-99825
I'll add this again here, maybe in got lost in the mixed answer.
If you need to initialize and pre-populate some values in the Form you can manually create a proxy:
Pojo originalPojo;
Pojo pojoForm;
@Init
public void init() {
//retrieve original Pojo ...
//create a proxy around the originalPojo
pojoForm = ProxyHelper.createProxyIfAny(originalPojo);
//set a value in the form proxy only
//does not affect the originalPojo direcly, only after successful saving
pojoForm.setIcdVersion(123456);
}
public Pojo getPojoForm() {
return pojoForm;
}
/*getter setter for originalPojo*/
and use it in the zul file:
<groupbox form="@id('fx') @init(vm.pojoForm) @load(vm.originalPojo)
@save(vm.originalPojo, before='savePojo') " >
As you can see there is no need for an Object like Simple form SimpleForm anymore. You still work with your original class' interface, just behind a proxy.