How to force a Value change on a Vaadin RichTextArea component

675 Views Asked by At

I have developed a custom component consist of a layout and two labels within it. This layout is draggable. The code is similar to this :

DragAndDropWrapper boxWrap= new DragAndDropWrapper(layout);
mainLayout.addComponent(boxWrap);

After that I have a RichTextArea that allows the layout to be dropped in it. With this code.

RichTextArea richText= new RichTextArea;
DragAndDropWrapper dndWrapper = new DragAndDropWrapper(richText);
dndWrapper.setDropHandler(new DropHandler()  {
        public void drop(DragAndDropEvent event)  {
            //Do whatever you want when something is dropped                
        }
        //Criterio de aceptacion
        public AcceptCriterion getAcceptCriterion() {   
            return AcceptAll.get();
        }
    });

The code works fine. But when I drop the layout within the RichTextArea y want to get the Text written in this area and add some text but the method richText.getValue() is not updated unless I change the focus to another component or tab out. I guess there is not being communication with the server side so the value is not updated. Is there any way to force a a focus change when mousedown on the layout? I tried with JavaScript but i dont know how to add a onmousedown="function()" attribute to the layout component. I also tried extending RichTextArea and implementing the MouseListener or something or a TextChangeListener, but nothing works.

Any clue? Thank you.

PS: The component cannot be different from a RichTextArea.

1

There are 1 best solutions below

1
luuksen On

Have you set richText.setImmediate(true); ?