【问题标题】:Displaying Image depending on a value in oracle adf根据 oracle adf 中的值显示图像
【发布时间】:2015-01-21 12:22:34
【问题描述】:
我们正在使用
开发一个网络应用程序
我们的要求:我们有一个名为 Departments 的表,其中包含两列“deptId 和Employees”。我们已经为 Departments 表创建了实体和视图对象。我们正在使用视图对象的数据控制在 jsf 页面中创建一个表。我们想要的表格如下。我们拖放第一列。如果部门中的员工少于 100(例如),我们需要创建另一个应该包含绿色图像的列,否则为红色图像。我们的主要要求是根据某些条件显示图像。
提前致谢。
【问题讨论】:
标签:
oracle-adf
jdeveloper
【解决方案1】:
或者在一行中使用条件 EL:
<af:image source=
"#{row.bindings.EmployeeCount.inputValue ge 100 ? '/red.png' : '/green.png'}"/>
【解决方案2】:
我们的主要要求是根据某些条件显示图像。
我的假设是您的 View 对象中已经有一个属性,它反映了您所依赖的数据(在这种情况下,员工人数为 EmployeeCount)。然后,您可以简单地使用 rendered 属性和 EL 表达式在表格中显示不同的图像:
...
<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>
...