Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 289849

Summary: Validator message not shown on ValidationTime.ON_UPDATE_TO_MODEL
Product: [RT] Riena Reporter: Ralf Stuckert <ralf.stuckert>
Component: UIAssignee: Sabine Achilles <achilles.sabine>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 1.2.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:

Description Ralf Stuckert CLA 2009-09-18 09:00:56 EDT
The message of a validator (e.g. MaxLength) is not shown if ValidationTime ON_UPDATE_TO_MODEL is used.
If you use ON_UI_CONTROL_EDIT the message is shown.
A validation message added to the ridget is displayed in both modes!
Comment 1 Elias Volanakis CLA 2009-09-18 14:28:53 EDT
Hi Ralf,

can you provide a snippet (standalone or in a comment) ?

If your validation message is tied to a rule, it will only appear when that rule is validated. This may explain the above, but I would like to see a snippet to be sure.

Kind regards,
Elias.
Comment 2 Ralf Stuckert CLA 2009-09-21 06:01:10 EDT
The problem seems to be specific to blocking validators like e.g. MaxLength in conjunction with ValidationTime.ON_UPDATE_TO_MODEL. 

Try the following snippet. Enter >5 characters to both Text fields. They both have 5 character max length validator. The difference is, that the second field is using a "non-blocking" validator. Field two gets marked, field one doesn't. Can you reproduce that?


package org.eclipse.riena.sample.snippets;

import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.layout.GridLayoutFactory;
import org.eclipse.riena.ui.core.marker.ValidationTime;
import org.eclipse.riena.ui.ridgets.ITextRidget;
import org.eclipse.riena.ui.ridgets.marker.TooltipMessageMarkerViewer;
import org.eclipse.riena.ui.ridgets.swt.SwtRidgetFactory;
import org.eclipse.riena.ui.ridgets.validation.MaxLength;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

import rst.riena.sample.beans.TextBean;

public final class BlockingValidatorProblem {

	public static void main(String[] args) {
		Display display = Display.getDefault();
		try {
			Shell shell = new Shell();
			GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).spacing(20, 10).applyTo(shell);

			Text text = new Text(shell, SWT.BORDER);
			GridDataFactory.fillDefaults().grab(true, false).applyTo(text);
			ITextRidget textRidget = (ITextRidget) SwtRidgetFactory.createRidget(text);
			textRidget.addValidationRule(new MaxLength(5), ValidationTime.ON_UPDATE_TO_MODEL);
			textRidget.bindToModel(new TextBean(), "text");
			
			Text text2 = new Text(shell, SWT.BORDER);
			GridDataFactory.fillDefaults().grab(true, false).applyTo(text2);
			ITextRidget textRidget2 = (ITextRidget) SwtRidgetFactory.createRidget(text2);
			textRidget2.addValidationRule(new NonBlockingMaxLength(5), ValidationTime.ON_UPDATE_TO_MODEL);
			textRidget2.bindToModel(new TextBean(), "text");

			TooltipMessageMarkerViewer tooltipMessageMarkerView = new TooltipMessageMarkerViewer();
			tooltipMessageMarkerView.addRidget(textRidget);
			tooltipMessageMarkerView.addRidget(textRidget2);
			
			shell.setSize(200, 200);
			shell.open();
			while (!shell.isDisposed()) {
				if (!display.readAndDispatch()) {
					display.sleep();
				}
			}
		} finally {
			display.dispose();
		}
	}

}

class NonBlockingMaxLength extends MaxLength {
	public NonBlockingMaxLength(int length) {
		super(length, false);
	}
}
Comment 3 Sabine Achilles CLA 2009-11-10 06:06:40 EST
This bug was fixed with report 289458 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=289458). Both TextFields in the snippet show an ErrorMarker now.
Comment 4 Elias Volanakis CLA 2009-11-10 13:29:43 EST
Duplicate of resolved Bug.

*** This bug has been marked as a duplicate of bug 289458 ***