all groups > macromedia flash flash remoting > october 2003 >
You're in the

macromedia flash flash remoting

group:

Binding Null Fields from a Remoting Recordset


Binding Null Fields from a Remoting Recordset Simon Sadler
10/22/2003 3:36:04 PM
macromedia flash flash remoting:
I'm setting a DataSet's DataProvider with a Remoting recordset containing fields with a null value. The type seems to be correctly converted to undefined but binding from the DataSet to a TextInput shows the string "undefined" in the field. Surely no one would want the UI to show such a value; the input should just be set to an empty string. I have reported this as a bug but in the mean time what is the best way around the problem? There are two options as far as I see:

1. Set all relevant fields in the database to "not null". Undesirable.

2. Use code to convert the nulls to empty strings at some point. Where do you think the best place would be for such an operation? A formatter perhaps.

Is there another way? How have others handled this?


Many thanks.

Re: Binding Null Fields from a Remoting Recordset djnetwerk
10/29/2003 1:07:49 AM
I've been wondering about this also. I've been just ignoring it for now hoping there would be an easy fix. A custom formatter does work though. Here's what I have. Its just annoying adding a custom formatter to practically every stinking field in the dataset.

Here is the custom formatter. Just save this in a file called NullFormatter.as in your classpath and in your dataset change your formatter to custom formatter and add NullFormatter as your formatter options. If there is a better way please someone say something!

class NullFormatter
{
function NullFormatter ()
{
trace ("NullFormatter initiated!");
}
function format () {
var value = arguments [ 0 ];
var returnValue;
if (value == undefined) {
returnValue = "";
}
else
{
returnValue = value;
}
return returnValue;
}
// convert blank strings back to null
function unformat() {
var value = arguments [ 0 ];
var returnValue;
if (value == "") {
returnValue = undefined;
}
else
{
returnValue = value;
}
return returnValue;
}
}

AddThis Social Bookmark Button