You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Shahzad Bhatti <sb...@peak6.com> on 2010/03/26 23:02:21 UTC

Displaying multiple form errors

I am trying to build a form with multiple fields and would like to show all errors when form validation fails. From looking at samples, it looks like we can only have one Form.Flag per box pane such as following snippet from Forms.java

        submitButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                String lastName = lastNameTextInput.getText();
                String firstName = firstNameTextInput.getText();

                Form.Flag flag = null;
                if (lastName.length() == 0
                    || firstName.length() == 0) {
                    flag = new Form.Flag(MessageType.ERROR, "Name is required.");
                }

                Form.setFlag(nameBoxPane, flag);

                if (flag == null) {
                    errorLabel.setText(null);
                    Prompt.prompt("Pretending to submit...", window);
                } else {
                    errorLabel.setText("Some required information is missing.");
                }
            }
        });

 Is it possible to show error messages next to each field when form validation fails. I would appreciate for any examples. Thanks.

______________________________________________

See  http://www.peak6.com/email_disclaimer.php
for terms and conditions related to this email

Re: Displaying multiple form errors

Posted by Greg Brown <gk...@mac.com>.
> Thanks, this looks pretty nice. I think I might be able to provide some feedback using listeners, but it would be nice to see support errors per field in future release to reduce boiler plate code.


This is potentially doable if we add an orientation property to the Form class. That way, you could nest forms inside of other forms and get the highlight behavior on nested fields. You are welcome to file a feature request in JIRA for this if you like - I'd suggest submitting it for v 2.0.

G




Re: Displaying multiple form errors

Posted by Shahzad Bhatti <sb...@peak6.com>.
Thanks, this looks pretty nice. I think I might be able to provide some feedback using listeners, but it would be nice to see support errors per field in future release to reduce boiler plate code.


On 3/26/10 3:19 PM, "Greg Brown" <gk...@mac.com> wrote:

FWIW, the look and feel of the Form class has been significantly improved for Pivot 1.5. Flag messages now appear in a color coded popup that is more strongly visually associated with the flagged field:

http://ixnay.biz/form.png

Messages can also be displayed inline such that they are always visible (i.e. they don't only appear on mouse over). Additionally, the flag icons are now more consistent with their Alert/Prompt equivalents.

G

On Mar 26, 2010, at 6:09 PM, Greg Brown wrote:

> This is unfortunately not supported. The Form container supports one flag per field (where fields are defined by the form's sections). Form has no way of knowing that you have multiple text inputs inside the box pane, so it can't attach a flag to those text inputs. It can only show a flag for the fields it knows about.
>
>
> On Mar 26, 2010, at 6:02 PM, Shahzad Bhatti wrote:
>
>> I am trying to build a form with multiple fields and would like to show all errors when form validation fails. From looking at samples, it looks like we can only have one Form.Flag per box pane such as following snippet from Forms.java
>>
>>       submitButton.getButtonPressListeners().add(new ButtonPressListener() {
>>           @Override
>>           public void buttonPressed(Button button) {
>>               String lastName = lastNameTextInput.getText();
>>               String firstName = firstNameTextInput.getText();
>>
>>               Form.Flag flag = null;
>>               if (lastName.length() == 0
>>                   || firstName.length() == 0) {
>>                   flag = new Form.Flag(MessageType.ERROR, "Name is required.");
>>               }
>>
>>               Form.setFlag(nameBoxPane, flag);
>>
>>               if (flag == null) {
>>                   errorLabel.setText(null);
>>                   Prompt.prompt("Pretending to submit...", window);
>>               } else {
>>                   errorLabel.setText("Some required information is missing.");
>>               }
>>           }
>>       });
>>
>> Is it possible to show error messages next to each field when form validation fails. I would appreciate for any examples. Thanks.
>>
>> ______________________________________________
>>
>> See  http://www.peak6.com/email_disclaimer.php
>> for terms and conditions related to this email
>



Re: Displaying multiple form errors

Posted by Greg Brown <gk...@mac.com>.
FWIW, the look and feel of the Form class has been significantly improved for Pivot 1.5. Flag messages now appear in a color coded popup that is more strongly visually associated with the flagged field:

http://ixnay.biz/form.png

Messages can also be displayed inline such that they are always visible (i.e. they don't only appear on mouse over). Additionally, the flag icons are now more consistent with their Alert/Prompt equivalents.

G

On Mar 26, 2010, at 6:09 PM, Greg Brown wrote:

> This is unfortunately not supported. The Form container supports one flag per field (where fields are defined by the form's sections). Form has no way of knowing that you have multiple text inputs inside the box pane, so it can't attach a flag to those text inputs. It can only show a flag for the fields it knows about.
> 
> 
> On Mar 26, 2010, at 6:02 PM, Shahzad Bhatti wrote:
> 
>> I am trying to build a form with multiple fields and would like to show all errors when form validation fails. From looking at samples, it looks like we can only have one Form.Flag per box pane such as following snippet from Forms.java
>> 
>>       submitButton.getButtonPressListeners().add(new ButtonPressListener() {
>>           @Override
>>           public void buttonPressed(Button button) {
>>               String lastName = lastNameTextInput.getText();
>>               String firstName = firstNameTextInput.getText();
>> 
>>               Form.Flag flag = null;
>>               if (lastName.length() == 0
>>                   || firstName.length() == 0) {
>>                   flag = new Form.Flag(MessageType.ERROR, "Name is required.");
>>               }
>> 
>>               Form.setFlag(nameBoxPane, flag);
>> 
>>               if (flag == null) {
>>                   errorLabel.setText(null);
>>                   Prompt.prompt("Pretending to submit...", window);
>>               } else {
>>                   errorLabel.setText("Some required information is missing.");
>>               }
>>           }
>>       });
>> 
>> Is it possible to show error messages next to each field when form validation fails. I would appreciate for any examples. Thanks.
>> 
>> ______________________________________________
>> 
>> See  http://www.peak6.com/email_disclaimer.php
>> for terms and conditions related to this email
> 


Re: Displaying multiple form errors

Posted by Greg Brown <gk...@mac.com>.
This is unfortunately not supported. The Form container supports one flag per field (where fields are defined by the form's sections). Form has no way of knowing that you have multiple text inputs inside the box pane, so it can't attach a flag to those text inputs. It can only show a flag for the fields it knows about.


On Mar 26, 2010, at 6:02 PM, Shahzad Bhatti wrote:

> I am trying to build a form with multiple fields and would like to show all errors when form validation fails. From looking at samples, it looks like we can only have one Form.Flag per box pane such as following snippet from Forms.java
> 
>        submitButton.getButtonPressListeners().add(new ButtonPressListener() {
>            @Override
>            public void buttonPressed(Button button) {
>                String lastName = lastNameTextInput.getText();
>                String firstName = firstNameTextInput.getText();
> 
>                Form.Flag flag = null;
>                if (lastName.length() == 0
>                    || firstName.length() == 0) {
>                    flag = new Form.Flag(MessageType.ERROR, "Name is required.");
>                }
> 
>                Form.setFlag(nameBoxPane, flag);
> 
>                if (flag == null) {
>                    errorLabel.setText(null);
>                    Prompt.prompt("Pretending to submit...", window);
>                } else {
>                    errorLabel.setText("Some required information is missing.");
>                }
>            }
>        });
> 
> Is it possible to show error messages next to each field when form validation fails. I would appreciate for any examples. Thanks.
> 
> ______________________________________________
> 
> See  http://www.peak6.com/email_disclaimer.php
> for terms and conditions related to this email