I did some research on the net, found this website with valuable information. I work a lot with conditionals using javascript, see an excerpt from my function that receives radiogroup as a parameter and verifies whether it was selected yes or no, thus performing the necessary tasks:
var habilitarCampo3 = function(obj, selectedRadio)
{
if(selectedRadio.inputValue == "NAO"){
Ext.getCmp('comJustificativaAviso').setVisible(true);
if (iAtividade == 7)
{
TransitionData2Form.insertMandatory('comJustificativaAviso','Justifique o não desconto do Aviso Prévio!');
}
}
else{
Ext.getCmp('comJustificativaAviso').setVisible(false);
TransitionData2Form.removeMandatory('comJustificativaAviso');
Ext.getCmp('comJustificativaAviso').setValue(Ext.getCmp('procedeJuridico').getValue().inputValue);
}
};
Sometimes this code stays in the radiogroup object itself, see:
checkSolicitacoesRealizadas = new Ext.form.RadioGroup
({
width:600,
fieldLabel:'Solicitações foram realizadas',
labelSeparator: '?',
id:'checkSolicitacoesRealizadas',
value:'ZERO',
listeners:
{
change: function(obj, selectedRadio)
{
if (selectedRadio.inputValue == "NAO")
{
alert('É obrigatório a geração das solicitações');
Ext.getCmp('checkSolicitacoesRealizadas').setValue('ZERO');
}
}
},
items: [
{boxLabel: '<b style="color:green;" >Sim</b>', name: 'checkSolicitacoesRealizadas-op', inputValue: "SIM"},
{boxLabel: '<b style="color:green;" >Sim</b>', hidden:true, name: 'checkSolicitacoesRealizadas-op', inputValue: "ZERO"},
{boxLabel: '<b style="color:red;" >Não</b>', name: 'checkSolicitacoesRealizadas-op', inputValue: "NAO"}
]
});
Here's one of the hundreds of conditionals in my code:
if (Ext.getCmp('tipoRescisao').getValue() == 02 &&
Ext.getCmp('tipoSolicitacao').getValue().inputValue == 'desligamento')
{
if (Ext.getCmp('dataInicioAvisoPrevio').getValue() == '')
{
msgErro += "\n É Obrigatório [Data Início Aviso Prévio]!";
}
}
My question is: Is there any Design Patterns that deals with a better way to organize conditional structures by performing some code usage during the field value comparison? I wanted to organize a dynamic and intelligent structure to perform the value comparisons of the form fields. I hope I was clear on the question. Any questions I can improve the question, this is very important to me.