If you want the flag to disappear when the user enters some text, you could add a listener to the text input that clears the flag when the text changes.
On Dec 21, 2010, at 10:02 PM, Luiz Gustavo wrote: > Hi Greg, > > I'm calling salvarEdicao when the user submit de form. I whant to validate > the requeired fields befor inserting. > I'll se the classes you told me, but in my scenario is there anything I can > do? > > > > 2010/12/22 Greg Brown <[email protected]> > When are you calling the salvarEdicao() method? If you want to validate as > the user types, you'll need to call this method whenever the field value > changes. For text, you may want to consider using a validator for this. See > the classes in org.apache.pivot.wtk.validation and TextInput#setValidator(). > > > On Dec 21, 2010, at 9:37 PM, Luiz Gustavo wrote: > >> Hi, >> >> I'm having problems using Form.flag. >> >> >> I have a method for inserting data from a form, and a validation on the >> begining: >> >> >> private void salvarEdicao() { >> >> try { >> >> Form.Flag flagDesc = null; >> Form.Flag flagVal = null; >> Form.Flag flagCat = null; >> >> String desc = descricao.getText(); >> String val = valor.getText(); >> >> if(desc == null || "".equals(desc.trim())){ >> flagDesc = new Form.Flag(MessageType.ERROR, >> resources.get("campoRequerido").toString()); >> } >> Form.setFlag(descricao, flagDesc); >> >> if(val == null || "".equals(val.trim())){ >> flagVal = new Form.Flag(MessageType.ERROR, >> resources.get("campoRequerido").toString()); >> } >> Form.setFlag(valor, flagVal); >> >> if(categoria == null){ >> flagCat = new Form.Flag(MessageType.ERROR, >> resources.get("campoRequerido").toString()); >> } >> Form.setFlag(categoria, flagCat); >> >> if(flagDesc != null || flagVal != null || flagCat != null){ >> return; >> } >> >> ... >> } >> >> >> When I try to submit a form with desc and val (description and value) empty, >> just one flag is presented. Even when I insert data in the "Descrição" >> field, the flag in the field "Descrição" continues to apear. The flag of >> field "Valor" doesn't apear in neigther cases. >> >> >> Any idea? >> >> Cheers, >> Luiz Gustavo S. de Souza >> >> http://luizgustavoss.wordpress.com >> http://luizgustavoss.blogspot.com >> http://twitter.com/lugustso >> <frame1.png><frame2.png> > > > > > -- > Luiz Gustavo S. de Souza > > http://luizgustavoss.wordpress.com > http://luizgustavoss.blogspot.com > http://twitter.com/lugustso
