No, flags definitely don't appear one at a time - you should be able to flag
all the fields in your form if you want to. The message won't appear until you
hover over the field, but it should be outlined, and you should see the error
icon.
There must be some other issue - not sure what it might be.
On Dec 21, 2010, at 10:14 PM, Luiz Gustavo wrote:
> When the user enter some text in the field, it desapears, because flag is set
> to null in the begining of the salvarEdicao method:
>
> Form.Flag flagDesc = null;
>
> ...
>
> if(desc == null || "".equals(desc.trim())){
> flagDesc = new Form.Flag(MessageType.ERROR,
> resources.get("campoRequerido").toString());
> }
> Form.setFlag(descricao, flagDesc);
>
>
> So in the case of desc != null, I clean the flag. The problem is that the
> flag for the second field (Valor) never apears. Initially i thought that
> flags apeared one per time (not all at the same time), but even when the
> first field is ok, the flag of the second doesn't apear.
>
> Any idea?
>
>
>
> 2010/12/22 Greg Brown <[email protected]>
> 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
>
>
>
>
> --
> Luiz Gustavo S. de Souza
>
> http://luizgustavoss.wordpress.com
> http://luizgustavoss.blogspot.com
> http://twitter.com/lugustso