hi,
I’m new in VAADIN ,i create dynamically many TwinColSelect and i need to access to one of them in reason to set it visible.
this is the method where i create the TwinColSelect:
public void RoleData(VerticalLayout lv) {
ComboBox module = new ComboBox ( "Role:");
Statement st = null;
try {
st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
ResultSet result = null;
result = st.executeQuery("select * from u_module order by name");
lv.addComponent(module);
while (result.next()) {
module.addItem(result.getString("name"));
module.setNullSelectionAllowed(false);
//create TwinColSelect
priv = new TwinColSelect();
Privstore(result.getString("name"), priv);
priv.setVisible(false);
lv.addComponent(priv);
lv.addComponent(priv);
}
result.beforeFirst();
result.next();
module.setValue(result.getString("name"));
priv.setVisible(true);
Privstore(result.getString("name"), priv);
} catch (SQLException e1) {
e1.printStackTrace();
} catch (UnsupportedOperationException e) {
e.printStackTrace();
}
}
Maren, not sure I got you right, so please correct me, but do you want to extract some component from a VerticalLayout instance to where it was added prevously ?
If so, just iterate over VerticalLayout children and find your component:
VerticalLayout vl = ......
Iterator<Component> i = vl.getComponentIterator();
while ( i.hasNext() )
{
Component c = i.next();
if ( c instanceof TwinSelect )
{
TwinSelect mywidget = (TwinSelect)c;
...
}
}
You’ll need to be able to identify them somehow. For instance, you can use setData / getData method on any Vaadin widget to store your specific data there. Or you may create your own widget which extends TwinSelect and add some identity fields there.
If you’re extending core widget from a server-side, you don’t need to deal with the client side and a widgetset, so just extend class and that’s all.