KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > FileChooserCG


1 /*
2  * $Id: FileChooserCG.java,v 1.17 2005/05/26 13:18:09 neurolabs Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css;
15
16
17 import java.io.IOException JavaDoc;
18
19 import org.wings.SComponent;
20 import org.wings.SFileChooser;
21 import org.wings.io.Device;
22
23 public class FileChooserCG extends AbstractComponentCG implements
24         org.wings.plaf.FileChooserCG {
25
26     public void writeContent(final Device device,
27                              final SComponent _c)
28             throws IOException JavaDoc {
29         final SFileChooser component = (SFileChooser) _c;
30
31         int columns = component.getColumns();
32         /*
33         * for some wierd reason, the 'maxlength' column contains the
34         * maximum content length .. see RFC1867.
35         * .. anyway, all browsers seem to ignore it or worse, render the
36         * file upload unusable (konqueror 2.2.2).
37         */

38         //int maxContent = component.getSession().getMaxContentLength()*1024;
39

40         // maxLength = maxContent removed, since it does not work.
41
device.print("<input type=\"file\"");
42
43         Utils.printCSSInlineFullSize(device, component.getPreferredSize());
44
45         Utils.optAttribute(device, "size", columns);
46         Utils.optAttribute(device, "accept", component.getFileNameFilter());
47
48         if (component.isEnabled()) {
49             device.print(" name=\"");
50             Utils.write(device, Utils.event(component));
51             device.print("\"");
52             device.print(" id=\"");
53             Utils.write(device, component.getName());
54             device.print("\"");
55         }
56         else
57             device.print(" readonly=\"true\"");
58
59         if (component.isFocusOwner())
60             Utils.optAttribute(device, "focus", component.getName());
61
62         Utils.optAttribute(device, "tabindex", component.getFocusTraversalIndex());
63
64         Utils.writeEvents(device, component);
65         device.print("/>");
66     }
67 }
68
Popular Tags