0

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}" />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
itro
  • 7,006
  • 27
  • 78
  • 121

1 Answers1

1

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

JavaMan
  • 1,142
  • 12
  • 22
  • Thanks for your replay. I used it en with a combination of Trinidad dialog as below. ` `String viewId = "/popups/evs.xhtml"; TrinidadDialog dialog = new TrinidadDialog .Builder(viewId, event.getComponent()) .window().size(800, 600) .parameter(KMEHR_MESSAGE_PARAMETER, evsUrl) .build(); dialog.open();` I am going to accept your answer. – itro Jan 30 '20 at 10:55