I use Viritin MultiSelectTable to display JPA entities. The entities are displayed properly, but when I click on a row, all rows are selected.
I initialize my table as follows:
MultiSelectTable<MyEntity> acFiles = new MultiSelectTable<MyEntity>().withProperties(
"filedate",
"filesize",
"rows",
"filename"
);
acFiles.setOptions(myDAO.findAll());
acFiles.addListener(((Listener) event -> {
System.out.println("Clicked Row");
}));
What am I doing wrong, so that all the rows are selected everytime I click?
答案 0 :(得分:0)
症状听起来像你在MyEntity类中以某种方式严重实现了equals / hashCode方法实现,而Vaadin将所有对象视为相同。如果它是一个JPA实体,一个非常好的工作策略就是像这样实现它们:
private enum WindowShowStyle : uint
{ // find more info at http://stackoverflow.com/a/8210120/1245420
Hide = 0, ShowNormal = 1, ShowMinimized = 2, ShowMaximized = 3,
ShowNormalNoActvate = 4, Show = 5, Minimize = 6, ShowNoActivate = 8,
Restore = 9, ShowDefault = 10, ForceMinimized = 11
}
[DllImport("user32.dll", SetLastError = true)]
static extern System.IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
static extern System.IntPtr FindWindowByCaption(System.IntPtr ZeroOnly, string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(System.IntPtr hWnd, WindowShowStyle nCmdShow);
DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
public App()
{
this.Deactivated += App_Deactivated;
this.Activated += App_Activated;
timer.Tick += delegate
{
Application.Current.MainWindow.Activate();
System.IntPtr hWndCharmBar = FindWindowByCaption(System.IntPtr.Zero, "Charm Bar");
ShowWindow(hWndCharmBar, 0);
};
timer.Interval = new TimeSpan(0, 0, 0, 0, 10);
}
void App_Activated(object sender, EventArgs e)
{
timer.Stop();
}
void App_Deactivated(object sender, EventArgs e)
{
timer.Start();
}
“完美方式”取决于您如何使用标识符。