sorry with my bad english
I am a new user of the Vaadin Framework
I use vaadin 7 (continuing the ongoing project)
“The goal, when clicking the list tree displays the image in component 2”
[https://postimg.cc/0b5BkqyS]
(https://postimg.cc/0b5BkqyS)
I have made 3 components
- component tree
- component displays the document image
- document information components
component 1
package com.work.newdesign.docimaging;
import com.vaadin.event.ItemClickEvent;
import com.vaadin.server.FileResource;
import com.vaadin.server.VaadinService;
import com.vaadin.ui.*;
import java.io.File;
public class DocumentTreeView extends VerticalLayout {
// A menu tree
Tree docCtgList = new Tree();
public DocumentTreeView(){
// An item with hierarchy
docCtgList.addItem("Category Documents");
docCtgList.addItem("SPAJ");
docCtgList.addItem("SPAK");
docCtgList.setChildrenAllowed("SPAJ", false);
docCtgList.setChildrenAllowed("SPAK", false);
docCtgList.setParent("SPAJ", "Dokumen Penutupan Polis");
docCtgList.setParent("SPAK", "Dokumen Penutupan Polis");
docCtgList.setImmediate(true);
docCtgList.expandItem("Dokumen Penutupan Polis");
addComponent(docCtgList);
setSizeFull();
docCtgList.addItemClickListener( new ItemClickEvent.ItemClickListener() {
@SuppressWarnings("deprecation")
public void itemClick(ItemClickEvent event) {
// Pick only left mouse clicks
if (event.getButton() == ItemClickEvent.BUTTON_LEFT)
Notification.show("Left Click",
Notification.Type.HUMANIZED_MESSAGE);
// Find the application directory
String basepath = VaadinService.getCurrent()
.getBaseDirectory().getAbsolutePath();
// Image as a file resource
FileResource resource = new FileResource(new File (basepath +
"images/icon/32/search.png"));
// Show the image in the application
Image image = new Image("Image from file", resource);
// Let the user view the file in browser or download it
Link link = new Link("Link to the image file", resource);
}
});
}
}