# setFocusLostSaveEnabled: how to use

**URL:** https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199
**Category:** Classic Servoy
**Created:** [December 13, 2005, 5:29pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199 "2005-12-13T17:29:01Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)
#### Post date: [December 13, 2005, 5:29pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/1 "2005-12-13T17:29:01Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ebrandt](https://avatars.discourse-cdn.com/v4/letter/e/96bed5/32.png) [@ebrandt](https://forum.servoy.com/u/ebrandt)
#### Post date: [December 13, 2005, 7:02pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/2 "2005-12-13T19:02:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)
#### Post date: [December 13, 2005, 7:15pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/3 "2005-12-13T19:15:06Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [December 13, 2005, 10:58pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/4 "2005-12-13T22:58:01Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)
#### Post date: [December 14, 2005, 5:19am UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/5 "2005-12-14T05:19:40Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [December 14, 2005, 10:44am UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/6 "2005-12-14T10:44:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![rioba](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@rioba](https://forum.servoy.com/u/rioba)
#### Post date: [December 14, 2005, 3:46pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/7 "2005-12-14T15:46:31Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ROCLASI](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/roclasi/32/4371_2.png) [@ROCLASI](https://forum.servoy.com/u/ROCLASI)
#### Post date: [December 14, 2005, 5:04pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/8 "2005-12-14T17:04:39Z")

</div>

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).

---

<div class="post-metadata">

### Author: ![gabid](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@gabid](https://forum.servoy.com/u/gabid)
#### Post date: [July 26, 2010, 3:10pm UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/9 "2010-07-26T15:10:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)
#### Post date: [July 27, 2010, 8:30am UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/10 "2010-07-27T08:30:46Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![gabid](https://avatars.discourse-cdn.com/v4/letter/g/7ab992/32.png) [@gabid](https://forum.servoy.com/u/gabid)
#### Post date: [July 27, 2010, 11:22am UTC](https://forum.servoy.com/t/setfocuslostsaveenabled-how-to-use/5199/11 "2010-07-27T11:22:05Z")

</div>

Thank you,

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

Gabriel - Iulian Dumbrava
