Minor style changes
[castle.git] / MonoRail / Castle.MonoRail.Framework / Helpers / WizardHelper.cs
blob2718bf4d2dde660288615194d843c4e73477f9eb
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.Framework.Helpers
17 using System;
18 using System.Collections;
20 using Castle.MonoRail.Framework.Internal;
22 /// <summary>
23 /// Provide useful helpers to be used in a layout view
24 /// or in the wizards steps views.
25 /// </summary>
26 public class WizardHelper : HtmlHelper
28 /// <summary>
29 /// Returns <c>true</c> if the current wizard
30 /// flow has a next step.
31 /// </summary>
32 /// <returns></returns>
33 public bool HasNextStep()
35 return WizardUtils.HasNextStep(Controller);
38 /// <summary>
39 /// Returns <c>true</c> if the current wizard
40 /// flow has an accessible previous step.
41 /// </summary>
42 /// <remarks>
43 /// This will only return <c>true</c> if not
44 /// the first step
45 /// </remarks>
46 /// <returns></returns>
47 public bool HasPreviousStep()
49 return WizardUtils.HasPreviousStep(Controller);
52 /// <summary>
53 /// Returns the name of the previous step
54 /// </summary>
55 public String PreviousStepName
57 get { return WizardUtils.GetPreviousStepName(Controller); }
60 /// <summary>
61 /// Returns the name of the next step
62 /// </summary>
63 public String NextStepName
65 get { return WizardUtils.GetNextStepName(Controller); }
68 #region LinkToStep
70 /// <overloads>This method has three overloads.</overloads>
71 /// <summary>
72 /// Creates an anchor tag (link) to the specified step.
73 /// <code>
74 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
75 /// </code>
76 /// </summary>
77 /// <param name="linkText">The label for the step</param>
78 /// <param name="step">The WizardStepPage to link to</param>
79 /// <returns></returns>
80 public String LinkToStep(String linkText, WizardStepPage step)
82 return LinkTo( linkText, step.WizardController.Name, step.ActionName);
85 /// <summary>
86 /// Creates an anchor tag (link) to the specified step.
87 /// <code>
88 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
89 /// </code>
90 /// </summary>
91 /// <param name="linkText">The label for the step</param>
92 /// <param name="step">The WizardStepPage to link to</param>
93 /// <param name="id">Object to use for the action ID argument.</param>
94 /// <returns></returns>
95 public String LinkToStep(String linkText, WizardStepPage step, object id)
97 return LinkTo( linkText, step.WizardController.Name, step.ActionName, id);
100 /// <summary>
101 /// Creates an anchor tag (link) to the specified step.
102 /// <code>
103 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
104 /// </code>
105 /// </summary>
106 /// <param name="linkText">The label for the step</param>
107 /// <param name="step">The WizardStepPage to link to</param>
108 /// <param name="id">Object to use for the action ID argument.</param>
109 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
110 /// <returns></returns>
111 public String LinkToStep(String linkText, WizardStepPage step, object id, IDictionary attributes)
113 return LinkToAttributed( linkText, step.WizardController.Name, step.ActionName, id, attributes);
116 #endregion
118 #region LinkToNext and LinkToPrevious
120 /// <overloads>This method has four overloads.</overloads>
121 /// <summary>
122 /// Creates an anchor tag (link) to the next step.
123 /// <code>
124 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
125 /// </code>
126 /// </summary>
127 /// <remarks>
128 /// This helper assumes there is a next step. It's advised
129 /// that you use <see cref="HasNextStep"/> before calling this
130 /// </remarks>
131 /// <param name="linkText">The label for the link</param>
132 /// <returns></returns>
133 public String LinkToNext(String linkText)
135 return LinkTo( linkText, Controller.Name, NextStepName );
138 /// <summary>
139 /// Creates an anchor tag (link) to the next step.
140 /// <code>
141 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
142 /// </code>
143 /// </summary>
144 /// <remarks>
145 /// This helper assumes there is a next step. It's advised
146 /// that you use <see cref="HasNextStep"/> before calling this
147 /// </remarks>
148 /// <param name="linkText">The label for the link</param>
149 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
150 /// <returns></returns>
151 public String LinkToNext(String linkText, IDictionary attributes)
153 return LinkToAttributed( linkText, Controller.Name, NextStepName, attributes );
156 /// <summary>
157 /// Creates an anchor tag (link) with an id attribute to the next step.
158 /// <code>
159 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
160 /// </code>
161 /// </summary>
162 /// <remarks>
163 /// This helper assumes there is a next step. It's advised
164 /// that you use <see cref="HasNextStep"/> before calling this
165 /// </remarks>
166 /// <param name="linkText">The label for the link</param>
167 /// <param name="id">Object to use for the action ID argument.</param>
168 /// <returns></returns>
169 public String LinkToNext(String linkText, object id)
171 return LinkTo( linkText, Controller.Name, NextStepName, id );
174 /// <summary>
175 /// Creates an anchor tag (link) with an id attribute to the next step.
176 /// <code>
177 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
178 /// </code>
179 /// </summary>
180 /// <remarks>
181 /// This helper assumes there is a previous step. It's advised
182 /// that you use <see cref="HasNextStep"/> before calling this
183 /// </remarks>
184 /// <param name="linkText">The label for the link</param>
185 /// <param name="id">Object to use for the action ID argument.</param>
186 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
187 /// <returns></returns>
188 public String LinkToNext(String linkText, object id, IDictionary attributes)
190 return LinkToAttributed( linkText, Controller.Name, NextStepName, id, attributes );
193 /// <overloads>This method has four overloads.</overloads>
194 /// <summary>
195 /// Creates an anchor tag (link) to the previous step.
196 /// <code>
197 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
198 /// </code>
199 /// </summary>
200 /// <remarks>
201 /// This helper assumes there is a previous step. It's advised
202 /// that you use <see cref="HasPreviousStep"/> before calling this
203 /// </remarks>
204 /// <param name="linkText">The label for the link</param>
205 /// <returns></returns>
206 public String LinkToPrevious(String linkText)
208 return LinkTo( linkText, Controller.Name, PreviousStepName );
211 /// <summary>
212 /// Creates an anchor tag (link) to the previous step.
213 /// <code>
214 /// &lt;a href=&quot;/page2.rails&quot;&gt;linkText&lt;/a&gt;
215 /// </code>
216 /// </summary>
217 /// <remarks>
218 /// This helper assumes there is a previous step. It's advised
219 /// that you use <see cref="HasPreviousStep"/> before calling this
220 /// </remarks>
221 /// <param name="linkText">The label for the link</param>
222 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
223 /// <returns></returns>
224 public String LinkToPrevious(String linkText, IDictionary attributes)
226 return LinkToAttributed( linkText, Controller.Name, PreviousStepName, attributes );
229 /// <summary>
230 /// Creates an anchor tag (link) with an id attribute to the previous step.
231 /// <code>
232 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
233 /// </code>
234 /// </summary>
235 /// <remarks>
236 /// This helper assumes there is a previous step. It's advised
237 /// that you use <see cref="HasPreviousStep"/> before calling this
238 /// </remarks>
239 /// <param name="linkText">The label for the link</param>
240 /// <param name="id">Object to use for the action ID argument.</param>
241 /// <returns></returns>
242 public String LinkToPrevious(String linkText, object id)
244 return LinkTo( linkText, Controller.Name, PreviousStepName, id );
247 /// <summary>
248 /// Creates an anchor tag (link) with an id attribute to the previous step.
249 /// <code>
250 /// &lt;a href=&quot;/page2.rails?Id=id&quot;&gt;linkText&lt;/a&gt;
251 /// </code>
252 /// </summary>
253 /// <remarks>
254 /// This helper assumes there is a previous step. It's advised
255 /// that you use <see cref="HasPreviousStep"/> before calling this
256 /// </remarks>
257 /// <param name="linkText">The label for the link</param>
258 /// <param name="id">Object to use for the action ID argument.</param>
259 /// <param name="attributes">Additional attributes for the <b>a</b> tag.</param>
260 /// <returns></returns>
261 public String LinkToPrevious(String linkText, object id, IDictionary attributes)
263 return LinkToAttributed( linkText, Controller.Name, PreviousStepName, id, attributes );
266 #endregion