setFocusLostSaveEnabled: how to use

I want that changes made to a record are not saved automaticaly.

I tried setFocusLostSaveEnabled(false): no matter where I put it, it does nothing, ie the modified record is saved every time.

Any suggestion?

Maybe you could enable transacttions and either commit or rollback based on a event or variable

Thank you for the suggestion. In fact, I thought doing it this way. However setFocusLostSaveEnabled(false/true) should do exactly this, if I am right. But it doesn’t work. Or, I am unable of making it work.

Hi rioba,

You say the data is stored every time.
After you leave a field ? Or only after you browse to another record ?
I mean, when does this exactly happen?

Also what version of Servoy/Java do you use ?

Hi, Robert

this is exactly the question I asked myself a lot of times while trying to figure out how to use application.setFocusLostSaveEnabled. But I was unable to determine when the data were saved.

However, in my understanding (but this is probably the point) why would you need to automatically save (or not save) after losing focus if changes are saved in any case when you move from one record to another?

My problem is to force the user to confirm the modifications before moving to the next record. One could use a transaction (even if this seems to me to be an “overkill” option for such a simple operation), but in my case I am already inside a very large transaction, and therefore I am unable to start a new one.

I am using Servoy 2.2.3 on MacOS X and J2SE 5.0.

Thanks.

What the setFocusLostSaveEnabled(false/true) does is when you click out of a field (and thus lose the focus of this GUI element) it lets/stops the auto-save-data do it’s thing.
Now moving to another record is another matter. This has nothing to do with losing the focus of a GUI element.
I am sure Servoy WILL save the data then.

Robert,

I am probably too dumb, but I still don’t understand.

You are saying that setFocusLostSaveEnabled(false/true) works when leaving a GUI area (losing focus). This is ok. Let’s say that I make a modification to a field, then I move to the next field. Obviously the modified field keeps the new value, unless I force a UI refresh.

When I move to the next record, the changes are saved. That’s ok.

Now: in this case, what would have happened if I had used setFocusLostSaveEnabled(false)? I really don’t understand.

Thanks.

Hi rioba,

When you don’t use setFocusLostSaveEnabled(false) then when you click outside a field or run any method then your data will be saved.
So if you want to prevent that from happening you use setFocusLostSaveEnabled(false).

Is this function still available? If so, how does it work?

I’m trying to commit some changes when the user clicks or tabs away from a form field, but it seems that the data save is triggered only when the form is hidden.

I know that I can do that manually with “onFocusLost” methods, but I was wondering if there is a default behavior that might help me.

When the data from a form is saved?

Thanks,
Gabriel - Iulian Dumbrava

normally if you click besides a field (so on the form itselt,not in another field) the data will be saved
But if you just jump from field to field, it will not save until you switch to another record or form.

with databaseManager.setAutoSave() you can even switch that behavior off.

If you really want to save after focus lost of any field you have to program that yourself.

Thank you,

I wasn’t able to figure out the autosave “rule”.

Gabriel - Iulian Dumbrava