marcwebdude
marcwebdude

Reputation: 73

ADF Display Image Based on OutputText Value

In my ADF application, the value in #attachmentTxt element returns the attachment value from the service/DB as a boolean value. I am trying to display the activeImage object if the value returns true and to just display blank if it's false. I am limited to the use of standard Javascript, no externals such as jQuery.

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

a non-working example for what I'm looking for is:

<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>

Thank you in advance

Upvotes: 0

Views: 523

Answers (1)

giftkugel
giftkugel

Reputation: 26

in my opinion you should use the "rendered" attribute of the activeImage tag to decide whether to display the image or not. So it is not necessary to use JavaScript. The ADF Framework will only render the image if the value is true.

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

Upvotes: 1

Related Questions