- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我对 ADF Faces 表和动态区域有疑问。
先决条件:
Oracle JDeveloper 11.1.1.6.0
我正在使用 ADF Faces 和 ADF 绑定(bind)层在 af:table 中显示 Java POJO 列表。ADF 表显示在有界任务流内的 View 上。
此任务流用于另一个 View 上的动态区域。
导航包含两个链接,用于通过 bean-property 选择要在动态区域中显示的有界任务流。
动态区域通过任务流绑定(bind)接收“输入参数映射”。
该映射包含要在表中显示的 POJO 和一个状态 Bean,该状态 Bean 应保存表状态和 View 上可能的其他组件的状态(请参见下面的实现)。
问题/需求:
<强>1。预选:
在第一次加载表时根据 POJO 中包含的数据预选表中的单个行。
<强>2。保持对任务流切换的选择:
在切换到另一个有界任务流 B 并返回 A(表所在位置)后,还应选择表中的选定行(有界任务流 A)。
<强>3。无 MDS
不使用保存点/MDS 功能。
<强>4。一致的表模型和绑定(bind)层
在任务流之间切换和选择表中的元素后,应该可以询问表组件和所选行的绑定(bind)。
切换任务流和选择表中的元素后,表行和绑定(bind)中选择的行应该保持一致。
已经尝试过:
预选一行并在不使用 MDS/保存点的情况下保持对任务流切换的选择。
我已将一些表属性绑定(bind)到“状态”bean。bean 的实现附在下面。
<强>1。表的属性:
选定的行键:
selectedRowKeys="#{pageFlowScope.stateBean.tableStateBean.rowKeySet}"
绑定(bind) RichTable 的 Backing-Bean 属性:
binding="#{pageFlowScope.stateBean.tableStateBean.richTable}"
默认选择Listener
selectionListener="#{bindings.postanschriften.collectionModel.makeCurrent}"
我们在这里尝试了什么:
在表的初始加载和更改行 bean 方法 getRowKeySet(..) 被调用。
在此方法中,要选择的行是在初始表加载时计算的 (this.rowKeySet == null)。因为表属性 selectedRowKeys 绑定(bind)到 pageFlowScope.stateBean.tableStateBean.rowKeySet
如果在表中选择另一行,bean 中的属性将更新。如果我们将任务流从 A 更改为 B,反之亦然,则调用支持 bean 属性 richTable 的 getter。在 getter 方法中,选择状态被恢复。
<强>2。 “状态”bean 的实现:
public class TableStateBean {
private RichTable richTable;
private RowKeySet rowKeySet;
private String bindingIteratorName;
private RowMatcher matcher;
public RowKeySet getRowKeySet() {
if (this.rowKeySet == null) {
preselectRow();
}
return rowKeySet;
}
public RichTable getRichTable() {
if (richTable != null && rowKeySet != null) {
RowKeySet currentTableSelection = getCurrentTableSelection();
RowKeySet tableSelectionToRestore = getTableSelectionToRestore();
executeSelection(tableSelectionToRestore, currentTableSelection);
}
return richTable;
}
public void setRichTable(RichTable pRichTable) {
richTable = pRichTable;
}
public void doTableSelection(){
preselectRow();
}
private RowKeySet getCurrentTableSelection() {
Row currentRow = (Row) JSFUtils.resolveExpression("#{bindings." + this.bindingIteratorName + ".currentRow}");
Key currKey = currentRow.getKey();
ArrayList<Key> lst = new ArrayList<Key>(1);
lst.add(currKey);
RowKeySet keySet = new RowKeySetImpl();
keySet.add(lst);
return keySet;
}
private RowKeySet getTableSelectionToRestore() {
RowKeySet tableSelectionToRestoreRow = null;
RowSetIterator rowSetIterator = extractRowSetIterator();
int tableRowIndexOfCurrentSelectedKey = getSingleRowKeyIndexValue(this.rowKeySet);
if (tableRowIndexOfCurrentSelectedKey != -1) {
Row currentRow = rowSetIterator.first();
for (int i = 0; rowSetIterator.hasNext() && i < tableRowIndexOfCurrentSelectedKey; i++) {
currentRow = rowSetIterator.next();
}
if (currentRow != null) {
Key newSelectionKey = currentRow.getKey();
ArrayList<Key> keyList = new ArrayList<Key>(1);
keyList.add(newSelectionKey);
tableSelectionToRestoreRow = new RowKeySetImpl();
tableSelectionToRestoreRow.add(keyList);
}
}
return tableSelectionToRestoreRow;
}
private int getSingleRowKeyIndexValue(RowKeySet rowKeySet) {
int tableRowIndexOfCurrentSelectedKey = -1;
if (rowKeySet != null) {
Object[] rowKeySetArray = rowKeySet.toArray();
List<Key> selectedRowKeys = (rowKeySetArray.length > 0) ? (List<Key>) rowKeySetArray[0] : new ArrayList<Key>();
if (selectedRowKeys.size() > 0) {
Key currentSelectedKey = selectedRowKeys.get(0);
Object[] attributeValues = currentSelectedKey.getAttributeValues();
assert (attributeValues.length > 0);
tableRowIndexOfCurrentSelectedKey = (Integer) attributeValues[0];
}
}
return tableRowIndexOfCurrentSelectedKey;
}
private void executeSelection(RowKeySet newCurrentRow, RowKeySet oldCurrentRow) {
SelectionEvent selectionEvent = new SelectionEvent(oldCurrentRow, newCurrentRow, richTable);
selectionEvent.queue();
AdfFacesContext.getCurrentInstance().addPartialTarget(richTable);
}
protected void preselectRow() {
RowSetIterator rowSetIterator = extractRowSetIterator();
RowKeySet oldSelection = getCurrentTableSelection();
Row currentRow = rowSetIterator.first();
while (rowSetIterator.hasNext()
&& (!matcher.match(currentRow))) // Matcher selects which row should be displayed according to the Object bound behind the binding-layer.
{
currentRow = rowSetIterator.next();
}
if (currentRow != null) {
Key key = currentRow.getKey();
RowKeySet newSelection = createRowKeySet(key);
setActiveRowKey(key);
executeSelection(newSelection, oldSelection);
setRowKeySet(newSelection);
}
}
private void setActiveRowKey(Key pKey) {
ArrayList<Key> lst = new ArrayList<Key>(1);
lst.add(pKey);
this.richTable.setActiveRowKey(lst);
}
private RowKeySet createRowKeySet(Key pKey) {
ArrayList<Key> lst = new ArrayList<Key>(1);
lst.add(pKey);
RowKeySetImpl rowKeySetToCreate = new RowKeySetImpl();
rowKeySetToCreate.add(lst);
return rowKeySetToCreate;
}
private RowSetIterator extractRowSetIterator() {
DCIteratorBinding iteratorBinding = ADFUtils.findIterator(this.bindingIteratorName);
RowSetIterator rowSetIterator = iteratorBinding.getRowSetIterator();
return rowSetIterator;
}
}
在某些情况下,绑定(bind)层似乎与 RichTable 组件上选择的元素不同步。所以我猜上面提到的解决方案不是很稳健。
是否有另一种方法可以以稳健的方式归档上述功能?我认为根据绑定(bind)的 POJO 中的某些值预选表中的一行并不奇怪。并且在有界任务流(动态区域)之间切换后保持表格的选定行应该是可能的,不是吗?
期待您的帮助
问候,
最大
最佳答案
设置“选定”行相当容易。有几种解决方案。这只是其中之一:为您的表绑定(bind)到您的支持 bean。在 getter 中添加以下代码:
DCBindingContainer bindings = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcItteratorBindings =
bindings.findIteratorBinding("yourViewObjectIterator");
RowSetIterator it = dcItteratorBindings.getRowSetIterator();
Rows[] rows = voTableData.getAllRowsInRange();
Row needsSelection = null;
for(Row r: rows)
{
//just search for the row you want to set selected
if(r.getAttribute("SomeAttribute").eqauls(..))
needsSelection = r;
}
if(needsSelection != null)
it.setCurrentRow(needsSelection);
关于jsf - ADF AF :table restoring table state,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13469113/
我试图了解 JSF 实现如何识别用户的各种可能操作。在我放在一起的简单应用程序中,我在 login.xhtml 页面中配置了以下字段。 用户名 - 输入字段 密码 - 密码字段 登录按钮 取消按钮 登
我已经开始学习 JSF,我想知道在我们的类路径中包含什么 JAR 以开始使用 JSF。是jsf-api或 jsf-impl ?或者我们必须同时包含两者?如果两者都是,那么为什么它们不合并? 最佳答案
我是 java server faces (JSF) 的初学者,我需要将文本输入的内容传递到第二页以显示它,同样适用于第二页:我想将单选按钮值传递到第三页。我搜索并尝试了很多但没有成功。例如我试过
我有一个 JSF 页面。我的 CommandButton 操作方法值取决于 bean 变量值。 例子: Bean headerBean 具有可变的 actionValue,值为“someBean.do
我有两个 JSF 页面,假设 A 和 B。从这两个页面 A 和 BI 可以导航到页面 C。现在页面 C 中有一个按钮(确定按钮),单击它应该导航回 A 或 B,具体取决于从哪里(A 或 B)调用 C
我可以在没有 JSTL 标签的情况下使用 JSF 执行条件逻辑吗? 例如,我制作了一个复合组件,并想说明,如果指定了“id”属性,则定义“id”属性,但如果未指定“id”属性,则不要指定“id”属性。
我有一个应用程序,用户可以在其中从我的应用程序的欢迎页面动态切换语言环境。我看到早期的开发人员(在没有太多文档的情况下继承了代码)已经从 ViewHandler 覆盖了以下三个方法,并告诉我这是动态切
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
有没有一种方法可以在我的 JSF 2.0 应用程序中处理浏览器刷新事件,以便在浏览器刷新页面时将用户导航到欢迎页面? 这让我想到了另一个问题,即如何在托管 bean 中进行页面导航? 干杯, 最佳答案
我有两页。搜索页面是第一个接受用户输入的页面。第二页显示数据表中的结果集。第二页有 3 个面板,用于结果集、更新和在单个页面中创建。根据单击的按钮,我将面板呈现为真和假。 . . . . . .
由于我们在 Asp.Net 中有 comparevalidator,我们在 JSF 中有什么来验证两个字段的值是否相同?我想验证密码和确认密码字段。 最佳答案 不,这样的验证器在基本的 JSF 实现中
我想构建一个自定义 JSF 组件。现在我从 oracle 阅读了一些文档并看到了一些代码示例。问题是我有点困惑: 似乎有两种方法可以使用 JSF 2.0+ 构建自定义组件。据我了解,自 JSF 2.0
我遇到了与 user1598186 在他的问题中提到的相同的问题:p:commandButton doesn't call bean's method in an page 但是,没有给出解决方案(
这个问题在这里已经有了答案: Ajax update/render does not work on a component which has rendered attribute (1 个回答)
是否有内置机制可以有条件地重定向到另一个 View ?如果他/她已经登录,我希望用户从登录页面重定向到“主页”。 我已经有两种基本方法,但对于第一种我不知道如何实现,第二种是一种肮脏的解决方法。 添加
如何在 JSF 中格式化值 我需要格式化一个数字,如:12345.67 到 12,345.67 可以用模式吗? 最佳答案 尝试使用: 关于jsf - 用逗号格式化为数字 JSF,我们在Sta
根据this blog JSF 正在走向无状态。使用 JSF 的全部意义不在于它使保存和恢复状态成为一件苦差事。 JSF 成为无状态的有什么意义?您能否提供一个有用的示例。 最佳答案 首先,我想澄清
我读到某个地方(不再找到它),可以在资源包中使用EL Expresions,然后在不更改* .xhtml文件的情况下使用它。 some.text=#{someBean.stepsLeft} more
我想看一个简单的登录应用程序,不像this那么简单尽管。 我想要实现的是对 JSF 的工作原理的理解,我开发了很多 ASP.NET,您可以在其中隐藏代码,并且您可以在其中检查是否在登录时创建了 ses
如果#{myBean.birthdate}是java.util.Calendar或java.util.Date类型,我可以格式化吗this 在 EL 本身内部可能使用现有函数,其输出类似于 DateF
我是一名优秀的程序员,十分优秀!