jsfprimefacesmyfacestrinidad

How to display external links content in a dialog from Java Bean?


I should display an external link content in a dialog dynamically. I trayed this in my bean but it just opens a new tab. Is there any other way to show the content of the external link in the dialog?

I use Primefaces, Trinidad, and JSF in my pages and am open to using any other framework. Any simple solution is very welcome.

in bean:

public void launchUrl(String url) {

        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
 }

in xhtml:

first method:

<tr:goButton id="evsButton1" text="eVS" onclick="openUrl('#{bean.url}')" />

<script type="text/javascript">
        function openUrl(url) {
          window.open(url,"_blank");
        }
      </script>

second method:

<tr:goButton id="evsButton" text="eVS" destination="#{bean.url}" targetFrame="_blank" attributeChangeListener="#{wijzigBean.fetchUrl}" />

Solution

  • I think it should be possible to add the external content as an iframe

     <div id="someId"> 
        <iframe id="iframeId" name="iframe" frameborder="0" scrolling="auto" src="#{yourbean.externalUrl}">
           <p>Something went wrong.</p>
        </iframe>
     </div>
    

    from Adding iframe to JSF components