根据 oracle adf 中的值显示图像

Displaying Image depending on a value in oracle adf

我们正在使用

开发 Web 应用程序

我们的要求:我们有一个名为 Departments 的 table,有两列 "deptId and Employees"。我们已经为部门 table 创建了实体和视图对象。我们正在使用视图对象的数据控件在 jsf 页面中创建一个 table。我们想要的 table 如下。我们拖放第一列。如果部门中的员工少于 100(例如),我们需要创建另一个应包含绿色图像的列,否则为红色图像。我们的主要要求是根据某些条件显示图像。

提前致谢。

Our main requirement is we have show image depending on some condition.

我的假设是您的 View 对象中已经有一个属性,它反映了您所依赖的数据(在本例中为 EmployeeCount 的员工人数)。然后,您可以简单地使用 rendered 属性和 EL 表达式来在 table:

中显示不同的图像
...
<af:column headerText="Icon" id="c1">
    <af:image source="#{resource['images:green.png']}" id="i1" 
              rendered="#{row.bindings.EmployeeCount.inputValue lt 100}"/>
    <af:image source="#{resource['images:red.png']}" id="i2" 
              rendered="#{row.bindings.EmployeeCount.inputValue ge 100}"/>
</af:column>
...

或者在一行中使用条件 EL:

<af:image source=
 "#{row.bindings.EmployeeCount.inputValue ge 100 ? '/red.png' : '/green.png'}"/>