我对我的方法有疑问。我正在使用 JDeveloper 12c。我有一个名为 activeYear 的方法,其代码在这里:
public void activeYear() {
this.getCurrentRow().setAttribute("Active", 1);
}
它基于复选框。在我的应用程序中,它的工作原理是 - 我有一个按钮,它使用这种方法。如果我按下它,我的当前行会将其复选框值“Active”更改为选中状态。
要点是:我必须只有一行处于 Activity 状态,当我立即按下按钮时,必须取消选择其他每一行。我如何更改此代码?或者我应该再添加一种方法吗?
解决方案:
在我的方法 activeYear 中,我添加了名为 deactive 的方法,其代码如下:
public void deactive() {
RowSetIterator rowSetIterator = this.createRowSetIterator("New");
if (rowSetIterator != null) {
rowSetIterator.reset();
while (rowSetIterator.hasNext()) {
Row currentRow = rowSetIterator.next();
currentRow.setAttribute("Active", 0);
}
rowSetIterator.closeRowSetIterator();
}
}
问候, WK
最佳答案
在模型层中,在 activeYear 的 set 方法上,首先找到当前为 1 的行并将其设置为 0,然后将当前行设置为 1。
关于java - 如何在列中仅设置一个可能的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23130111/