Search code examples
javaeclipsevaadinvaadin7

VaadIn Visual Designer - panel issue


I created an VaadIn Design with the Visual Designerfrom Vaadin Labs

Its basic an login panel

<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8" name="design-properties" content="{&quot;RULERS_VISIBLE&quot;:true,&quot;GUIDELINES_VISIBLE&quot;:false,&quot;SNAP_TO_OBJECTS&quot;:true,&quot;SNAP_TO_GRID&quot;:true,&quot;SNAPPING_DISTANCE&quot;:10.0,&quot;PAPER_WIDTH&quot;:1440,&quot;PAPER_HEIGHT&quot;:900,&quot;JAVA_SOURCES_ROOT&quot;:&quot;src&quot;,&quot;THEME&quot;:&quot;sws_7_2&quot;}">
 </head> 
 <body> 
  <v-panel caption="Login" width="40%" height="40%" _id="login"> 
   <v-vertical-layout spacing="true" size-full="true" margin=""> 
    <v-horizontal-layout spacing="true" width-full="true"> 
     <v-label size-auto="true" plain-text="" :middle="" :right="" _id="lblLoginName">
       Login naam : 
     </v-label> 
     <v-text-field :middle="" _id="txtLoginName"></v-text-field> 
    </v-horizontal-layout> 
    <v-horizontal-layout spacing="true" width-full="true"> 
     <v-label size-auto="true" plain-text="" :middle="" :right="" _id="lblPassword">
       Paswoord : 
     </v-label> 
     <v-text-field :middle="" _id="txtPassword"></v-text-field> 
    </v-horizontal-layout> 
    <v-horizontal-layout spacing="true" width-full="true"> 
     <v-button plain-text="" :middle="" :right="" _id="btnLogin">
       Login 
     </v-button> 
     <v-button plain-text="" :middle="" _id="btnCancel">
       Annuleren 
     </v-button> 
    </v-horizontal-layout> 
    <v-horizontal-layout spacing="true" width-full="true"> 
     <v-button plain-text="" :middle="" :center="" _id="btnLoginPasswordForgotten">
       Login / paswoord vergeten? 
     </v-button> 
    </v-horizontal-layout> 
    <v-horizontal-layout width-full="true"> 
     <v-label width="6px" plain-text="" :middle="" :center="" _id="lblError"></v-label> 
    </v-horizontal-layout> 
   </v-vertical-layout> 
  </v-panel>  
 </body>
</html>

When I call the loginscreen (code below) I see it but I can't do anything with it. The ClickListner isn't working, I can't even change a label value or something ...

public class Login extends LoginDesign implements Button.ClickListener {
private static final long serialVersionUID = 1L;
private UI mainUI;
private ClickListener listner = this;

public Panel createLoginPanel(UI mainUI) {
    this.mainUI = mainUI;
    LoginDesign login = new LoginDesign();
    btnLogin.addClickListener(listner);
    lblError.setValue("Problem");
    System.out.println(lblError.getValue());
    return login;
}....

I see the changed value of the lblError in the console, but not on the screen ... ?

Normally you create your buttons and you add the caption and the listener. Here I need to add the listener seperatly ... ?!

I'm doing something wrong ... any suggestions!. Thx!


Solution

  • Solved it.

    I took an instance of the generated file but you need to use the extended class .. .

    public class Login extends LoginDesign implements Button.ClickListener {
    private static final long serialVersionUID = 1L;
    
    private UI mainUI;
    
    private ClickListener listner = this;
    
    public Panel createLoginPanel(UI mainUI) {
        this.mainUI = mainUI;
        Login login = new Login();
        btnLogin.addClickListener(listner);
        lblError.setValue("Problem");
        System.out.println(lblError.getValue());
        return login;
    }....
    

    Solved it