Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to create composite widget in SmartGWT

    Hello,

    I want to separate codes in my SmartGWT project so I don't need to have huge chunk of code in the EntryPoint. Anyway in GWT I would just need to create a new class which extends the Composite class, and then I just need to create an instance so i can add it into the RootPanel. However that doesn't work with GWT. So i wonder how it should be done, or what's the best practice for separating codes in SmartGWT? An example code would be helpful.

    After some googling I found an old thread here on this forum with the same question. So I made a try to see if it works. However it doesn't work and I get error. Below is the code which produce the error.
    Code:
    package com.project.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.project.screen.LoginScreen;
    
    public class Project implements EntryPoint {
    
    	public void onModuleLoad() {
    
    	LoginScreen login = new LoginScreen();
    	login.draw();
    
    	}
    }
    Code:
    package com.project.screen;
    
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.HeaderItem;
    import com.smartgwt.client.widgets.form.fields.PasswordItem;
    import com.smartgwt.client.widgets.layout.VLayout;
    
    public class LoginScreen extends VLayout {
    
    	public LoginScreen() {
    
    		DynamicForm form = new DynamicForm();
    		HeaderItem header = new HeaderItem();
    		header.setDefaultValue("Login");
    
    		PasswordItem passwordItem = new PasswordItem();
    		passwordItem.setName("password");
    
    		form.setFields(header, passwordItem);
    		form.setValue("userName", "bsmith");
    		form.setValue("firstName", "Bob");
    		form.setValue("lastName", "Smith");
    		form.setValue("email", "bob@.com");
    		form.setValue("password", "sekrit");
    
    		addMember(form);
    	}
    }
    Last edited by ganmo; 15 Feb 2011, 14:43.

    #2
    Add absolutePanel.add( new LoginScreen() );

    Replace extends VLayout to Composite

    This should basically fix your problem. This is what I'm using in my code so I can easily add and remove classes from the Panel without having to keep all classes in one code.

    Comment


      #3
      Please don't mix GWT and SmartGWT components. What error are you receiving from your example code?

      Comment

      Working...
      X