in

ASP.NET Weblogs

guyS's WebLog

IShare, My DotNet Fingerprint

XML2HTML_ENTRY_FORM : The XML Structure - Step #1

I'm going to use two XMLs that hold the set of rules for each HTML entry form. The first XML will hold the input element/s definitions and values (when returned from the client). The second XML will hold all the Validations definitions & dependencies.

This is amazing - but few minutes ago, before I started to write about it I got email which links to an Article in FTPOnline web site (http://www.ftponline.com/javapro/2004_03/online/xml_jboltz_03_17_04/default_pf.aspx) and explains a very similar problem/solution (Its seems that we all make our living from the same stuff).

Have a look at the XML Elements I define:

Input Elements Definitions (first XML)-

Name - p1, p2 …..p-N (parameter #1….) - must be unique for JS manipulations

InternalName - optional

Type - TextBox, Hidden, CheckBox, ListBox, Multiple ListBox, RadioButtonsGroup, CheckBoxesGroup

Required - is the value for the parameter which is required

Default Value - Can be a constant but can also come from a Data Fetcher (a methods that gets 0 or more Arguments and return a list of values)

Validations -

Type - Required, Range, RegularExpression and actually the types we have in ASP.NET Web Controls. The functionality will be implemented by me in the client JS functions

TargetParameter - on which input element we need to activate the validation

ActivateOn - the event name when the validation should take place (OnBlur, OnChange, OnSubmit)

UseDataFetcher - if true - then the parameter values will retrieved from external data fetcher source during construction (the call will be done with an optional arguments list of values)

<Params>

<Param Name="p1" Title="ItemFriendlyName" ControlType="[ListBox]" ToolTip="Select a ItemFriendlyName from the list"

UseDataFetcher="True" ParamOrder="1" InternalName="">

<DataFetcher Name="ProductsByCategory">

<Arg Name="CategoryID" Type="string">Shoes</Arg>

<Arg Name="CustomerID" Type="long">43312</Arg>

</DataFetcher>

<ParamValues Type="[Numeric or string]" MaxLength="12">

<ReturnValue>a</ReturnValue>><!--when the client submit the form I should create these elemenst-->

<DefaultValue>hello</DefaultValue>

</ParamValues>

</Param>

<Param Name="p2" Title="ItemFriendlyName" ControlType="[MultipleListBox]"

ToolTip="Select a ItemFriendlyName from the list" UseDataFetcher="False" ParamOrder="2"

DataFetcher="N" InternalName="">

<ParamValues Type="[Numeric or string]" MaxLength="12">

<ReturnValue>a</ReturnValue><!--when the client submit the form I should create these elemenst-->

<ReturnValue>b</ReturnValue>

<ReturnValue>c</ReturnValue>

<DefaultValue>hello world</DefaultValue>

<DefaultValue>foo</DefaultValue>

</ParamValues>

</Param>

<Param Name="p3" Title="ItemFriendlyName" ControlType="Hidden" UseDataFetcher="False" ParamOrder="3" InternalName="">

<ParamValues Type="[Numeric or string]">

<ReturnValue>a</ReturnValue>

<DefaultValue>hello</DefaultValue>

</ParamValues>

</Param>

<!--custom type parameter will enable me to group several parameters by their types and during construction activate the relevant type manipulations-->

<Param Name="p6" ParamType="CustomType" InternalName="GivenName" ControlType="Hidden" UseDataFetcher="False" ParamOrder="3">

<ParamValues Type="[Numeric or string]">

<ReturnValue>a</ReturnValue>

<DefaultValue>hello</DefaultValue>

</ParamValues>

</Param>

Validations -

You can see the validations are the same as what we have in ASP.NET validation controls

<Validation ValiditionType="Required" ParamName="p1" ErrorMessege="You should type ($ParamName)!" onblur="false" onsubmit="true" onload="false" />

<Validation ValiditionType="Compare" ParamName="p1" Oprator="GT" TargetParam="p2" TargetValue="" onblur="false" onsubmit="true" onload="false"/>

<!--param type will be taken from the above param def Xml-->

<Validation ValiditionType="Range" ParamName="p1" MinValue="1" MaxValue="10000" onblur="false" onsubmit="true" onload="false"/>

<Validation ValiditionType="RegularExp" ParamName="p1" Expression="[A-Z]" onblur="false" onsubmit="true" onload="false" />

<Validation ValiditionType="CustomJS" ParamName="p1" JSFunction="validateProductID">

<Argument Type="string">Guy S.</Argument>

<Argument Type="param">p2</Argument>

</Validation>

Dependencies -

Compare Dependency - when one of the form elements (equal to, greater then etc) how other element/s (one or more) will be reflected

For each dependency I define one or more Action XML element/s that enable us to do something the moment a Dependency been fired

Actions Examples -

Set a value to one of the other input elements (constant value or from other element)

Set values from a Data Fetcher - a JS Function which by using HTTP Request to the server enable us to retrieve data from our repository and set the specified element/s

Call a Custom JS Function

GroupCompare - when the event that trigger the dependency occur a logical condition between the Group Items should be commited

in case the condition fullfill - the Actions will be done

<Dependency Type="Compare" SourceParam="p1" Operator="GT" TargetParam="" TargetValue=""

onblur="false" onsubmit="true" onload="false">

<Action Type="SetValue" TargetParam="p3" Value="1"/>

<Action Type="SetParamValue" TargetParam="p5" SourceParam="p6"/>

<Action Type="SetDataFetcherValue" FetcherName="GetDvisionByCustomer" ArgsValues="1,2,3" ParamArgsValues="p7,p8"/>

<Action Type="Hide" TargetParam="p9"/>

<Action Type="CustomJS" JSFunction="DoSomething" ArgsValues="1,2,3" ParamArgsValues="p7,p8"/>

</Dependency>

<Dependency Type="GroupCompare">

<GroupItem SourceParam="p1" Operator="GT" TargetParam="p2" TargetValue="" GroupCondition="" />

<GroupItem SourceParam="p3" Operator="EQUAL" TargetParam="" TargetValue="4" GroupCondition="And" />

<GroupItem SourceParam="p3" Operator="GT" TargetParam="" TargetValue="4" GroupCondition="" />

ActivateOn="[OnLoad, OnSubmit, OnBlur]">

<Action Type="SetValue" TargetParam="p3" Value="1"/>

<Action Type="SetParamValue" TargetParam="p5" SourceParam="p6"/>

<Action Type="SetDataFetcherValue" FetcherName="GetProductByCategory" />

<Argument Type="string">Guy S.</Argument>

<Argument Type="param">p2</Argument>

</Action>

<Action Type="Hide" TargetParam="p9"/>

<Action Type="CustomJS" JSFunction="DoSomething"/>

<Argument Type="string">Guy S.</Argument>

<Argument Type="param">p2</Argument>

</Action

</Dependency>

Question/s, feedback/s and resources are more then welcome

Published Mar 21 2004, 02:45 PM by guyS
Filed under:

Comments

 

TrackBack said:

March 21, 2004 3:04 PM
 

TrackBack said:

March 22, 2004 1:58 AM
 

TrackBack said:

April 8, 2004 1:01 PM
 

TrackBack said:

April 17, 2004 3:27 PM

Leave a Comment

(required)  
(optional)
(required)  
Add