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 Castle
.MonoRail
.Framework
.Helpers
18 using System
.Collections
;
20 using Castle
.MonoRail
.Framework
.Internal
;
23 /// Provide useful helpers to be used in a layout view
24 /// or in the wizards steps views.
26 public class WizardHelper
: HtmlHelper
29 /// Returns <c>true</c> if the current wizard
30 /// flow has a next step.
32 /// <returns></returns>
33 public bool HasNextStep()
35 return WizardUtils
.HasNextStep(Controller
);
39 /// Returns <c>true</c> if the current wizard
40 /// flow has an accessible previous step.
43 /// This will only return <c>true</c> if not
46 /// <returns></returns>
47 public bool HasPreviousStep()
49 return WizardUtils
.HasPreviousStep(Controller
);
53 /// Returns the name of the previous step
55 public String PreviousStepName
57 get { return WizardUtils.GetPreviousStepName(Controller); }
61 /// Returns the name of the next step
63 public String NextStepName
65 get { return WizardUtils.GetNextStepName(Controller); }
70 /// <overloads>This method has three overloads.</overloads>
72 /// Creates an anchor tag (link) to the specified step.
74 /// <a href="/page2.rails">linkText</a>
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
);
86 /// Creates an anchor tag (link) to the specified step.
88 /// <a href="/page2.rails">linkText</a>
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
);
101 /// Creates an anchor tag (link) to the specified step.
103 /// <a href="/page2.rails">linkText</a>
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
);
118 #region LinkToNext and LinkToPrevious
120 /// <overloads>This method has four overloads.</overloads>
122 /// Creates an anchor tag (link) to the next step.
124 /// <a href="/page2.rails">linkText</a>
128 /// This helper assumes there is a next step. It's advised
129 /// that you use <see cref="HasNextStep"/> before calling this
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
);
139 /// Creates an anchor tag (link) to the next step.
141 /// <a href="/page2.rails">linkText</a>
145 /// This helper assumes there is a next step. It's advised
146 /// that you use <see cref="HasNextStep"/> before calling this
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
);
157 /// Creates an anchor tag (link) with an id attribute to the next step.
159 /// <a href="/page2.rails?Id=id">linkText</a>
163 /// This helper assumes there is a next step. It's advised
164 /// that you use <see cref="HasNextStep"/> before calling this
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
);
175 /// Creates an anchor tag (link) with an id attribute to the next step.
177 /// <a href="/page2.rails?Id=id">linkText</a>
181 /// This helper assumes there is a previous step. It's advised
182 /// that you use <see cref="HasNextStep"/> before calling this
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>
195 /// Creates an anchor tag (link) to the previous step.
197 /// <a href="/page2.rails">linkText</a>
201 /// This helper assumes there is a previous step. It's advised
202 /// that you use <see cref="HasPreviousStep"/> before calling this
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
);
212 /// Creates an anchor tag (link) to the previous step.
214 /// <a href="/page2.rails">linkText</a>
218 /// This helper assumes there is a previous step. It's advised
219 /// that you use <see cref="HasPreviousStep"/> before calling this
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
);
230 /// Creates an anchor tag (link) with an id attribute to the previous step.
232 /// <a href="/page2.rails?Id=id">linkText</a>
236 /// This helper assumes there is a previous step. It's advised
237 /// that you use <see cref="HasPreviousStep"/> before calling this
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
);
248 /// Creates an anchor tag (link) with an id attribute to the previous step.
250 /// <a href="/page2.rails?Id=id">linkText</a>
254 /// This helper assumes there is a previous step. It's advised
255 /// that you use <see cref="HasPreviousStep"/> before calling this
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
);