although not much of a big deal, when a user would create a new record/row
in the TableView, all the TextInput which should not be empty will all be
colored red.

I tried doing a simple boolean firstTimeInputFlag trick in the validator but
failed.

Any solution to this? thanks

On Wed, Sep 30, 2009 at 8:43 PM, Todd Volkert <[email protected]> wrote:

> Why not just attach the appropriate validators to your text inputs?  Then,
> when they're invalid, they'll paint themselves to look invalid, which should
> save you the burden of alerting the user as to why the edit is being
> denied.  Then your previewSaveChanges() method becomes a simple deny vs.
> approve decision and gets trimmed down to one line.
>
> -T
>
>
> On Wed, Sep 30, 2009 at 7:19 AM, Vicente de Rivera III <
> [email protected]> wrote:
>
>> I'm using TableViewEditor a lot and I noticed in my code that for all
>> TableViewEditor, I have
>>    tableViewRowEditor.getRowEditorListeners().add(new
>> TableView.RowEditorListener.Adapter() {
>>             private boolean shown = false;
>>             private boolean invalid = false;
>>             @Override
>>             public Vote previewSaveChanges(RowEditor rowEditor, TableView
>> tableView, int rowIndex, int columnIndex, Dictionary<String, Object>
>> changes) {
>>                 invalid = usernameTI.getText().isEmpty() ||
>> passwordTI.getText().isEmpty();
>>                 String errorMsg = (usernameTI.getText().isEmpty() ?
>> "Username" : "") +
>>                                   (passwordTI.getText().isEmpty() ?
>> "Password" : "") +
>>                                   " cannot be empty";
>>                 if (invalid) {
>>                     if (!shown) {
>>                         Prompt.prompt(MessageType.ERROR, errorMsg, null,
>> main.getWindow(),
>>                                 new SheetCloseListener() {
>>
>>                                     public void sheetClosed(Sheet sheet) {
>>                                         shown = false;
>>                                     }
>>                                 });
>>                         shown = true;
>>                     }
>>                     return Vote.DENY;
>>                 }
>>                 return Vote.APPROVE;
>>             }});
>>
>> I'm thinking maybe I could just add validation to TableViewEditor.
>> Something like
>>       tableViewRowEditor.getValidators().add(
>> org.apache.pivot.wtk.text.validation.Validator )
>>
>
>

Reply via email to