0

Update dirty property of proxy

asked 2021-09-24 18:25:40 +0800

aUser gravatar image aUser
137 1 4

updated 2021-09-24 18:45:04 +0800

Hello,

I have a scenario like this:

<window border="normal" viewModel="@id('vm') @init('ViewModel')"
        form="@id('proxy') @init(vm.proxy) @load(vm.obj) @save(vm.obj, before='save') 
        @validator('ObjValidator', proxy=proxy)"
        validationMessages="@id('vmsgs')">
...
</window>

@Init
public void init() {
    private Obj obj = getObj();

    private Obj proxy = ProxyHelper.createFormProxy(obj, Obj.class);
    // set status immediately to dirty
}

@Command
public void save() {
    // some save logic;
}

// getters & setters

Is it possibile to update proxy's status to dirty as soon as the proxy is instantiated in the init method? The reason I need this is because I noticed that if I open this page, the proxy is created, then I click a save button to fire the save event and the validator for the proxy is called but the obj is not updated at all. Of course I understand that it makes sense to not update the original object if the proxy is not changed, but in my case I have some logic in the validator to edit the proxy even if the user didn't edit the form at all, therefore i need my original obj to be updated in any case.

I noticed this utility method:

((FormProxyObject) proxy).submitToOrigin(bindContext);

but I don't know what bindContext is.


UPDATE:

I used the Immutable annotation on the objects that I don't want a proxy around, it seems working but not sure if this is the best solution.

Thank you

delete flag offensive retag edit
Be the first one to answer this question!
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: 2021-09-24 18:25:40 +0800

Seen: 2 times

Last updated: Sep 24 '21

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