ADF 根据 OutputText 值显示图像
ADF Display Image Based on OutputText Value
在我的 ADF 应用程序中,#attachmentTxt 元素中的值 returns 来自 service/DB 的附件值作为布尔值。我试图在值 returns 为真时显示 activeImage 对象,如果为假则只显示空白。我仅限于使用标准 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>
在我的 ADF 应用程序中,#attachmentTxt 元素中的值 returns 来自 service/DB 的附件值作为布尔值。我试图在值 returns 为真时显示 activeImage 对象,如果为假则只显示空白。我仅限于使用标准 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>