ADF 根据输出文本值显示图像



在我的 ADF 应用程序中,#attachmentTxt 元素中的值将服务/DB 中的附件值作为布尔值返回。如果值返回 true,我正在尝试显示 activeImage 对象,如果值为 false,则只显示空白。我仅限于使用标准的Javascript,没有像jQuery这样的外部。

<af:outputText id="attachmentTxt" value="#{bean.attachment}" visible="false" />
<af:activeImage id="attachmentImg" source="/images/icon.png"></af:activeImage>

我正在寻找的一个非工作示例是:

<af:resource type="javascript">
function hasAttachment() {
var att = document.getElementById("attachmentTxt");
var attImg = document.getElementById("attachmentImg");
if(att.value == 'true') {
attImg.show();
} else {
attImg.hide();
}
}
</af:resource>

提前谢谢你

在我看来,您应该使用activeImage标签的"rendered"属性来决定是否显示图像。所以没有必要使用 JavaScript。仅当值为 true 时,ADF 框架才会呈现图像。

<af:activeImage id="attachmentImg" source="/images/icon.png" rendered="{#bean.attachment}"></af:activeImage>

最新更新