Nice!
On Mar 7, 2011, at 4:57 PM, anton dos santos wrote:
> I have done it this way:
>
> public class ValidationRowEditor extends TableViewRowEditor {
>
> @Override
> public void endEdit(boolean result) {
> boolean valid = true;
> if (result) {
> Dictionary<String, Component> editors = getCellEditors();
> Sequence<Column> cols = getTableView().getColumns();
> for (int i = 0, n = cols.getLength(); i < n; i++) {
> Component comp = editors.get(cols.get(i).getName());
> if (comp instanceof TextInput) {
> valid &= ((TextInput) comp).isTextValid();
> }
> }
> }
> if (!(result && !valid)) {
> super.endEdit(result);
> }
> }
> }
>
> if one of the TextInput editors is not valid, user can only leave the editor
> by pressing ESC.
> It seems to work also with mouse, so it may also solve Lello's issues (
> haven't tested completely)
>
> On 07/03/2011 22:11, Greg Brown wrote:
>> Sorry - I haven't looked at this code in a while. You should just be able to
>> override endEdit() and perform your validation. Don't call the base
>> endEdit() if validation fails.
>>
>> On Mar 7, 2011, at 4:06 PM, anton dos santos wrote:
>>
>>> Ok
>>> but how can my app (my validators) tell the TableViewRowEditor that it
>>> should not store the row?
>>> it happens in TableViewRowEditor#endEdit(boolean result) which is invoked
>>> by keyPressed().
>>> So I should override keyPressed() and check the status of all validators
>>> before invoking endEdit() ?
>>>
>>> On 07/03/2011 21:41, Greg Brown wrote:
>>>> That's true, but it is up to your app to decide what constitutes "valid".
>>>>
>>>> On Mar 7, 2011, at 3:36 PM, anton dos santos wrote:
>>>>
>>>>> when a value is not valid you can still press return and then editing
>>>>> ends and store() is also called.
>>>>> So modifying the MouseListener will not be enough.
>>>>> I believe that store() should not be invoked when there is a non valid
>>>>> value in the row
>>>>>
>>>>>
>>>>> On 07/03/2011 21:04, lello wrote:
>>>>>> The problem I am facing is that when you have any value which is not
>>>>>> valid
>>>>>> you can still select a row of the table with the mouse and trigger a
>>>>>> store()
>>>>>> method. This shouldn't be allowed whether or not strictValidation() is
>>>>>> true
>>>>>> or false, since it returns an exception in any case. I should overwrite
>>>>>> some
>>>>>> MouseListener in my custom TableRowEditor, but I can't find any.
>>>>>> Any suggestion?
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://apache-pivot-users.399431.n3.nabble.com/TextInput-and-Validator-issues-tp2641141p2647704.html
>>>>>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>
>>
>>
>