fixed SPRNET-1118, updated refdocs
This commit is contained in:
@@ -692,7 +692,17 @@ bool userInfoIsValid = userInfoValidator.Validate(userInfo, errors);
|
||||
</object>
|
||||
|
||||
<v:group id="tripValidator">
|
||||
// our validation rules
|
||||
<v:required id="departureAirportValidator" test="StartingFrom.AirportCode">
|
||||
<!-- write error message to 2 providers -->
|
||||
<v:message id="error.departureAirport.required" providers="departureAirportErrors, errorSummary"/>
|
||||
</v:required>
|
||||
|
||||
<v:group id="destinationAirportValidator">
|
||||
<v:required test="ReturningFrom.AirportCode">
|
||||
<!-- write error message to 2 providers -->
|
||||
<v:message id="error.destinationAirport.required" providers="destinationAirportErrors, errorSummary"/>
|
||||
</v:required>
|
||||
</v:group>
|
||||
</v:group>
|
||||
|
||||
</objects></programlisting>
|
||||
@@ -719,83 +729,30 @@ bool userInfoIsValid = userInfoValidator.Validate(userInfo, errors);
|
||||
<literal><spring:validationSummary/></literal> controls to the
|
||||
ASP.NET form:</para>
|
||||
|
||||
<programlisting language="myxml"><%@ Page Language="c#" MasterPageFile="~/Web/StandardTemplate.master" Inherits="TripForm" CodeFile="TripForm.aspx.cs" %>
|
||||
<%@ Register TagPrefix="spring" Namespace="Spring.Web.UI.Controls" Assembly="Spring.Web" %>
|
||||
|
||||
<asp:Content ID="head" ContentPlaceHolderID="head" runat="server">
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
<!--
|
||||
function showReturnCalendar(isVisible)
|
||||
{
|
||||
document.getElementById('<%= returningOnDate.ClientID %>').style.visibility = isVisible? '': 'hidden';
|
||||
document.getElementById('returningOnCalendar').style.visibility = isVisible? '': 'hidden';
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
|
||||
</asp:Content>
|
||||
|
||||
<asp:Content ID="body" ContentPlaceHolderID="body" runat="server">
|
||||
<div style="text-align: center">
|
||||
<h4><asp:Label ID="caption" runat="server"></asp:Label></h4>
|
||||
<spring:ValidationSummary ID="validationSummary" runat="server" />
|
||||
<programlisting language="myxml"><!-- code snippet taken from the SpringAir sample application -->
|
||||
<%@ Page Language="c#" MasterPageFile="~/Web/StandardTemplate.master" Inherits="TripForm" CodeFile="TripForm.aspx.cs" %>
|
||||
|
||||
<!-- render all error messages sent to 'errorSummary' provider -->
|
||||
<spring:ValidationSummary ID="summary" Provider="errorSummary" runat="server" />
|
||||
<table>
|
||||
<tr class="formLabel">
|
||||
<td>&nbsp;</td>
|
||||
<td colspan="3">
|
||||
<spring:RadioButtonGroup ID="tripMode" runat="server">
|
||||
<asp:RadioButton ID="OneWay" onclick="showReturnCalendar(false);" runat="server" />
|
||||
<asp:RadioButton ID="RoundTrip" onclick="showReturnCalendar(true);" runat="server" />
|
||||
</spring:RadioButtonGroup>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="formLabel" align="right">
|
||||
<td>
|
||||
<asp:Label ID="leavingFrom" runat="server" /></td>
|
||||
<td nowrap="nowrap">
|
||||
<td>
|
||||
<asp:DropDownList ID="leavingFromAirportCode" AutoCallBack="true" runat="server" />
|
||||
<spring:ValidationError id="departureAirportErrors" runat="server" />
|
||||
<!-- render error messages sent to 'departureAirportErrors' provider -->
|
||||
<spring:ValidationError ID="leavingFromError" Provider="departureAirportErrors" runat="server" />
|
||||
</td>
|
||||
<td class="formLabel" align="right">
|
||||
<td>
|
||||
<asp:Label ID="goingTo" runat="server" /></td>
|
||||
<td nowrap="nowrap">
|
||||
<td>
|
||||
<asp:DropDownList ID="goingToAirportCode" AutoCallBack="true" runat="server" />
|
||||
<spring:ValidationError id="destinationAirportErrors" runat="server" />
|
||||
<!-- render error messages sent to 'destinationAirportErrors' provider -->
|
||||
<spring:ValidationError ID="goingToError" Provider="destinationAirportErrors" runat="server" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="formLabel" align="right">
|
||||
<asp:Label ID="leavingOn" runat="server" /></td>
|
||||
<td nowrap="nowrap">
|
||||
<spring:Calendar ID="leavingFromDate" runat="server" Width="75px" AllowEditing="true" Skin="system" />
|
||||
<spring:ValidationError id="departureDateErrors" runat="server" />
|
||||
</td>
|
||||
<td class="formLabel" align="right">
|
||||
<asp:Label ID="returningOn" runat="server" /></td>
|
||||
<td nowrap="nowrap">
|
||||
<div id="returningOnCalendar">
|
||||
<spring:Calendar ID="returningOnDate" runat="server" Width="75px" AllowEditing="true" Skin="system" />
|
||||
<spring:ValidationError id="returnDateErrors" runat="server" />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="buttonBar" colspan="4">
|
||||
<br/>
|
||||
<asp:Button ID="findFlights" runat="server"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
if (document.getElementById('<%= tripMode.ClientID %>').value == 'OneWay')
|
||||
showReturnCalendar(false);
|
||||
else
|
||||
showReturnCalendar(true);
|
||||
</script>
|
||||
|
||||
</asp:Content></programlisting>
|
||||
</programlisting>
|
||||
|
||||
<section>
|
||||
<title>Rendering Validation Errors</title>
|
||||
@@ -927,5 +884,50 @@ bool userInfoIsValid = userInfoValidator.Validate(userInfo, errors);
|
||||
<para>It's as simple as that!</para>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title>How Validate() and Validation Controls play together</title>
|
||||
|
||||
<para> Validation Controls (ValidationSummary, ValidationError) need to
|
||||
somehow get the list of errors collected during validation. Both,
|
||||
Spring.Web.UI.Page and Spring.Web.UI.UserControl come with a
|
||||
ValidationErrors property and implement IValidationContainer.
|
||||
ValidationControls will automatically pick the IValidationContainer
|
||||
control they are placed on:</para>
|
||||
|
||||
<para><programlisting language="myxml">// ASPX / ASCX Template Code
|
||||
<%@ Control Language="c#"%>
|
||||
|
||||
<!-- render all error messages sent to 'errorSummary' provider -->
|
||||
<spring:ValidationSummary ID="summary" Provider="errorSummary" runat="server" />
|
||||
|
||||
<asp:DropDownList ID="leavingFromAirportCode" AutoCallBack="true" runat="server" />
|
||||
<!-- render error messages sent to 'departureAirportErrors' provider -->
|
||||
<spring:ValidationError ID="leavingFromError" Provider="departureAirportErrors" runat="server" />
|
||||
|
||||
|
||||
<script language="C#" runat="server">
|
||||
public void SearchForFlights(object sender, EventArgs e)
|
||||
{
|
||||
if (Validate(Controller.Trip, tripValidator))
|
||||
{
|
||||
Process.SetView(Controller.SearchForFlights());
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
</programlisting>If you need to render errors from a UserControl not in the
|
||||
hierarchy of your Validation control, you can specify the name of the
|
||||
target validation container control:</para>
|
||||
|
||||
<para><programlisting language="myxml">// ASPX / ASCX Template Code
|
||||
<%@ Page Language="c#" %>
|
||||
<%@ Register TagPrefix="user" TagName="EmployeeInfoEditor" Src="EmployeeInfoEditor.ascx" %>
|
||||
|
||||
<spring:ValidationSummary ID="summary" Provider="summary" ValidationContainerName="editor" runat="server" />
|
||||
<user:EmployeeInfoEditor ID="editor" runat="server" />
|
||||
|
||||
</programlisting></para>
|
||||
</section>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
Reference in New Issue
Block a user