pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luiz Gustavo <luizgustav...@gmail.com>
Subject Re: Problems with flags
Date Wed, 22 Dec 2010 21:40:42 GMT
If you think it'll help, I can open an issue in Jira.

For my case, I see no problems in showing a flag for the BoxPane (since the
checkbox is an aditional information for the value). But in other cases it
would be really helpful to show a flag in fields that are not directly
nested in Form.Section.


Luiz Gustavo

2010/12/22 Greg Brown <gk_brown@verizon.net>

> Good catch. This is by design - a form can only display flags for direct
> descendants of a section. However, it is confusing, and I have been tripped
> up by the same issue myself a number of times. Probably worth thinking about
> how we might improve this.
>
> On Dec 22, 2010, at 4:25 PM, Luiz Gustavo wrote:
>
> Greg,
>
> I discovered the reason for that problem. That's because the "valor" field
> was not a direct descendant of the Form.Section:
>
> Before (when not showing the flag):
>
> <Form.Section>
>     <TextInput Form.label="%lblDescricao" textSize="40"
> bxml:id="descricao"/>
>
>     <BoxPane styles="{verticalAlignment:'center'}" Form.label="%lblValor">
>        *<TextInput textSize="10" bxml:id="valor" />*
>        <Checkbox buttonData="%lblConciliado" bxml:id="conciliado"
>
> ButtonPressListener.buttonPressed="conciliadoImg.setVisible(conciliado.isSelected());"/>
>        <ImageView bxml:id="conciliadoImg" image="@conciliado.png"
> visible="false"/>
>     </BoxPane>
>     ...
> </Form.Section>
>
>
> When I put the "valor" field as a direct descendant of Form.Section, it
> works:
>
>
> <Form.Section>
>
>      <TextInput Form.label="%lblDescricao" textSize="40"
> bxml:id="descricao"/>
>      *<TextInput textSize="10" bxml:id="valor" />*
>      <BoxPane styles="{verticalAlignment:'center'}"
> Form.label="%lblValor">
>                <Checkbox buttonData="%lblConciliado" bxml:id="conciliado"
>
> ButtonPressListener.buttonPressed="conciliadoImg.setVisible(conciliado.isSelected());"/>
>                <ImageView bxml:id="conciliadoImg" image="@conciliado.png"
> visible="false"/>
>      </BoxPane>
>
>
> Is this a expected behavior or flag shoud work event when not directly
> nested in FormSection?
>
>
> Luiz Gustavo
>
>
>
>
> 2010/12/22 Luiz Gustavo <luizgustavoss@gmail.com>
>
>> Hi Greg,
>>
>> I did the tests and flags are really being instantiated and associated
>> with the fields.
>> As you can see in the images attached, I've debuged the code and for the
>> fields "descricao" and "valor", that were empty, the flags were instantiated
>> and associated.
>> When I resumed the debug, de frame just showed the first flag in the
>> "descricao" field.
>>
>> Luiz Gustavo
>>
>>
>>
>> 2010/12/22 Greg Brown <gk_brown@verizon.net>
>>
>>> I don't see anything obviously lwrong. Can you step through the code (or
>>> add some debug output) to verify that the flag-setting code is actually
>>> being called when you expect it to be?
>>>
>>> On Dec 22, 2010, at 5:26 AM, Luiz Gustavo wrote:
>>>
>>> Hi Greg,
>>>
>>>
>>> These are the fragments involved:
>>>
>>>
>>> bxml
>>> ...
>>> <Form.Section>
>>>
>>>                             <TextInput Form.label="%lblDescricao"
>>> textSize="40" bxml:id="descricao"/>
>>>
>>>                             <BoxPane
>>> styles="{verticalAlignment:'center'}" Form.label="%lblValor">
>>>                                 <TextInput textSize="10" bxml:id="valor"
>>> />
>>>                                 <Checkbox buttonData="%lblConciliado"
>>> bxml:id="conciliado"
>>>
>>> ButtonPressListener.buttonPressed="conciliadoImg.setVisible(conciliado.isSelected());"/>
>>>                                 <ImageView bxml:id="conciliadoImg"
>>> image="@conciliado.png" visible="false"/>
>>>                             </BoxPane>
>>>
>>>                             <CalendarButton bxml:id="data"
>>> Form.label="%lblData"/>
>>>
>>>                             <BoxPane Form.label="%lblTipo"
>>> orientation="horizontal" styles="{padding:4}">
>>>
>>>                                 <bxml:define>
>>>                                     <ButtonGroup bxml:id="tipos"/>
>>>                                 </bxml:define>
>>>                                 <RadioButton bxml:id="despesaButton"
>>> buttonGroup="$tipos" selected="true">
>>>                                     <content:ButtonData
>>> icon="@despesa.png" text="%lblDespesa"/>
>>>                                 </RadioButton>
>>>                                 <RadioButton bxml:id="receitaButton"
>>> buttonGroup="$tipos">
>>>                                     <content:ButtonData
>>> icon="@receita.png" text="%lblReceita"/>
>>>                                 </RadioButton>
>>>
>>>                             </BoxPane>
>>>
>>>                             <ListButton bxml:id="categoria"
>>> Form.label="%lblCategoria" />
>>>
>>>                             <BoxPane Form.label="%lblObservacoes">
>>>                                 <Border styles="{color:10}">
>>>                                     <ScrollPane
>>> horizontalScrollBarPolicy="fill"
>>>
>>> verticalScrollBarPolicy="fill_to_capacity"
>>>                                         preferredHeight="200"
>>> preferredWidth="500">
>>>                                         <TextArea bxml:id="observacoes"/>
>>>                                     </ScrollPane>
>>>                                 </Border>
>>>                             </BoxPane>
>>>
>>>                         </Form.Section>
>>> ...
>>>
>>>
>>> Binding class:
>>>
>>> ...
>>>  Action.getNamedActions().put("salvarAction", new Action() {
>>>       @Override
>>>       public void perform(Component source) {
>>>         if (lancamento == null) {
>>>           salvarNovo();
>>>         }
>>>         else {
>>>           salvarEdicao();
>>>         }
>>>         atualizarGrid();
>>>       }
>>>     });
>>>
>>> ...
>>>
>>>
>>> private void salvarNovo() {
>>>
>>>     try {
>>>
>>>       Form.Flag flagDesc = null;
>>>       Form.Flag flagVal = null;
>>>       Form.Flag flagCat = null;
>>>
>>>       String desc = descricao.getText().trim();
>>>       String val = valor.getText().trim();
>>>
>>>       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;
>>>       }
>>>
>>>       lancamento = new Lancamento();
>>>       lancamento.setDescricao(desc);
>>>       lancamento.setConciliado(conciliado.isSelected());
>>>       lancamento.setData(data.getSelectedDate().toCalendar().getTime());
>>>       lancamento.setObservacao(observacoes.getText());
>>>       lancamento.setValor(new BigDecimal(numberFormat.parse(val)
>>>           .toString()));
>>>       lancamento.setTipoLancamento((CategoriaLancamento) categoria
>>>           .getSelectedItem());
>>>
>>>       daoLancamento.cadastrar(lancamento);
>>>       cancelar();
>>>       Prompt.prompt(MessageType.INFO, resources.get("sucessoCadastro")
>>>           .toString(), this);
>>>     }
>>>     catch (Exception e) {
>>>       Prompt.prompt(MessageType.ERROR, resources.get("falhaCadastro")
>>>           .toString(), this);
>>>     }
>>>
>>>   }
>>>
>>>   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;
>>>       }
>>>
>>>       lancamento.setDescricao(desc);
>>>       lancamento.setConciliado(conciliado.isSelected());
>>>       lancamento.setData(data.getSelectedDate().toCalendar().getTime());
>>>       lancamento.setObservacao(observacoes.getText());
>>>       lancamento.setValor(new BigDecimal(numberFormat.parse(val)
>>>           .toString()));
>>>       lancamento.setTipoLancamento((CategoriaLancamento) categoria
>>>           .getSelectedItem());
>>>
>>>       daoLancamento.alterar(lancamento);
>>>       cancelar();
>>>       Prompt.prompt(MessageType.INFO,
>>>           resources.get("sucessoEdicao").toString(), this);
>>>     }
>>>     catch (Exception e) {
>>>       Prompt.prompt(MessageType.ERROR,
>>> resources.get("falhaEdicao").toString(),
>>>           this);
>>>     }
>>>   }
>>>
>>>
>>> I can't see a reason for flags no work in this scenario. I have another
>>> frame that has just one field validated, and everything's right. Can you see
>>> something wrong?
>>>
>>>
>>> Thank's
>>>
>>> Luiz Gustavo S. de Souza
>>>
>>> http://luizgustavoss.wordpress.com
>>> http://luizgustavoss.blogspot.com
>>> http://twitter.com/lugustso
>>>
>>>
>>> 2010/12/22 Greg Brown <gk_brown@verizon.net>
>>>
>>>> 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 <gk_brown@verizon.net>
>>>>
>>>>> 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 <gk_brown@verizon.net>
>>>>>
>>>>>> 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
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> --
>> 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
> <frame_flag.png>
>
>
>


-- 
Luiz Gustavo S. de Souza

http://luizgustavoss.wordpress.com
http://luizgustavoss.blogspot.com
http://twitter.com/lugustso

Mime
View raw message