Skip to content

doc: add documentation for the Upload component#981

Open
laurenic0l wants to merge 4 commits into
mainfrom
972-upload-component
Open

doc: add documentation for the Upload component#981
laurenic0l wants to merge 4 commits into
mainfrom
972-upload-component

Conversation

@laurenic0l
Copy link
Copy Markdown
Contributor

Adds the documentation article and demos for the new inline Upload component

Covers:

Basics + when to use vs. FileUploadDialog
Picking files: selection mode, picker source, filters, drop zone
Validation and limits + server-side validation note
Upload behavior: auto upload, auto clear, programmatic actions
Mobile capture
Native file system access
Customizing the layout: presets, part visibility, default slot
Themes
Events
Internationalization
Styling

- docs/components/upload.md covering basics, picker behavior, validation
  and limits, auto upload and auto clear, mobile capture, native file
  system access, layout customization with presets and the default slot,
  themes, events, internationalization, and styling
- UploadView: resume upload inside a job application form
- UploadPickingFilesView: multi-file gallery uploader with filter switching
- UploadAutoUploadView: ticket submission with background attachment uploads
- UploadPresetsView: side-by-side comparison of the four chrome presets
- UploadDefaultSlotView: HEADLESS preset with projected drop surface
- UploadEventsView: progress bar and status line driven by onChange,
  onListProgress, and onComplete
layout.add(upload);
```

The example below drops a resume `Upload` into a job application form, alongside a name field and submit button.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[Google.WordList] Use 'app' instead of 'application'.

@laurenic0l laurenic0l marked this pull request as ready for review May 28, 2026 02:34
@laurenic0l laurenic0l added the status: waiting-for-review The PR is ready. Waiting for team members to review. label May 28, 2026
@hyyan hyyan added the status: needs-snapshot Update to the latest snapshot before this PR can be merged. label May 28, 2026
@@ -0,0 +1,337 @@
---
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please include a description at the top for llm.txt parsing:

description: This component...

- **`ON_DROP`** uploads as soon as files are dropped onto the component.
- **`ALWAYS`** covers both paths.

Auto upload pairs well with the `BUTTON_ONLY` or `INLINE` presets, where there's no Upload button for the user to click anyway. For workflows where the user needs to review the selection before sending, leave auto upload off.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This likely belongs in a tip, but I'll leave that up to your judgement!

Comment thread docs/docs/components/upload.md Outdated

When the user picks a new batch, auto clear decides what to do with the entries already in the list. Clearing happens at the moment of the next pick, not on upload completion, so finished uploads stay visible until the user picks again.

:::warning Auto clear has subtle triggers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend moving this after the ENUM options, but up to you

:::tip Capture and filters
Restrict selection to image extensions so the camera opens in still mode, or to video extensions so it opens in recording mode. Without a corresponding filter, a capture mode falls back to the standard picker on most platforms. Desktop browsers ignore the capture setting entirely.
:::

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally up to you here, but I could see benefit in linking to the PWA section of the docs here for more info on using webforJ for mobile web app development

Comment thread docs/docs/components/upload.md Outdated
height='400px'
/>

## Themes {#themes}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd move this section to right before the end/styling section

@laurenic0l laurenic0l requested a review from MatthewHawkins May 28, 2026 20:43
@laurenic0l
Copy link
Copy Markdown
Contributor Author

Thanks for the feedback @MatthewHawkins. I've applied the changes

Copy link
Copy Markdown
Member

@hyyan hyyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurenic0l Looking great overall, just a few more requests!

@@ -0,0 +1,345 @@
---
title: Upload
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new-content badge

@@ -0,0 +1,345 @@
---
title: Upload
sidebar_position: 160
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the component to the gallery

submit);
}

private FlexLayout fieldGroup(String label, String helperText, Upload upload) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label is not aligned with the "full name" input's label horizontally


@Route
@StyleSheet("ws://css/upload/upload.css")
@FrameTitle("Upload Basic")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All upload demos should automatically delete any uploaded files directly from the server, and file system access must be disabled, as iframes block this feature otherwise the upload will never be triggered.

resume.setFileSystemAccess(false);
resume.onUpload(e -> {
  e.getFiles().forEach(file -> {
    try {
      file.delete();
    } catch (Exception ex) {
      // skip
    }
  });
});

@Route
@StyleSheet("ws://css/upload/upload.css")
@FrameTitle("Upload Basic")
public class UploadView extends Composite<FlexLayout> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify this demo to only include the uploa, nothing else. The form is not functional.

upload.setAutoClear(Upload.AutoClear.ALL);
```

:::warning Auto clear has subtle triggers
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not possible to select a file programmatically, so I'm not sure what that tip is referring to.


## Customizing the layout {#customizing-the-layout}

The component is built from five visible parts: the picker button, the drop label, the file list, the upload button, and the cancel button. By default all five are visible, but the layout can be reshaped with presets for common picker shapes, or with per-part visibility controls for finer adjustments.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default all five are visible, -> cancel button is not visible by default

@Route
@StyleSheet("ws://css/upload/upload.css")
@FrameTitle("Upload Default Slot")
public class UploadDefaultSlotView extends Composite<FlexLayout> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This demo doesn't do anything useful, please use the table demo instead.

```java
upload.onProgress(e -> {
// Fires repeatedly during a single file's transfer.
int percent = (int) e.getProgress();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why casting to int ?


@Route
@FrameTitle("Upload Themes")
public class UploadThemesView extends Composite<FlexLayout> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only display the primary theme and use the inline preset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: needs-snapshot Update to the latest snapshot before this PR can be merged. status: waiting-for-review The PR is ready. Waiting for team members to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants