1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace TestSite
.Controllers
17 using Castle
.MonoRail
.Framework
;
19 public class BindingController
: SmartDispatcherController
26 #region Basic Controls
28 public void BasicAction()
33 public void ClickMe(string selection
, string text
)
35 RenderText(string.Format("Button was clicked (\"{0}\" / \"{1}\")", selection
, text
));
38 public void SelectMe(string selection
)
40 RenderText("'{0}' was selected", selection
);
43 public void ChangeMe(string text
)
45 RenderText("Text was changed to '{0}'", text
);
48 public void CheckMe(bool isChecked
)
50 RenderText(string.Format("Checkbox was {0}checked", isChecked
? "" : "un"));
53 public void PickMe(string name
)
55 RenderText(string.Format("RadioButton '{0}' was checked", name
));
58 public void Command(string commandName
, object commandArg
)
60 RenderText("Command '{0}' with arg '{1}'", commandName
, commandArg
);
65 #region DataBound Controls
67 public void DataBound()
71 PropertyBag
["Employees"] = new Employee
[]
73 new Employee(1, "Craig Neuwirt", "USA"),
74 new Employee(2, "Hamilton Verissimo", "Brazil"),
75 new Employee(3, "Ayende Rahien", "Israel")
80 public void SelectRow(string argument
, int id
, string name
)
82 RenderText(string.Format("Row {0} Employee {1} ({2}) was selected", argument
, name
, id
));
85 public void EditRow(string argument
)
87 RenderText(string.Format("Row {0} was edited", argument
));
90 public void DeleteRow(int rowIndex
)
92 RenderText(string.Format("Row {0} was deleted", rowIndex
));
95 public void SortRows(string argument
)
97 RenderText(string.Format("Sort rows with expression {0}", argument
));
103 #region User Controls
105 public void UserControls()
109 public void AddEmployee(string name
, string country
)
111 RenderText("Add employee {0} from {1}", name
, country
);
114 public void RemoveEmployee(int id
)
116 RenderText("Remove employee with id {0}", id
);
122 #region Employee Model
124 public class Employee
128 private string country
;
135 public Employee(int id
, string name
, string country
)
139 this.country
= country
;
151 set { name = value; }
154 public string Country
156 get { return country; }
157 set { country = value; }