Update of /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/Collections
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv12346/Collections
Modified Files:
Default.aspx Default.aspx.cs
Log Message:
improved WebQuickStart examples
fixed SPRNET-344
fixed SPRNET-696
fixed SPRNET-706
Index: Default.aspx.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/Collections/Default.aspx.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Default.aspx.cs 4 Dec 2006 00:08:36 -0000 1.1
--- Default.aspx.cs 23 Aug 2007 10:37:53 -0000 1.2
***************
*** 13,18 ****
private IList products;
! private IntegerFormatter quantityFormatter = new IntegerFormatter();
! private CurrencyFormatter priceFormatter = new CurrencyFormatter();
#endregion
--- 13,18 ----
private IList products;
! private readonly IntegerFormatter quantityFormatter = new IntegerFormatter();
! private readonly CurrencyFormatter priceFormatter = new CurrencyFormatter();
#endregion
***************
*** 44,47 ****
--- 44,48 ----
protected override void InitializeDataBindings()
{
+ // HttpRequestListBindingContainer unbinds specified values from Request -> Productlist
HttpRequestListBindingContainer requestBindings =
new HttpRequestListBindingContainer("sku,name,quantity,price", "Products", typeof(ProductInfo));
Index: Default.aspx
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/examples/Spring/Spring.WebQuickStart/src/Spring.WebQuickStart.2005/DataBinding/Collections/Default.aspx,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Default.aspx 4 Dec 2006 00:08:36 -0000 1.1
--- Default.aspx 23 Aug 2007 10:37:53 -0000 1.2
***************
*** 5,11 ****
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
! <title>Data Binding - Hello World example</title>
<script>
! function dodaj() {
var src = document.getElementById('itemTemplate');
var dst = document.getElementById('products');
--- 5,11 ----
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
! <title>Data Binding - HttpRequestListBindingContainer example</title>
<script>
! function addRow() {
var src = document.getElementById('itemTemplate');
var dst = document.getElementById('products');
***************
*** 15,54 ****
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
! This very simple web form demonstrates basic bi-directional data binding.
! </p>
! <p>
! Once you enter your name into the text box and submit the form (by hitting Enter),
! Spring.NET will evaluate data binding rules configured in the code-behind file and
! set the Name property of the page to the value of txtName.Text property.
</p>
<p>
! After that, page will be rendered again and Name property will be bound both
! to the text box, so you can change the value, and to the label below the text
! box, in order to show you how you can use one-way bindings to set non-writable
! properties.
</p>
Edit List: <br />
<div id="products">
<%
foreach (ProductInfo p in Products)
{
%>
! <div>
! <input name="sku" type="text" value="<%= p.Sku %>" style="width: 50px;" />
! <input name="name" type="text" value="<%= p.Name %>" style="width: 150px;" />
! <input name="quantity" type="text" value="<%= QuantityFormatter.Format(p.Quantity) %>" style="width: 30px;" />
! <input name="price" type="text" value="<%= PriceFormatter.Format(p.Price) %>" style="width: 50px;" />
! <br />
! </div>
<%
}
%>
</div>
<asp:Button ID="btnAdd" Text="Add" runat="server" OnClick="btnAdd_Click" />
<asp:Button ID="btnSave" Text="Save" runat="server" OnClick="btnSave_Click" />
! <button onclick="dodaj();">Dodaj</button>
</div>
</form>
--- 15,60 ----
</head>
<body>
+ <h2><a href="../../Default.aspx">Welcome to Spring.NET Web Framework Quick Start Guide</a></h2>
+ <h2><a href="../Default.aspx">Bi-directional DataBinding</a></h2>
<form id="form1" runat="server">
<div>
+ <h2>HttpRequestListBindingContainer example</h2>
<p>
! This form demonstrates unbinding data from HttpRequest.Form collection into a list model using HttpRequestListBindingContainer.
</p>
<p>
! HttpRequestListBindingContainer extracts posted values from the request and populates the specified IList by creating objects
! of the type specified and populating each of these objects according to the requestBindings collection.
</p>
+ <pre>
+ HttpRequestListBindingContainer requestBindings =
+ new HttpRequestListBindingContainer("sku,name,quantity,price", "Products", typeof(ProductInfo));
+ requestBindings.AddBinding("sku", "Sku");
+ requestBindings.AddBinding("name", "Name");
+ requestBindings.AddBinding("quantity", "Quantity", quantityFormatter);
+ requestBindings.AddBinding("price", "Price", priceFormatter);
+ </pre>
Edit List: <br />
<div id="products">
+ <table>
+ <tr><td>Firstname</td><td>Lastname</td><td>Quantity</td><td>Price/Item</td></tr>
<%
foreach (ProductInfo p in Products)
{
%>
! <tr>
! <td><input name="sku" type="text" value="<%= p.Sku %>" style="width: 50px;" /></td>
! <td><input name="name" type="text" value="<%= p.Name %>" style="width: 150px;" /></td>
! <td><input name="quantity" type="text" value="<%= QuantityFormatter.Format(p.Quantity) %>" style="width: 30px;" /></td>
! <td><input name="price" type="text" value="<%= PriceFormatter.Format(p.Price) %>" style="width: 50px;" /></td>
! </tr>
<%
}
%>
+ </table>
</div>
<asp:Button ID="btnAdd" Text="Add" runat="server" OnClick="btnAdd_Click" />
<asp:Button ID="btnSave" Text="Save" runat="server" OnClick="btnSave_Click" />
! <button onclick="addRow();">Add row using javascript</button>
</div>
</form>
***************
*** 57,61 ****
<input name="name" type="text" value="" style="width: 150px;" />
<input name="quantity" type="text" value="0" style="width: 30px;" />
! <input name="price" type="text" value="$0.00" style="width: 50px;" />
<br />
</div>
--- 63,67 ----
<input name="name" type="text" value="" style="width: 150px;" />
<input name="quantity" type="text" value="0" style="width: 30px;" />
! <input name="price" type="text" value="<%= PriceFormatter.Format(0) %>" style="width: 50px;" />
<br />
</div>
|