Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Right Click Delete Option to delete particular item from Treetable
hey Guys Help me
I want right click menu in which add and delete option..
when i right click on parent name or down arrow than i will get delete option which delete that entry from database.
I can write database Query but I cant find way to Get Item ID of particular clicked item ???
can anybody help me ?
Please check my code and Image Attached at down of post....Image at Down Post..
and Reply Solution as soon as possible,here
thank you
..................................................................................
public class Testone extends verticalLayout implements
ValueChangeListener,ClickListener{
private static final long serialVersionUID = 1L;
protected static final String NAME_PROPERTY = "Prenom";
protected static final String Parent_PROPERTY = "parent";
protected static final String Nom_PROPERTY = "Nom";
protected static final String Type_PROPERTY = "Type";
protected final TreeTable treetable;
@SuppressWarnings("serial")
public usermanagement(String Titre, Main slice) throws Exception {
super("User Managment", slice, false);
setWidth("100%");
// Create the treetable
treetable = new TreeTable();
treetable.setWidth("100%");
addComponent(treetable);
// Add Table columns
treetable.addContainerProperty(NAME_PROPERTY, String.class, "");
treetable.addContainerProperty(Nom_PROPERTY, String.class, "");
treetable.addContainerProperty(Parent_PROPERTY, String.class, "");
treetable.addContainerProperty(Type_PROPERTY,String.class,"");
Statement requete = MySQL.creeRequete();
String request = "select * from personne ,enfant where personne.login=enfant.login";
final ResultSet resultat = requete.executeQuery(request);
try {
while (resultat.next())
{
// Populate table
Object parent = treetable.addItem(new Object[] { resultat.getString("parent"),resultat.getString("nom"),null,resultat.getString("type") }, null);
Object child = treetable.addItem(new Object[] {resultat.getString("login"),resultat.getString("nom"),resultat.getString("parent"),resultat.getString("genre") }, null);
// Set hierarchy
treetable.setParent(child, parent);
// Expand all
treetable.setCollapsed(parent, true);
//treetable.setCollapsed(year2010, false);
final Action ACTION_Delete = new Action("Delete");
final Action ACTION_Add = new Action("add");
final Action[] ACTIONS = new Action[] { ACTION_Delete, ACTION_Add };
// Actions (a.k.a context menu)
treetable.addActionHandler(new Action.Handler() {
public Action[] getActions(Object target, Object sender) {
return ACTIONS;
}
public void handleAction(Action action, Object sender, Object target) {
if(action.equals(ACTION_Delete))
{
System.out.print("you click on red"+treetable.getItem(treetable.getValue()));
System.out.print("you click on red"+treetable.getCaption());
}
//Do something when the user chooses a item from the popup menu.
}
});
}
}
catch (Exception e) {
System.out.println("pas d'enfants pour " );
}
}
@Override
public void buttonClick(ClickEvent event) {
// TODO Auto-generated method stub
}
@Override
public void valueChange(ValueChangeEvent event) {
// TODO Auto-generated method stub
}
}