Fixing Brail Templates for VS Net wizards.
[castle.git] / MonoRail / TestSiteBrail / Controllers / AjaxController.cs
blobc8a429b26bd451eb1e4e13c212e48184fb68280f
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
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 Castle.MonoRail.Views.Brail.TestSite.Controllers
17 using System;
18 using System.Collections;
19 using Castle.MonoRail.Framework;
20 using Castle.MonoRail.Framework.Helpers;
22 public class AjaxController : SmartDispatcherController
24 public void AccountFormValidate(string name, string addressf)
26 string text1 = "";
27 if ((name == null) || (name.Length == 0))
29 text1 = "<b>Please, dont forget to enter the name<b>";
31 if ((addressf == null) || (addressf.Length == 0))
33 text1 += "<>Please, don't forget to enter the adress<b>";
35 this.RenderText(text1);
38 public void AddUserWithAjax(string name, string email)
40 this.GetList().Add(new User(name, email));
41 this.Index();
42 this.RenderView("/userlist");
45 public void AutoCom()
49 public void BuildFormRemoteTag()
51 Hashtable values = new Hashtable();
52 values.Add("url", "url");
53 this.RenderText(this.Helper.BuildFormRemoteTag(values));
56 private IList GetList()
58 IList list2 = this.Context.Session["list"] as IList;
59 if (list2 == null)
61 list2 = new ArrayList();
62 list2.Add(new User("somefakeuser", "fakeemail@server.net"));
63 list2.Add(new User("someotherfakeuser", "otheremail@server.net"));
64 this.Context.Session["list"] = list2;
66 return list2;
69 public void Index()
71 IList list1 = this.GetList();
72 this.PropertyBag.Add("users", list1);
75 public void JsFunctions()
77 this.RenderText(this.Helper.InstallScripts());
80 public void LinkToFunction()
82 this.RenderText(this.Helper.LinkToFunction("<img src='myimg.gid'>", "alert('Ok')"));
85 public void LinkToRemote()
87 this.RenderText(this.Helper.LinkToRemote("<img src='myimg.gid'>", "/controller/action.rails", new Hashtable()));
90 public void NameAutoCompletion(string name)
92 this.RenderText("<ul class=\"names\"><li class=\"name\">Jisheng Johnny</li><li class=\"name\">John Diana</li><li class=\"name\">Johnathan Maurice</li></ul>");
95 public void ObserveField()
97 this.RenderText(this.Helper.ObserveField("myfieldid", 2, "/url", "elementToBeUpdated", "newcontent"));
100 public void ObserveForm()
102 this.RenderText(this.Helper.ObserveForm("myfieldid", 2, "/url", "elementToBeUpdated", "newcontent"));
105 public void PeriodInvocation()
109 public void PeriodInvokeTarget()
111 this.RenderText("Ok");
115 public AjaxHelper Helper
119 return (AjaxHelper)this.Helpers["AjaxHelper"];
125 [Serializable]
126 private class User
128 public User(string name, string email)
130 this.name = name;
131 this.email = email;
135 public string Email
139 return this.email;
143 this.email = value;
147 public string Name
151 return this.name;
155 this.name = value;
160 protected string email;
161 protected string name;