Announcement

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

  • CanvasItem not storing values

    Good Afternoon, I've a problem with a big form to whom i added a canvasItem in SmartGWT. The canvas item works except for the save. When i save the DynamicForm it is set in the values stored in the textItem and in the comboItem inside the canvas is totally lost. I've been through the documentation of smartGWT and i found out that the canvasItem never get saved if you don't add to it the method `setShouldSaveValue`. But I've added the method and the debug code `getValues` from the parent form doesn't show the data stored in the canvas. So i've added the `storeValue` method and now I'm getting the following error:

    Caused by: com.google.gwt.core.client.JavaScriptException: (TypeError): self.storeValue is not a function

    The code of the form is the following:

    TextItem galleryIdItem = new TextItem();
    galleryIdItem.setTitle(Nove.getInstance().getConstants().galleryId());
    galleryIdItem.setName(UserDS.ATTR_GALLERY_ID);
    galleryIdItem.setRequired(false);
    galleryIdItem.setWidth(400);
    galleryIdItem.setAlign(Alignment.LEFT);
    galleryIdItem.setOptionDataSource(UserDS.getInstance());

    SelectItem companyCombo = new SelectItem();
    companyCombo.setTitle(Nove.getInstance().getConstants().aziendaGallery());
    companyCombo.setName(UserDS.ATTR_COMPANY_CODE);
    companyCombo.setOptionDataSource(ClienteGalleryDS.getInstance());
    companyCombo.setDisplayField(ClienteGalleryDS.LONGNAME);
    companyCombo.setValueField(ClienteGalleryDS.RCT_CODE);
    companyCombo.setWidth(400);
    companyCombo.setAlign(Alignment.LEFT);
    companyCombo.setRequired(true);
    galleryForm.setFields(galleryIdItem,companyCombo);
    galleryCanvas = new CanvasItem();
    galleryCanvas.setColSpan(2);
    galleryCanvas.setCanvas(galleryForm);
    galleryCanvas.setShowTitle(false);
    galleryCanvas.setShouldSaveValue(true);
    galleryCanvas.storeValue(galleryForm);

    // Set field to render in DynamicForm
    this.setFields(lastNameItem, firstNameItem, loginItem, emailItem, matricolaItem, statoCombo, noveUser, smsUser, noveCanvas, smsCanvas, galleryCanvas, sogettoVal, ufficioVal, livelloVal, userTypeVal, clienteVal);


    I've tried even to do something like this

    galleryCanvas.storeValue(galleryIdItem);
    galleryCanvas.storeValue(companyCombo);

    but it throws always the same error.

    Any idea of why am I getting this error and how to solve it?

  • #2
    See docs: storeValue() is called to store a value entered by an end user. It would never make sense to call it in the midst of creating the form before the user has interacted with it. If you are trying to establish a default value, use setDefaultValue(), or for an initial value, use form.setValues() or related APIs. For more help, take a look at the CanvasItem documentation, which also links to working samples.

    Comment

    Working...
    X