Check for typos or other problems unrelated to ViewFileItem.
Here's a working test case. To run, use the Admin Console to generate a table for the the mediaLibrary DataSource, run the Smart GWT code, upload a file using the form at the top, reload the page and the bottom form shows the file (since it's the first record, fetchData() grabs it).
mediaLibrary.ds.xml:
Here's a working test case. To run, use the Admin Console to generate a table for the the mediaLibrary DataSource, run the Smart GWT code, upload a file using the form at the top, reload the page and the bottom form shows the file (since it's the first record, fetchData() grabs it).
Code:
final DynamicForm uploadForm = new DynamicForm(); uploadForm.setDataSource(DataSource.get("mediaLibrary")); uploadForm.draw(); IButton saveButton = new IButton("Save"); saveButton.setTop(100); saveButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { uploadForm.saveData(); } }); saveButton.draw(); DynamicForm viewForm = new DynamicForm(); viewForm.setTop(200); viewForm.setDataSource(DataSource.get("mediaLibrary")); ViewFileItem target = new ViewFileItem("image"); target.setAttribute("editorType", "ViewFileItem"); target.setType("imageFile"); viewForm.setItems(target); viewForm.fetchData(); viewForm.draw();
Code:
<DataSource ID="mediaLibrary" serverType="sql"> <fields> <field name="pk" type="sequence" hidden="true" primaryKey="true"/> <field name="title"/> <field name="image" type="imageFile"/> </fields> </DataSource>
Comment