losing data in web client by searching

Forum to discuss the Web client version of Servoy.

losing data in web client by searching

Postby adamk » Thu Mar 29, 2012 8:31 pm

I seem to have found a bug. I have a web client solution. Sometimes when I search for some data in a particular column, i get all the matching records, but all the columns have been emptied.
Say there are 5 records with a particular string in a given column. I perform a search on that column for that string. I get 5 results. The trouble is that all the columns for those 5 records are now empty, including the one I searched on. I've just lost all that data. If I do the same search again, I now get zero results. It's rare that this happens and I haven't noticed a pattern.

One thing I have noticed is that only those records that are shown on the screen get emptied. If there are 40 search results, but only 30 fit on my screen at a time, the first 30 get emptied. If I click to the next page, I see the other 10 records and all the data is still there.

Servoy 6.0.3
PostgreSQL
adamk
 
Posts: 35
Joined: Sat Jun 30, 2007 2:33 am
Location: Lynnfield, MA

Re: losing data in web client by searching

Postby ngervasi » Fri Mar 30, 2012 11:40 am

Can you post the code that you use for the search?
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: losing data in web client by searching

Postby adamk » Fri Mar 30, 2012 2:48 pm

Code: Select all
var columnNames = null;
var searchCriteria = null;

function performSearch()
{
      globals.vMessage = '';
      var s
      if (isNaN(searchCriteria))
      {
           s = '#%' + searchCriteria + '%';
      }
      else
      {
           s = searchCriteria;
      }
      controller.find()
      if(controller.find())
      {
            foundset[columnNames] = s
            controller.search()
            elements.searchCriteria.selectAll();
      }
      else
      {
            globals.vMessage = 'Could not enter Find mode.';
      }
}
adamk
 
Posts: 35
Joined: Sat Jun 30, 2007 2:33 am
Location: Lynnfield, MA

Re: losing data in web client by searching

Postby ngervasi » Fri Mar 30, 2012 4:14 pm

adamk wrote:
Code: Select all
controller.find()
      if(controller.find())
      {
            foundset[columnNames] = s
            controller.search()
            elements.searchCriteria.selectAll();
      }
      else
      {
            globals.vMessage = 'Could not enter Find mode.';
      }
}


Why do you have controller.find() twice?
I suggest you to always check if you really are in find mode before searching, using the following code you can be sure of that (cause the only reason for controller.find() to fail is when you have unsaved changes):

Code: Select all
if(!controller.find())
{
databaseManager.saveData()
controller.find()
}


Usually when you suffer data loss and find mode is involved is due to the fact that find mode failed and the search criteria are entered in the dataproviders instead. It's always a good idea to save before finding or at least ask the user.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: losing data in web client by searching

Postby adamk » Fri Mar 30, 2012 9:58 pm

ngervasi wrote:Usually when you suffer data loss and find mode is involved is due to the fact that find mode failed and the search criteria are entered in the dataproviders instead. It's always a good idea to save before finding or at least ask the user.

That's not happening, though. The search criteria isn't being entered into the dataprovider. The dataprovider, and all the other columns in the table, are being emptied completely.
adamk
 
Posts: 35
Joined: Sat Jun 30, 2007 2:33 am
Location: Lynnfield, MA

Re: losing data in web client by searching

Postby adamk » Mon Apr 23, 2012 8:04 pm

I have new information about the problem. I was in form that consists only of fields in a table. I performed a search and got the results that I wanted. Then I did another search and got no results. I performed the first search again, and this time I got the same number of results as the first time, only all the fields were empty. The all the fields in every record that match my search criteria had been emptied. I reentered the missing data, then did another search for which there were no matching records. I then performed the first search a third time and the fields were emptied again. I had to reenter the data a second time.

Put more concisely, it seems that if I do a search and there are no matching records, the next search for which there are matching records clears out all the fields in those records.
adamk
 
Posts: 35
Joined: Sat Jun 30, 2007 2:33 am
Location: Lynnfield, MA

Re: losing data in web client by searching

Postby ngervasi » Mon Apr 23, 2012 8:11 pm

Weird but if it's reproducible create a case in the support system.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: losing data in web client by searching

Postby Harjo » Mon Apr 23, 2012 9:27 pm

It is hard to believe that Servoy clears or delete data, but if data is deleted, you should also see, some delete statements in the servoy-admin page....

did you have a look there?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: losing data in web client by searching

Postby adamk » Mon Apr 23, 2012 10:26 pm

Harjo wrote:It is hard to believe that Servoy clears or delete data, but if data is deleted, you should also see, some delete statements in the servoy-admin page....

did you have a look there?

I don't think Servoy would log any of this because no records are being deleted. The only thing that's happening is that the fields are being emptied. It's as if I clicked into each field and pressed backspace.

I did some experimenting and I discovered something important. Here's what happens:
I type some search criteria and click the Go button, which has a method attached to it that performs the search. No matter what I do, I never lose any data by clicking Go.
If I do the same thing, but press Enter instead of clicking the Go button, I lose data. Also, it only happens following a search for which there are no matching results. I perform a search, there are no results. I perform another search for which there are results. If I had clicked Go for the second search, no problem. If I had pressed Enter, the fields get emptied. I'll examine the methods to see if I can find a bug in the code.
adamk
 
Posts: 35
Joined: Sat Jun 30, 2007 2:33 am
Location: Lynnfield, MA

Re: losing data in web client by searching

Postby ngervasi » Mon Apr 23, 2012 10:33 pm

Execute some code to get the changed records output to the console after you have the issue, it's the best starting point to debug.
Check also if you are still in find mode or not when you see the empty records in your table view.
Nicola Gervasi
sintpro.com
SAN Partner
ngervasi
 
Posts: 1485
Joined: Tue Dec 21, 2004 12:47 pm
Location: Arezzo, Italy

Re: losing data in web client by searching

Postby adamk » Fri Apr 27, 2012 10:45 pm

I discovered that pressing Enter and clicking the Go button both run the same method. Whatever the problem is is not caused by the method alone. As a workaround, I've made it so that the Enter key no longer runs the method.
adamk
 
Posts: 35
Joined: Sat Jun 30, 2007 2:33 am
Location: Lynnfield, MA


Return to Servoy Web Client

Who is online

Users browsing this forum: No registered users and 2 guests