Amar Jarubula
Amar Jarubula

Reputation: 59

How can I use h:graphicImage to show a URL in a tab

I am writing a small application where I take a search string and show the results in the tabs with different search servers like Google,Yahoo,Bing etc., on the onkeyup event of the searchString inputText. I have tried to use h:graphicImage as well as h:outputLink with no results. h:graphicImage, I think, is expecting a relative path not absolute path and h:outputLink is working just like the anchor tag. Is there any other way to get what I am expecting it to do?

                <h:panelGrid columns="3" styleClass="panelGroupClass">
                    <h:panelGroup>
                        <h:graphicImage value = "#{searchController.googleURL}" alt="Google URL"/>
                    </h:panelGroup>
                </h:panelGrid>

Upvotes: 1

Views: 1946

Answers (1)

BalusC
BalusC

Reputation: 1108642

The <h:graphicImage> expects an URL to an image (a file with .jpg, .gif, .png or whatever extension) and will show it in a HTML <img> element. If the URL is relative (i.e. it doesn't start with http:// then it's relative to the domain where your website runs. If it is absolute (i.e. it starts with http://), then, well, it's absolute :)


Update as per the comments, you seem to want to embed the complete HTML output of an external site in your webpage. You should basically be using a HTML <iframe> for this.

<iframe src="#{searchController.googleURL}"></iframe>

There are no standard JSF components which renders a HTML <iframe> element. Above should however just work as good when you're using Facelets instead of JSP.

Upvotes: 1

Related Questions