Results 1 to 6 of 6

Thread: problem with AccordionLayoutContainer

  1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    17

    Default problem with AccordionLayoutContainer

    hi all,
    i'm developing a small app with gxt
    the program is the this:

    http://postimage.org/image/3xssi9gd3/

    like you can see there is three main objects: ContentPanel with 4 textfield, a ContentPanel with a grid that show what you insert in the previus contentpanel and a AccordionLayoutContainer the wraps the 2 contentPanel...

    the problem is the following:
    once the app is running, if my first operation in the insertion of somthings in the textfields, all go well.. but if my fist operation is to open the "griglia risultati" tab and after i insert somthing in the textfields, i get this error:

    Code:
    13:36:44.906 [ERROR] [pprovasencha] Uncaught exception escaped
    
    java.lang.ClassCastException: java.lang.String cannot be cast to com.google.gwt.user.client.EventListener
        at com.google.gwt.user.client.impl.DOMImpl.getEventListener(DOMImpl.java)
        at com.google.gwt.user.client.DOM.getEventListener(DOM.java:804)
        at com.google.gwt.user.cellview.client.CellBasedWidgetImplStandard.handleNonBubblingEvent(CellBasedWidgetImplStandard.java:68)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
        at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
        at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
        at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
        at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
        at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
        at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
        at sun.reflect.GeneratedMethodAccessor158.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
        at java.lang.Thread.run(Thread.java:680)
    it's very strage

    the code is this:

    entrypoint:
    Code:
    publicclass PProvaSencha implements EntryPoint {
        public void onModuleLoad() {
    
            ModelP model = new ModelP();
    
            ViewP view = new ViewP(model);
    
    @SuppressWarnings("unused")
            ControllerP controller = new ControllerP(model, view);
        }
    }
    



    the view:
    Code:
    publicclassViewP {
    
    
    	@SuppressWarnings("unused")
    	private ModelP model;
    	private static final StockProperties props = GWT.create(StockProperties.class);
    	private ColumnConfig<Contact, String> nameConf;
    	private ColumnConfig<Contact, String> surnameConf;
    	private ColumnConfig<Contact, String> numberConf;
    	private ColumnConfig<Contact, String> addressConf;
    	private ListStore<Contact> store;
    	private TextButton button;
    	private TextField nameT;
    	private TextField surnameT;
    	private TextField numberT;
    	private TextField addressT;
    	private FieldLabel nameL;
    	private FieldLabel surnameL;
    	private FieldLabel numberL;
    	private FieldLabel addressL;
    
    
    	public ViewP(ModelP model) {
    		this.model = model;
    
    		//griglia -----------
    		ContentPanel cp1 = new ContentPanel();
    		cp1.setHeadingText("Griglia risultati");
    		cp1.setPixelSize(700, 400);
    		nameConf = new ColumnConfig<Contact, String>(props.name(), 145, "Name");
    		surnameConf = new ColumnConfig<Contact, String>(props.surname(), 175, "Surname");
    		numberConf = new ColumnConfig<Contact, String>(props.number(), 175, "Number");
    		addressConf = new ColumnConfig<Contact, String>(props.address(), 175, "Address");
    
    		List<ColumnConfig<Contact, ?>> l = new ArrayList<ColumnConfig<Contact, ?>>();
    		l.add(nameConf);
    		l.add(surnameConf);
    		l.add(numberConf);
    		l.add(addressConf);
    
    		ColumnModel<Contact> cm = new ColumnModel<Contact>(l);
    
    		store = new ListStore<Contact>(props.key());
    		store.addAll(model.getContacts());
    
    		final Grid<Contact> grid = new Grid<Contact>(store, cm);
    	    grid.getView().setStripeRows(true);
    	    grid.getView().setColumnLines(true);
    	    grid.setBorders(true);
    	    grid.setColumnReordering(true);
    	    grid.setColumnResize(true);
    	    cp1.add(grid);
    	    //--------------
    
    	    ContentPanel cp2 = new ContentPanel();
    	    cp2.setHeadingText("Inserimento");
    	    VerticalPanel vp = new VerticalPanel();
    	    nameT = new TextField();
    	    surnameT = new TextField();
    	    numberT = new TextField();
    	    addressT = new TextField();
    	    nameL = new FieldLabel();     nameL.setText("Name:");
    	    surnameL = new FieldLabel();  surnameL.setText("Surame:");
    	    numberL = new FieldLabel();   numberL.setText("Number:");
    	    addressL = new FieldLabel();  addressL.setText("Address:");
    
    	    vp.add(nameL);
    	    vp.add(nameT);
    	    vp.add(surnameL);
    	    vp.add(surnameT);
    	    vp.add(numberL);
    	    vp.add(numberT);
    	    vp.add(addressL);
    	    vp.add(addressT);
    	    button = new TextButton("submit");
    	    vp.add(button);
    	    cp2.add(vp);
    
    	    AccordionLayoutContainer con = new AccordionLayoutContainer();
    	    //con.setExpandMode(ExpandMode.SINGLE_FILL);
    	    con.add(cp1);
    	    con.add(cp2);
    
    	    RootPanel.get().setStyleName("background");
    		RootPanel.get("grid_container").add(con);
    		//RootPanel.get("insert_container").add(vp);
    	}
    
    	public Contact getTexfieldText() {
    		String name = nameT.getText().toString();
    		String surname = surnameT.getText().toString();
    		String number = numberT.getText().toString();
    		String address = addressT.getText().toString();
    		return new Contact(name, surname, number, address);
    	}
    
    	//per se cambio handler?!?!?
    	public void addButtonHandler(SelectHandler h) {
    		button.addSelectHandler(h); 
    	}
    
    	public void addContactToGrid(Contact c) {
    		store.add(c);
    	}
    
    	public void resetFields() {
    		this.nameT.setText("");
    		this.surnameT.setText("");
    		this.numberT.setText("");
    		this.addressT.setText("");
    	}
    
    }


    the controller:
    Code:
    publicclassControllerP {
    
    
    	private ModelP model;
    	private ViewP view;
    	private Contact actualC;
    
    
    	public ControllerP(ModelP model, ViewP view) {
    		this.model = model;
    		this.view = view;
    
    		view.addButtonHandler(new ButtonHandler());
    	}
    
    	//buttonHandler ----------------------------------------------------------
    	class ButtonHandler implements SelectHandler {
    
    
    		public void onSelect(SelectEvent event) {
    			actualC = view.getTexfieldText();
    			model.addContact(actualC);
    			view.addContactToGrid(actualC);
    			view.resetFields();
    		}
    
    	}
    	//-------------------------------------------------------------------------
    
    
    
    
    }


  2. #2
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109

    Default

    I think you may be missing some code - where is the rest of ViewP, and where are ControllerP, ModelP, the "griglia risultati" tab, etc?

    Also, your stacktrace seems to be missing pieces - is there an earlier stack trace that includes any GXT code at all? And if not, try setting a breakpoint on all JavaScriptExceptions that are thrown, and try to extract the full trace that way.

  3. #3
    Sencha User
    Join Date
    Nov 2012
    Posts
    17

    Default

    i'm sorry but this forum is very strange

    now i modified the post but in the topic now it's disappeared anyway it will come back, you will see the whole code.. thanks a lot!

    however this is the code:
    [CODE]publicclassViewP {


    @SuppressWarnings("unused")
    private ModelP model;
    private static final StockProperties props = GWT.create(StockProperties.class);
    private ColumnConfig<Contact, String> nameConf;
    private ColumnConfig<Contact, String> surnameConf;
    private ColumnConfig<Contact, String> numberConf;
    private ColumnConfig<Contact, String> addressConf;
    private ListStore<Contact> store;
    private TextButton button;
    private TextField nameT;
    private TextField surnameT;
    private TextField numberT;
    private TextField addressT;
    private FieldLabel nameL;
    private FieldLabel surnameL;
    private FieldLabel numberL;
    private FieldLabel addressL;


    public ViewP(ModelP model) {
    this.model = model;

    //griglia -----------
    ContentPanel cp1 = new ContentPanel();
    cp1.setHeadingText("Griglia risultati");
    cp1.setPixelSize(700, 400);
    nameConf = new ColumnConfig<Contact, String>(props.name(), 145, "Name");
    surnameConf = new ColumnConfig<Contact, String>(props.surname(), 175, "Surname");
    numberConf = new ColumnConfig<Contact, String>(props.number(), 175, "Number");
    addressConf = new ColumnConfig<Contact, String>(props.address(), 175, "Address");

    List<ColumnConfig<Contact, ?>> l = new ArrayList<ColumnConfig<Contact, ?>>();
    l.add(nameConf);
    l.add(surnameConf);
    l.add(numberConf);
    l.add(addressConf);

    ColumnModel<Contact> cm = new ColumnModel<Contact>(l);

    store = new ListStore<Contact>(props.key());
    store.addAll(model.getContacts());

    final Grid<Contact> grid = new Grid<Contact>(store, cm);
    grid.getView().setStripeRows(true);
    grid.getView().setColumnLines(true);
    grid.setBorders(true);
    grid.setColumnReordering(true);
    grid.setColumnResize(true);
    cp1.add(grid);
    //--------------

    ContentPanel cp2 = new ContentPanel();
    cp2.setHeadingText("Inserimento");
    VerticalPanel vp = new VerticalPanel();
    nameT = new TextField();
    surnameT = new TextField();
    numberT = new TextField();
    addressT = new TextField();
    nameL = new FieldLabel(); nameL.setText("Name:");
    surnameL = new FieldLabel(); surnameL.setText("Surame:");
    numberL = new FieldLabel(); numberL.setText("Number:");
    addressL = new FieldLabel(); addressL.setText("Address:");

    vp.add(nameL);
    vp.add(nameT);
    vp.add(surnameL);
    vp.add(surnameT);
    vp.add(numberL);
    vp.add(numberT);
    vp.add(addressL);
    vp.add(addressT);
    button = new TextButton("submit");
    vp.add(button);
    cp2.add(vp);

    AccordionLayoutContainer con = new AccordionLayoutContainer();
    //con.setExpandMode(ExpandMode.SINGLE_FILL);
    con.add(cp1);
    con.add(cp2);

    RootPanel.get().setStyleName("background");
    RootPanel.get("grid_container").add(con);
    //RootPanel.get("insert_container").add(vp);
    }

    public Contact getTexfieldText() {
    String name = nameT.getText().toString();
    String surname = surnameT.getText().toString();
    String number = numberT.getText().toString();
    String address = addressT.getText().toString();
    return new Contact(name, surname, number, address);
    }

    //per se cambio handler?!?!?
    public void addButtonHandler(SelectHandler h) {
    button.addSelectHandler(h);
    }

    public void addContactToGrid(Contact c) {
    store.add(c);
    }

    public void resetFields() {
    this.nameT.setText("");
    this.surnameT.setText("");
    this.numberT.setText("");
    this.addressT.setText("");
    }
    }[/CODE]

    controller:

    [CODE]publicclassControllerP {



    private ModelP model;
    private ViewP view;
    private Contact actualC;


    public ControllerP(ModelP model, ViewP view) {
    this.model = model;
    this.view = view;

    view.addButtonHandler(new ButtonHandler());
    }

    //buttonHandler ----------------------------------------------------------
    class ButtonHandler implements SelectHandler {


    public void onSelect(SelectEvent event) {
    actualC = view.getTexfieldText();
    model.addContact(actualC);
    view.addContactToGrid(actualC);
    view.resetFields();
    }

    }
    //-------------------------------------------------------------------------



    }[/CODE]

  4. #4
    Sencha User
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109

    Default

    ModelP is still missing - the example won't compile without it. Same with Contact - though you seem to be using StockProperties as if it works for this Contact class?

    Without ModelP and Contacts, there is no way to add items to the grid, nor can the Grid and ColumnConfig objects even compile. I could just try and assume what Contact looks like what StockProperties (which should be ContactProperties) should look like, etc, but I might unknowingly make your bug go away in doing this.

    Please provide a full, working example, or a full stack trace consistently reproducible in our of our existing examples.

  5. #5
    Sencha User
    Join Date
    Nov 2012
    Posts
    17

    Default

    ok sorry again, the rest of the code is:

    NB: i try the problem a lot of times and the problem is random.. some times give me error, sometimes work fine.. incredible

    Code:
    publicclassContactimplementsIsSerializable{
    Code:
    
    
    
    	private String name;
    	private String surname;
    	private String number;
    	private String address;
    
    
    	@SuppressWarnings("unused")
    	private Contact() {
    
    	}
    
    	public Contact (String name, String surname, String number, String address) {
    		this.name = name;
    		this.surname = surname;
    		this.number = number;
    		this.address = address;
    	}
    
    	public String getName() {
    		return name;
    	}
    	public void setName(String name) {
    		this.name = name;
    	}
    
    	public String getSurname() {
    		return surname;
    	}
    
    	public void setSurname(String surname) {
    		this.surname = surname;
    	}
    
    	public String getNumber() {
    		return number;
    	}
    
    	public void setNumber(String number) {
    		this.number = number;
    	}
    
    	public String getAddress() {
    		return address;
    	}
    
    	public void setAddress(String address) {
    		this.address = address;
    	}
    
    	public static boolean isValidContact(Contact c) {
    		if(c.name.isEmpty() || c.surname.isEmpty() || c.number.isEmpty() || c.address.isEmpty()) {
    			return false;
    		} else {
    			return true;
    		}
    	}
    
    }
    
    
    
    
    class ContactComparator implements Comparator<Contact> {
    
    
    	public int compare(Contact o1, Contact o2) { //-1 se il secondo  maggiore, +1 altrimenti
    
    		if(o1.getSurname().compareTo(o2.getSurname()) < 0) {
    			return -1;
    		} else {
    			return 1;
    		}
    	}
    }



    Code:
    publicclassModelP {
    Code:
    
    
    
    	private ArrayList<Contact> contacts = new ArrayList<Contact>();
    
    
    	ModelP() {
    		contacts.add(new Contact("a", "b", "c", "d"));
    	}
    
    	public void addContact(Contact c) {
    		contacts.add(c);
    	}
    
    	public ArrayList<Contact> getContacts() {
    		return this.contacts;
    	}
    
    	public void removeContact(Contact c) {
    		contacts.remove(c);
    	}
    
    	public void removeAll() {
    		contacts.clear();
    	}
    
    	public int getSize() {
    		return this.contacts.size();
    	}
    
    	public void sort() {
    		Collections.sort(contacts, new ContactComparator());
    	}
    
    
    }
    
    



    Code:
    publicinterfaceStockPropertiesextendsPropertyAccess<Contact> {
    Code:
      @Path("surname")
      ModelKeyProvider<Contact> key();
    
      @Path("name")
    
      ValueProvider<Contact, String> name();
    
      ValueProvider<Contact, String> surname();
    
      ValueProvider<Contact, String> number();
    
      ValueProvider<Contact, String> address();
    
    
    }

  6. #6
    Sencha User
    Join Date
    Nov 2012
    Posts
    17

    Default


    i forget that you have to add this on the html file:

    <div id="grid_container"></div>

    <div id="insert_container"></div>

    and this on the css file:
    .caio {
    color: red;
    font-color: red;
    background: red;
    font-color: red;
    font: red;
    }


    .background {
    background-color: #ccddff;
    }


    /**<!-------------------------------------------->
    <!-- CONTAINERS -->
    <!-------------------------------------------->*/




    #grid_container {
    position: absolute;
    top: 20px;
    left: 50px;
    }


    #insert_container {
    position: absolute;
    top: 40px;
    left: 800px;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •