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 TestSiteNVelocity
.Controllers
18 using System
.Collections
;
20 using Castle
.MonoRail
.Framework
;
23 public class AjaxController
: SmartDispatcherController
27 public void ObserveField()
31 public void InferAddress(String
value)
33 RenderText("Address " + value);
40 public void ObserveForm()
45 public void AccountFormValidate(String name
, String addressf
)
47 RenderText("name {0} address {1}", name
, addressf
);
52 #region AutoCompletion
55 /// Auto completion action
62 /// Auto completion results
64 public void NameAutoCompletion(String name
)
66 RenderText("<ul class=\"names\"><li class=\"name\">Jisheng Johnny</li><li class=\"name\">John Diana</li><li class=\"name\">Johnathan Maurice</li></ul>");
71 #region Periodically calls
73 public void PeriodicallyCall()
80 public void PeriodicallyCalled(int value)
82 RenderText((value + value).ToString());
89 public void JsProxies()
95 public void InvocableMethod1()
97 RenderText("Success");
100 [AjaxAction("friendlyName")]
101 public void InvocableMethod2(String
value)
103 RenderText("Success " + value);
108 #region BuildFormRemoteTag
110 public void FormRemoteTag()
112 IList list
= GetList();
113 PropertyBag
.Add("users", list
);
116 public void AddUserWithAjax(String name
, String email
)
118 GetList().Add(new User(name
, email
));
120 IList list
= GetList();
121 PropertyBag
.Add("users", list
);
123 RenderView("/userlist");
126 private IList
GetList()
128 IList list
= Context
.Session
["list"] as IList
;
132 list
= new ArrayList();
134 list
.Add(new User("somefakeuser", "fakeemail@server.net"));
135 list
.Add(new User("someotherfakeuser", "otheremail@server.net"));
137 Context
.Session
["list"] = list
;
149 private String email
;
151 public User(string name
, string email
)
164 get { return email; }