Announcement

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

    UploadItem size

    Hi. I've got a problem with UploadItem. I can't set its width properly. Using setWidth does not work. As far as I know file input items width is controlled by its size attribute. Does anyone know how to set it? Invoking

    Code:
    UploadItem ui = new UploadItem("file");
    ui.setAttribute("size", "35");
    doesn't make any difference.

    I think I could use
    Code:
    DOM.setElementAttribute(fileItem.getElement(), "size", "35");
    but UploadItem does not have getElement method.

    Any help would be appreciated.

    #2
    hi mtus,

    try "maxFileSize"

    public java.lang.Integer maxFileSize
    For fields of a type that are represented by binary data initially uploaded from a file (currently "binary" and "imageFile", see FieldType), this sets the maximum file size allowed, in bytes.

    regards,
    timo

    Comment


      #3
      Hi. Thanks for the answer but I think you've misunderstood my question. I've got a problem with input width, not file size.

      Comment


        #4
        oh sorry.

        look at my code:

        DynamicForm uploadForm = new DynamicForm();
        uploadForm.setNumCols(4);

        FileItem xmlFileItem = new FileItem("XMLORREPORTFILE", "XML File");
        xmlFileItem.setWrapTitle(false);
        xmlFileItem.setRequired(true);
        xmlFileItem.setColSpan(4);
        xmlFileItem.setAlign(Alignment.LEFT);
        xmlFileItem.setWidth(300);

        maybe!! you can do it in a DynamicForm with setColSpan().

        Comment


          #5
          Unfortunately Your code did not work for me.
          And the solution I've found -> I've set size by invoking native javascript. I've queried the DOM with jQuery and I've set the size attribute to appropriate value
          Last edited by mtus; 17 Feb 2011, 05:31.

          Comment


            #6
            Originally posted by mtus
            Unfortunately Your code did not work for me.
            And the solution I've found -> I've set size by invoking native javascript. I've queried the DOM with jQuery and I've set the size attribute to appropriate value
            Would you mind sharing how did you find this specific element in the DOM? Thanks

            Comment


              #7
              I am having the same problem.
              The thing is that FF has limitations about the native upload widget that does for unknown reasons not support width (in pixels) but instead size (width in characters).
              See also end of posting here:
              http://forums.smartclient.com/showthread.php?t=4850

              It would therefore be nice to have a way to set the size via the SmartGWT API. Generally it is a big problem for users of the SmartGWT API to workaround a problem if they know which attribute in the DOM will do the trick.
              I can see why SmartGWT wants to prevent this but a deprecated backdoor would help a lot!
              After all if you are developing a web app setting an additional attribute to an element is the easiest thing in every other web-framework but SmartGWT is very much in the way in such case. I know about lazy creation of DOM elements and all the things but anyway this would be possible if you wanted to... Thanks for thinking about it :)

              BTW: I can tell you where this is currently leading to:
              I get the DynamicFrom and add a Draw-Handler. That one is calling dynamicForm.getDom().getId() to get the ID and then doing DOM.getElementById(id) and then recursively searches the DOM for the formItem by its name attribute. There I can set the size Attribute.
              This is ugly and disgusting. It would still be a hacky workaround if I would call uploadItem.getDeprecatedBackdoor().setAttribute("size", "80"); until the next release of SmartGWT comes out but much less painful and fragile.

              Comment

              Working...
              X