Vaadin

Join Vaadin Log In
Combination View Flat View Tree View
Threads [ Previous | Next ]
Small immediate upload?
toggle
Small immediate upload?
12/19/09 10:35 PM
Hi,

The new immediate upload is very cool, but is there a easy way to give a stylename to the button? I'd like to

1upload.getButton().setStyleName("small");

But the button is not visible, only its caption. Setting the style for the upload itself is doesn't work, since it's actually the enclosing form, not the button div.

Is there a non-kludgy way to style the button?
Flag Flag
RE: Small immediate upload?
12/20/09 9:31 AM as a reply to Henri Muurimaa.
I don't know if this is exactly what you want - you can't apply the "small" style this way to the button without copying the css into an own identifier.

Anyhow, workaround: Give the whole upload component a new style name and style the button relative to the upload component.

Code:

Java:
1Window mainWindow = new Window("Test app");
2setMainWindow(mainWindow);
3upload = new Upload("foo bar", null);
4upload.setImmediate(true);
5upload.addStyleName("myCustomUpload");
6mainWindow.addComponent(upload);
7setTheme("testTheme");


CSS:
 1@import "../reindeer/styles.css";
 2
 3.myCustomUpload .v-button {
 4    background: none;
 5    border: 1px solid black;
 6    height: auto;
 7    padding: 0 !important;
 8}
 9
10.myCustomUpload .v-button .v-button-wrap {
11    height: auto;
12    background: none;
13    padding: 0 !important;
14}
15
16.myCustomUpload .v-button .v-button-wrap .v-button-caption {
17    height: auto;
18    padding: 2px;
19}


Result:


So if you want to do your own theme for the button, that'd be the way I'd go. If you'd like to use something predefined, like the small-style, you'd have to copy the whole small style into your theme and add the .myCustomUpload in front of the names.

And yeah, the new immediate upload is quite nice! emoticon
Flag Flag
RE: Small immediate upload?
12/20/09 11:36 AM as a reply to Jens Jansson.
Yeah, that's the kludgy way I'd like to avoid emoticon
Flag Flag
RE: Small immediate upload?
12/20/09 11:45 AM as a reply to Henri Muurimaa.
Well, the alternative seems to be to extend the whole component, extend the API and add the style name to the button, provided by the new API. emoticon
Flag Flag
RE: Small immediate upload?
12/20/09 5:20 PM as a reply to Jens Jansson.
I think I'll wait, perhaps the API will include a setButtonStyleName() or something at some point... ;)
Flag Flag