- private byte[] getBytes(InputStream is) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- byte[] block = new byte[1024];
- int n = is.read(block);
- while (n > 0) {
- bos.write(block, 0, n);
- n = is.read(block);
+ RepeatingView row = new RepeatingView("row") {
+ @Override
+ protected void onPopulate() {
+ removeAll();
+ final ValueHolder<Integer> ientry = new MyValueHolder<Integer>(index);
+ int irow = 0;
+ Album album = getAlbum();
+ while (irow < MAX_ROWS && ientry.getValue() < album.size()) {
+ WebMarkupContainer columns = new WebMarkupContainer(newChildId());
+ add(columns);
+ RepeatingView column = new RepeatingView("column") {
+ @Override
+ protected void onPopulate() {
+ removeAll();
+ int icolumn = 0;
+ Album album = getAlbum();
+ while (icolumn < MAX_COLUMNS && ientry.getValue() < album.size()) {
+ WebMarkupContainer thumbnail = new WebMarkupContainer(newChildId());
+ add(thumbnail);
+
+ final PhotoEntry entry = album.getEntry(ientry.getValue());
+ Link link = new SerializableEntryLink("thumbnail", entry.getPath());
+ thumbnail.add(link);
+
+ final ValueHolder<String> pathinfo = new MyValueHolder<String>();
+ if (entry instanceof Photo) {
+ pathinfo.setValue("/image/thumbnail/" + entry.getPath());
+ } else {
+ pathinfo.setValue("/image/resource/folder.png");
+ }
+ link.add(new Image("image") {
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ tag.put("src", context.getContextPath() + pathinfo.getValue());
+ }
+ });
+
+ link.add(new Label("name", album.getEntry(ientry.getValue()).getId()));
+ icolumn++;
+ ientry.setValue(ientry.getValue() + 1);
+ }
+ }
+ };
+ columns.add(column);
+ irow++;
+ }
+ }
+ };
+
+ add(row);
+
+ // upload panel
+ if (path.equals("/"))
+
+ {
+ add(new WebMarkupContainer("uploadPanel"));
+ } else
+
+ {
+ add(new UploadPanel("uploadPanel", path));