Revision history [back]

click to hide/show revision 1
initial version

answered 2016-12-13 01:17:51 +0800

cor3000 gravatar image cor3000

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

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

an Object like Simple form anymore. You still work with your original class' interface, just behind a proxy.

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.

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