Aug 25, 2009, 11:18 AM
store or form turns null-strings into empty strings
I fight against the problem that null-strings are turned into empty-strings.
The environment is Window Server 2003, Visual Studio 2008, C#, .NET 3.5
<ext:Store ID="ProductDetailStore" runat="server" ShowWarningOnFailure="true">
<Proxy>
<ext:HttpProxy Url="/ProductCoolite/GetProduct/" />
</Proxy>
<Reader>
<ext:JsonReader ReaderID="ProductID" Root="data" TotalProperty="totalCount">
<Fields>
<ext:RecordField Name="ProductID" Type="Int" SortDir="ASC" />
<ext:RecordField Name="NewDaoName" Type="String" />
<ext:RecordField Name="ProductNumber" Type="String" />
<ext:RecordField Name="MakeFlag" Type="Boolean" DefaultValue="false" />
<ext:RecordField Name="FinishedGoodsFlag" Type="Boolean" DefaultValue="false" />
<ext:RecordField Name="Color" Type="String" DefaultValue="null" />
<ext:RecordField Name="SafetyStockLevel" Type="Int" />
<ext:RecordField Name="ReorderPoint" Type="Int" />
<ext:RecordField Name="DaysToManufacture" Type="Int" />
<ext:RecordField Name="ListPrice" Type="Auto" DefaultValue="null" />
<ext:RecordField Name="ProductLine" Type="String" DefaultValue="null" />
<ext:RecordField Name="Class" Type="String" DefaultValue="null" />
<ext:RecordField Name="Style" Type="String" DefaultValue="null" />
<ext:RecordField Name="SellStartDate" Type="Date" DateFormat="d.m.Y" />
<ext:RecordField Name="SellEndDate" Type="Date" DateFormat="d.m.Y" DefaultValue="null" />
<ext:RecordField Name="DiscontinuedDate" Type="Date" DateFormat="d.m.Y" DefaultValue="null" />
<ext:RecordField Name="ProductSubcategoryID" Type="Int" DefaultValue="null" />
</Fields>
</ext:JsonReader>
</Reader>
<BaseParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="filter" Value="#{txtFilter}.getValue()" Mode="Raw" />
</BaseParams>
<Listeners>
<BeforeLoad Handler="#{ProductPanel}.el.mask('Lade die Produkte...', 'x-mask-loading');" />
<LoadException Handler="#{ProductPanel}.el.unmask();" />
<Load Fn="productLoaded" />
</Listeners>
</ext:Store>
....
<ext:FormPanel ID="DetailsForm" runat="server" Border="false" Url="/ProductCoolite/SaveProduct/">
....
<ext:FormLayout ID="gdFormLayout1" runat="server" LabelSeparator="" LabelWidth="130" MsgTarget="Side" AllowBlank="false">
......
<ext:Anchor Horizontal="95%">
<ext:TextField ID="Style" runat="server" FieldLabel="Style" AllowBlank="true" />
</ext:Anchor>
The json string downloaded from the server has a null value at Class and Style
{data:[{"ProductID":876,"NewDaoName":"Hitch Rack - 4-Bike Tele","ProductNumber":"RA-H123","MakeFlag"
:false,"FinishedGoodsFlag":true,"Color":null,"SafetyStockLevel":4,"ReorderPoint":3,"StandardCost":44
.8800,"ListPrice":120.0000,"Size":null,"SizeUnitMeasureCode":null,"WeightUnitMeasureCode":null,"Weight"
:null,"DaysToManufacture":0,"ProductLine":"S","Class":null,"Style":null,"ProductSubcategoryID":26,"ProductModelID"
:null,"SellStartDate":"2003-07-02T00:00:00","SellEndDate":null,"DiscontinuedDate":null,"rowguid":"00000000-0000-0000-0000-000000000000"
,"ModifiedDate":"2004-03-11T10:01:36"}
Sending back the updated product, the null values of Class and Style turned into a empty string ("").
{"Updated":[{"ProductID":876,"NewDaoName":"Hitch Rack - 4-Bike Tele","ProductNumber":"RA-H123","MakeFlag":true,"FinishedGoodsFlag":true,
"Color":"","SafetyStockLevel":4,"ReorderPoint":3,"DaysToManufacture":0,"ListPrice":120,"ProductLine":"S ",
"Class":"","Style":"","SellStartDate":"2003-07-02T00:00:00","SellEndDate":null,"DiscontinuedDate":null,"ProductSubcategoryID":26}]}
How can I avoid this behavoir? Dates (defined as DateTime?) are correctly returned as null values. Why not strings? Do I have to check every string on the server-side and set them to null by myself? In the database null values are allowed but not empty strings.Many thanks for your help.
Hans