Hello,
I created a widget that uses a DynamicForm with an UploadItem and a TileGrid that is data bound. The TileGrid displays binary images that are uploaded . Unfortunately, when I add a new image, the returned data is missing the binary field (which is a Base64 image). I've tried refetching the data after adding an image on the server side but that also did not include the binary field.
Here is my code:
Dynamic form:
A Button is added to handle the upload by calling "imageForm.saveData()"
TileGrid:
Datasource field
I created a widget that uses a DynamicForm with an UploadItem and a TileGrid that is data bound. The TileGrid displays binary images that are uploaded . Unfortunately, when I add a new image, the returned data is missing the binary field (which is a Base64 image). I've tried refetching the data after adding an image on the server side but that also did not include the binary field.
Here is my code:
Dynamic form:
Code:
final DynamicForm imageForm = new DynamicForm(); imageForm.setDataSource(DATASOURCE); imageForm.setSaveOperationType(DSOperationType.ADD); uploadItem = new UploadItem("image"); uploadItem.setColSpan(2); uploadItem.setWrapTitle(false); uploadItem.setAccept(".jpg,.png,.jpeg"); uploadItem.setMultiple(false); imageForm.setFields(uploadItem);
TileGrid:
Code:
tileGrid = new TileGrid(); tileGrid.setTileWidth(200); tileGrid.setWidth100(); tileGrid.setHeight100(); tileGrid.setSelectionType(SelectionStyle.SINGLE); tileGrid.setDataSource(ds); tileGrid.setCanReorderTiles(true); tileGrid.setShowAllRecords(true); tileGrid.setAutoFetchData(true); tileGrid.setAnimateTileChange(true); tileGrid.setHoverWrap(true); tileGrid.setShowHover(true); final DetailViewerField imageField = new DetailViewerField("image); imageField.setType("image"); imageField.setDetailFormatter((o, record, detailViewerField) -> { final String url = "data:" + record.getAttribute(MIME_TYPE) + ";base64," + o; detailViewerField.setImageSize(new Img(url).getSize()); return url; }); tileGrid.setFields(imageField, new DetailViewerField(NAME), new DetailViewerField(TYPE_ID)); tileGrid.addRecordClickHandler(event -> ds.viewFile(event.getRecord())); final SimpleTile tileProps = new SimpleTile(); tileProps.setCanHover(true); tileProps.setHoverWrap(true); tileProps.setShowHoverComponents(true); tileProps.addHoverHandler(event -> { Hover.hide(); Hover.show(tileGrid.getTileRecord(event.getFiringCanvas()).getAttribute(DESCRIPTION), new Label()); }); tileGrid.setCanHover(true); tileGrid.setHoverWrap(true); tileGrid.setShowHoverComponents(true); tileGrid.setTileProperties(tileProps); tileGrid.fetchData(CRITERIA);
Code:
<field name="image" type="binary" encodeInResponse="true"/>
Comment