Announcement

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

    ViewFileItem

    Are there any examples on how to use ViewFileItem ?

    Thanks a lot,
    Stonebranch

    #2
    Hi Stonebranch,

    There isn't a specific example for this item, however, if you are using one of the binary fieldTypes in your DataSource, you should see that DynamicForms simply use this item automatically. Did you have a question about using it?

    Comment


      #3
      Hi Isomorphic,

      Our requirement is to display logo image in the form.

      Logo is saved as a BLOB in mysql database.
      Our datasource has Logo as a binary field.
      <field name="logo" type="binary" title="Logo" required="false" />

      We get the input stream and pass it to dsResponse.setData()

      We`ve tried displaying logo by using ViewFileItem , but all we can see is an Input box with [object Object] text in it .

      What are we missing ?

      Thanks a lot for your help ,
      Stonebranch

      Comment


        #4
        To tell SmartClient that the binary field contains image data, use type "imageFile" in the DataSource field definition. This should trigger the ViewFileItem if the field is also marked not editable (canEdit:false). Otherwise, you'd see an UploadItem.

        Placing an InputStream in the response data is correct, but don't do it for a normal fetch. Instead, when the ViewFileItem is displayed in the form (or, in a grid, when someone clicks on the "view" icon), you'll see a special DataSource operation with type "viewFile" - for this operationType and the related "downloadFile" operationType, add an InputStream to the response data.

        Comment


          #5
          By the way, is this a SQLDataSource or your own code? With SQLDataSource this is all automatic (no need to add special code for viewFile/downloadFile operationType).

          Comment


            #6
            Noticed you deleted your post just as we were about to reply that the DMI declaration looked correct and should not cause that error - were you able to make it work via DMI or did you take another approach?

            Comment


              #7
              Yes we were able to get it to work with DMI .
              Now we have another problem. View and Download icons show up even though showFileInline is set to "true" on the ViewFileItem ( datasource field is also set to true).

              Thanks,
              Stonebranch

              p.s.I`ve tested it with the list grid , and showFileInline ="true" works fine.

              Comment


                #8
                Check that the type of the field in the DataSource is "imageFile". If you are explicitly adding a setting to use ViewFileItem, make sure you're using "editorType" and not the "type" attribute. If that doesn't clear it up, please show both the DataSource and form definition.

                Comment


                  #9
                  Here we go ...
                  DynamicForm
                  private DynamicForm createDynamicForm() {
                  dynamicForm.setAutoFetchData(true);
                  dynamicForm.setAutoFocus(true);
                  dynamicForm.setDataSource(dropboxDataSource);
                  dynamicForm.setWrapItemTitles(false);
                  final ViewFileItem logoItem = new ViewFileItem();
                  logoItem.setShowFileInline(true);
                  logoItem.setName(DropboxDS.LOGO);
                  logoItem.setTitle(DropboxDS.LOGO);

                  dynamicForm.setItems(logoItem);
                  ....

                  DataSource - logo field definition

                  private DataSourceImageFileField createLogoField() {
                  final DataSourceImageFileField logoField = new DataSourceImageFileField(LOGO, "Logo");
                  logoField.setEditorType(new ViewFileItem());
                  logoField.setShowFileInline(true);
                  logoField.setCanEdit(false);
                  return logoField;
                  }

                  Please let us know if you need more info.

                  Thanks,
                  Stonebranch

                  Comment


                    #10
                    What is the createLogoField() function doing there - this would be a server-side DataSource so code like that does not (and should not!) be written. Server-side DataSources are loaded via the DataSourceLoader servlet as shown in all EE samples.

                    Can you show the DataSource definition (.ds.xml file) and indicate your SmartGWT and GWT versions. Also, is this reproducible on multiple browsers?

                    Comment


                      #11
                      We have the same issue when datasource is loaded via the DataSourceLoader .

                      Here is DataSource definition
                      <DataSource ID="dropboxDMI" serverType="generic">
                      <fields>
                      <field name="id" type="string" hidden="true" primaryKey="true" />
                      <field name="name" type="string" title="Name" length="128" required="true" />
                      <field name="logo" type="imageFile" title="Logo" required="false" showFileInline="true"/>
                      <field name="logoPosition" type="string" title="Logo Position" length="32" required="false" />

                      <field name="createdByName" type="text" title="Created By" detail="true" />
                      <field name="createdDate" type="datetime" title="Created Date" detail="true" />
                      <field name="modifiedByName" type="text" title="Modified By" detail="true" />
                      <field name="modifiedDate" type="datetime" title="Modified Date" detail="true" />
                      </fields>

                      <serverObject lookupStyle="spring" bean="dropboxDS" />
                      <operationBindings>
                      <binding operationType="viewFile" serverMethod="viewFile">
                      <serverObject lookupStyle="spring" bean="dropboxDS"/>
                      </binding>
                      </operationBindings>
                      </DataSource>

                      We are using SmartGWTEE 2.0 and GWT 1.7.

                      Thanks,
                      Stonebranch

                      Comment


                        #12
                        This seems to be working for us with similar code. Check that:

                        1. the item is not clipped - use the Watch Tab to make sure the form is not behind something else or clipped off

                        2. data is actually making it to the form. Use getValues() to verify.

                        3. indicate whether you are seeing a "viewFile" being initiated by the form at all

                        If none of these steps help, please try isolating this as a standalone test case.

                        Comment


                          #13
                          The problem is that showFileInline="true" on the form item doesn`t work.

                          16:49:57.727:XRP8:WARN:ViewFileItem:isc_ViewFileItem_0:setValue(): Unsupported field-type for showFileInline: ViewFileItem

                          Code:
                          <field name="logo" type="imageFile" title="Logo File" required="false" showFileInline="true" />
                          
                          ViewFileItem logoItem = new ViewFileItem(DropboxDS.LOGO , "Logo");
                          logoItem.setShowFileInline(true);
                          I don`t have problem viewing the file when I click on the viewFile Icon and when showFileInline="false" ,but we need to stream the image and display it inline.

                          Thanks,
                          Stonebranch

                          p.s. Upgraded to GWT 2.0 and SGWT2.1
                          Last edited by stonebranch1; 11 Mar 2010, 16:10.

                          Comment


                            #14
                            Ah, that warning points immediately to the cause, be sure to watch for those (we've made them much more visible in 2.1 as you may have noticed).

                            There's a bug here involving confusion between editorType and type. We're correcting it. In the meantime, create your ViewFileItem like this:

                            Code:
                            	    ViewFileItem target = new ViewFileItem("target");
                            	    target.setAttribute("editorType", "ViewFileItem");
                            	    target.setType("imageFile");

                            Comment


                              #15
                              It doesn`t work even if I create my logo ViewFileItem the way you suggested it.

                              Now
                              the View and Download icons are not displayed any more
                              I don`t get Unsupported field-type message
                              ViewFile operation doesn`t get initiated

                              Log Messages:

                              02:16:00.332:WARN:Canvas:isc_ViewFileItem_2_canvas:ignoring bad or negative height: -4 [enable 'sizing' log for stack trace]
                              02:16:00.343:INFO:sizing:isc_ViewFileItem_2_canvas:Specified size: 908x100, drawn scroll size: 908x14, border: 0x0, margin: 0x0, old size: 908x14, reason: undefined

                              Code:
                              Evaluator: result of 'isc_ViewFileItem_2_canvas
                              ' (11ms):
                              Canvas{creator: [ViewFileItem ID:isc_ViewFileItem_2 name:logo],
                              ID: "isc_ViewFileItem_2_canvas",
                              height: 100,
                              width: 908,
                              position: "absolute",
                              className: "normal",
                              left: 98,
                              top: 28,
                              tabIndex: 2150,
                              canvasItem: [ViewFileItem ID:isc_ViewFileItem_2 name:logo],
                              disabled: false,
                              showFocused: false,
                              parentElement: [DynamicForm ID:isc_OID_250],
                              topElement: [VLayout ID:isc_OID_66],
                              contents: " ",
                              zIndex: 203582,
                              }
                              Stonebranch

                              Comment

                              Working...
                              X