ClickEvent

hi,
how to use this method:

package foo;

import java.net.URL;

import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Embedded;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Slider;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window.Notification;

@SuppressWarnings(“serial”)
public class NotificationCustomExample extends VerticalLayout implements ClickListener {

	public Button b;
	//private Button b;
    private Label richText;

    private final RichTextArea editor = new RichTextArea();

    public NotificationCustomExample() {
        setSpacing(true);

        richText = new Label(
                "<h1>Rich text example</h1>"
                        + "<p>The <b>quick</b> brown fox jumps <sup>over</sup> the <b>lazy</b> dog.</p>"
                        + "<p>This text can be edited with the <i>Edit</i> -button</p>");
        richText.setContentMode(Label.CONTENT_XHTML);

        addComponent(richText);

        b = new Button("Edit");
        b.addListener(this);
        addComponent(b);

        editor.setWidth("100%");

        
    }

    public void buttonClick(ClickEvent event) {
    	if (getComponentIterator().next() == richText) {
            editor.setValue(richText.getValue());
            replaceComponent(richText, editor);
             b.setCaption("Apply");
           
        } else {
            richText.setValue(editor.getValue());
            replaceComponent(editor, richText);
            b.setCaption("Edit");
        }

 
    }


   }

On first glance, the code should work fine. What exactly is your problem?

I don’t find how to display the changes made ​​at RichTextArea in another component as Label

code:

package foo;

import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.NativeSelect;
import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Slider;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window.Notification;

@SuppressWarnings(“serial”)
public class NotificationCustomExample extends VerticalLayout {

    public Label richText;
    public RichTextArea editor = new RichTextArea();
    public Label n ;
    public NotificationCustomExample() {
        setSpacing(true);
        
        final RichTextArea editor = new RichTextArea();
        
        editor.setWidth("100%");
        editor.setValue("<p>to <i>john.doe@example.com</i></p>");
       	editor.setCaption("Description");
   	    editor.setDescription("Additional information; try to keep it short.");
        addComponent(editor);
        
        
      n = new Label("ccccccc");
        addComponent(n);
    
    Button show = new Button("Show",
            new Button.ClickListener() {
                // "Inline" click listener; this is where the
                // notification is actually created and shown.
                public void buttonClick(ClickEvent event) {
                    // create Notification instance and customize

                   n.setValue(editor.getValue());
                   n.setContentMode(Label.CONTENT_XHTML);
                   //replaceComponent(n, editor);
                   
                   System.out.println( "richTextArea.getValue(): " + editor.getValue() );
                    
                }
            });
  
    addComponent(show);
    setComponentAlignment(show, Alignment.MIDDLE_RIGHT);
    
    }

}

That code seems to work just fine. When I press the button, the text from the RichTextEditor is set to the Label, including formatting.

Can you please try to explain your problem in more detail?

Hi,
if I made ​​a change at RichTextArea in label, I don’t receive this change.
My system is Mac and my browser is Safari

I tested this in mac safari. When I press the show button, the “ccccccc” label changes to “to john.doe@example.com”. Isn’t this the expected behavior?