minor blur bug

EDIT: replaced all the labels with textfields in the edit window, and now i got a bigger problem, where the logic skips, for which i created a separate thread with a test project attached:

http://vaadin.com/forum/-/message_boards/message/211770

So far this bug is preferable to the other one -_-
EDIT2: The other bug is still not fixed but i found a solution, that is not using clickable layout.

I have a bunch of labels that get replaced by textfields in the purpose of seeming editable, in response to layout click, and when the textfields lose focus, they are replaced with the label back again. The problem is the blur event doesn’t always make it or something, and a textfield remains in place although it has lost focus; I know, i can make them textfields from the start, but i only managed to make them look like that so i haven’t had the time, though they should work like this too.

/**
		 * Creates the input fields over the number labels
		 */
		private class EditNumberLayoutClickListener implements
				LayoutClickListener {

			@Override
			public void layoutClick(LayoutClickEvent event) {
				if (event.getChildComponent() instanceof Label) {
					Label thisLabel = (Label) event.getChildComponent();
					new NrLabelEdit(thisLabel, editNumberLabelsHLayout);
				}
private class NrLabelEdit {

			TextField edit;
			Label editedLabel;
			HorizontalLayout editNumberLabelsHLayout;

			public NrLabelEdit(Label label, HorizontalLayout layout) {
				editedLabel = label;
				editNumberLabelsHLayout = layout;
				edit = new TextField();
				edit.setImmediate(true);
				edit.setStyleName("nr");
				edit.setMaxLength(2);
				edit.setValue(((String) editedLabel.getValue()).substring(
						((String) editedLabel.getValue()).indexOf(">") + 1,
						((String) editedLabel.getValue()).indexOf("</")));
				edit.addValidator(new RegexpValidator("[1-9]
[0-9]
?", null));
				edit.addListener(new ValueChangeListener() {

					@Override
					public void valueChange(ValueChangeEvent event) {
						if (edit.isValid()) {
							byte value = Byte.parseByte((String) edit
									.getValue());
							if (value < 50 && value > 0) {
								for (byte b : nrs)
									if (value == b) {
										editNumberLabelsHLayout
												.replaceComponent(edit,
														editedLabel);
										destroy();
										return;
									}
								editedLabel.setValue(START_LABEL_H3 + value
										+ END_LABEL_H3);
							}
						}
						editNumberLabelsHLayout.replaceComponent(edit,
								editedLabel);
//						destroy();
					}
				});
				edit.addListener(new FieldEvents.BlurListener() {

					@Override
					public void blur(BlurEvent event) {
						editNumberLabelsHLayout.replaceComponent(edit,
								editedLabel);
//						destroy();
					}
				});
				editNumberLabelsHLayout.replaceComponent(editedLabel, edit);
				edit.focus();
			}

			private void destroy() {
				editedLabel = null;
				edit = null;
				editNumberLabelsHLayout = null;
			}

		}

There can’t be two textfields active at any one time.
I achieved this by clicking fast on the labels back and forth (my old trick for confusing the UI :grin: , this time seems to be for real )
11404.png
11405.png

EDIT: Bug replication metion: when clicking back and forth in this sequence fast enough: 1st 2nd, 1st 2nd. It helps trying it on a slower browser, such as IE :grin:
Note:
-you have to rename in the Web Project field in Eclipse when importing war.
–also perform a clean build with your Vaadin jar.

I believe also this is somehow linked with the framework.
I created a test war that i attached to this thread for importing the test project into eclipse. All you need to do is import the war and add the Vaadin jar to the build path.

First problem is the textfield who loses the blur event.
Another problem with this, is that it sends two requests instead of one when clicking over any label in the subwindow.

To replicate the bug, you must click over the balls in the subwindow randomly left and right, then at some point, one will remain a textfield, instead of beeing replaced by a label (in each textfield’s blur event i add that it should get replaced by a label, and each textfield appearing is part of a separate object that does this, then gets destroyed).

In the below picture, there’s three initial clicks, and 6 requests.
11414.war (23.7 KB)
11415.png