May 08, 2012, 7:13 PM
[CLOSED] RemoteValidation not firing when text is not changed
Hi.
I have a form that loads information in a multilanguage scenario.
Let's say we are managing Countries with their translations.
There are two classes:
Country {Id, ISO}
ConutryTr{Id, Country_Id, Language_Id, Name}
The form has at least a TextField for ISO, another for Name and a Combo with languages.
By default the combo selects one languaje, let's say English.
The ISO text is filled once as it is not translated.
The textbox for Name is filled with the information in that language, let's say: Germany
The form mandatory needs to be filled in all languajes.
I change the combo and select other language, lest's say, Spanish.
There, a DirectEvent is fired, and serverside I perform this operations:
Get last selected language (english)
Assign to English translation the text Germany
Blanks Name text
Shows new selected languaje in combo (Spanish).
Every time I change Language, this operation happens without problem.
The problem comes with the Text Field Remote validation.
Every time the textbox changes it fires a remote validation that validates not only the "not empty" status of the textbox itself, but that all translations are filled serverside.
If I add a new Country, I enter the first Country name in English. Let's say: 'Colombia'
Then select the new language (Spanish), so "Colombia" is assigned to English translation of the Country.
The Textbox for name is cleared and also its validation (so, no validation error is shown until a new remote validation).
When I enter the new translated name for the country it must be different. In the case of Colombia, both for English and Spanish spells the same, so if I type once "Colombia" the Remote validation is not fired. It seems like the control remembers the last text before clear().
If I type slowly and partially the name, "Col"... wait ... "ombia" then the RemoteValidation fires twice and everything runs fine.
Is there anyway to force Remotevalidation it doesn matter the text doesn't change?
I can't paste the whole code cause it calls some clases and methods and the post will get too long, but here are the essentials:
Name textbox:
Thanks
Regards
Fernando
I have a form that loads information in a multilanguage scenario.
Let's say we are managing Countries with their translations.
There are two classes:
Country {Id, ISO}
ConutryTr{Id, Country_Id, Language_Id, Name}
The form has at least a TextField for ISO, another for Name and a Combo with languages.
By default the combo selects one languaje, let's say English.
The ISO text is filled once as it is not translated.
The textbox for Name is filled with the information in that language, let's say: Germany
The form mandatory needs to be filled in all languajes.
I change the combo and select other language, lest's say, Spanish.
There, a DirectEvent is fired, and serverside I perform this operations:
Get last selected language (english)
Assign to English translation the text Germany
Blanks Name text
Shows new selected languaje in combo (Spanish).
Every time I change Language, this operation happens without problem.
The problem comes with the Text Field Remote validation.
Every time the textbox changes it fires a remote validation that validates not only the "not empty" status of the textbox itself, but that all translations are filled serverside.
If I add a new Country, I enter the first Country name in English. Let's say: 'Colombia'
Then select the new language (Spanish), so "Colombia" is assigned to English translation of the Country.
The Textbox for name is cleared and also its validation (so, no validation error is shown until a new remote validation).
When I enter the new translated name for the country it must be different. In the case of Colombia, both for English and Spanish spells the same, so if I type once "Colombia" the Remote validation is not fired. It seems like the control remembers the last text before clear().
If I type slowly and partially the name, "Col"... wait ... "ombia" then the RemoteValidation fires twice and everything runs fine.
Is there anyway to force Remotevalidation it doesn matter the text doesn't change?
I can't paste the whole code cause it calls some clases and methods and the post will get too long, but here are the essentials:
Name textbox:
<ext:TextField ID="txtNombre" runat="server" Width="250" FieldLabel="Nombre"
MaxLength="200" MsgTarget="Side" IsRemoteValidation="true">
<RemoteValidation OnValidation="VerificarTraduccionesNombre" Timeout="2147483647">
</RemoteValidation>
</ext:TextField>
Validation handlerProtected Sub VerificarTraduccionesNombre(ByVal sender As Object, ByVal e As Ext.Net.RemoteValidationEventArgs)
txtNombre.ClearInvalid()
Dim mPais As Pais = EntidadObtener("Pais")
Dim mValido As Boolean = True
Dim mIdiomasIncompletos As String = ""
Dim mCantidadIdiomas As Integer = 0
For Each mTr As PaisTr In mPais.Traducciones 'Traducciones = Translations. Type= List(Of PaisTr)
If mTr.Idioma <> cmbIdiomas.SelectedItem.Value AndAlso mTr.Nombre = "" Then 'Checks for every Translation to be filled but the new selected one (which is expected to be filled now)
mValido = False
If mCantidadIdiomas = 0 Then
mIdiomasIncompletos = (New Idioma(mTr.Idioma)).Nombre
Else
mIdiomasIncompletos &= ", " & (New Idioma(mTr.Idioma)).Nombre
End If
mCantidadIdiomas += 1
End If
Next
If Not mValido Then
e.Success = False
If mCantidadIdiomas = 1 Then
e.ErrorMessage = "Falta especificar la traducción para el idioma " & mIdiomasIncompletos
Else
e.ErrorMessage = "Falta especificar la traducción para los siguientes idiomas: " & mIdiomasIncompletos
End If
Else
e.Success = True
End If
End Sub
Sorry for the spanish and VB.NET (I don't know which one of them dislikes you more) ;-)Thanks
Regards
Fernando
Last edited by Daniil; May 11, 2012 at 4:37 PM.
Reason: [CLOSED]