Dynamic iframe src

Is there a way to dynamically load the src attribute of an iframe component with a jsf session value? I have a jsf page with an iframe which points to another web site. This website can be different dependand on a session variable. I am currently using an outputlink to target the iframe but would like to eliminate the need to press the link . Here is my code below:
<f:view>
<html lang="en-US" xml:lang="en-US">
<head>
<meta content="no-cache" http-equiv="Cache-Control"/>
<meta content="no-cache" http-equiv="Pragma"/>
<title>web Title</title>
<link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body style="-rave-layout: grid">
<div style="left: 0px; top: 0px; position: absolute">
<jsp:directive.include file="header.jspf"/>
</div>
<h:form binding="#{web.form1}" id="form1">
<h:outputLink binding="#{web.hyperlink1}" id="hyperlink1" style="left: 20px; top: 152px; position: absolute" target="t1" value="#{SessionBean1.webPath}">
<h:outputText binding="#{web.hyperlink1Text}" id="hyperlink1Text" value="Press here to view images"/>
</h:outputLink>
<div style="height: 600px; left: 20px; top: 192px; position: absolute; width: 754px">
<iframe frameborder="1" height="600px" marginheight="0" marginwidth="0" name="t1" scrolling="yes" src="" escape="false"/>' width="750px"></iframe>
</div>
</h:form>
</body>
</html>
</f:view>
</jsp:root>
What I would like is to populate the src of the iframe with "#{SessionBean1.webPath}" . Am I missing something extremely obvious?
Any help would be greatly appreciated.

Yes it's possible to load dynamically the src attribute. In fact the solution is almost simple.
The problem is that iframe is a pure html component so it's impossible to bind src with backing bean's attribute.
To resolve this pb you can use an outputText attribute which is binded with backing bean's attribute. This attribute could be filled with a string such as <iframe id="MyFrame" src="http://xxxxxx"></iframe>. On the other hand you have to unselect escape option of outputText to be sure that <iframe> string will be translated as a html string.
The frame will be generated at runtime.

Similar Messages

  • JSP iframe src = 'a file that is created by another JSP'  Error

    I have a JSP file that has an iframe into which, I want to load a .pdf file.
    Firstly, the iframe should contain nothing(and it does so), and when I press a button, another JSP is called, which creates a .pdf file and puts it in the WEB directory of the Application. After creating the .pdf, this JSP calls the first JSP, that now is supposed to load into the iframe the created .pdf.
    The .pdf is created corectly, but I believe that a synchronization is needed, so that the first JSP should not load the .pdf until the second doesn't finish writing it.
    I tried with delaying, but no success.And then I tried with synchronized(page){ }, but there are many possibilities instead of "page", and I came to no success.
    Here are my two JSPs:
    <%--
    Document : user
    Created on : 06.05.2008, 13:27:06
    Author : razvanb
    --%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>UserAbruf</title>
    <script type="text/javascript" language="JavaScript" src="jsscript.js">
    </script>
    </head>
    <style type="text/css">
    body {background-color : white}
    </style>
    <body>
    <%response.setHeader("Cache-Control", "must-revalidate, no-cache");
    response.setHeader("Expires", "0"); %>
    <div style="position:absolute;top:0px;left:0px;width:150px;height:100%" id = "userDiv">
    <form name="userForm" action="userForm" method="post">
    <br>
    <table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr>
    <td>
    <img src="sign.gif" alt="LOGO" style="position:relative;left:20%"/>
    </td>
    </tr>
    <tr>
    <td>
    <input type="button" value="Neuer Abruf" style="position:relative;top:20px;left:30%" onclick="gotopage('NeuAbrufS.jsp')">
    <br>
    <br>
    <input type="button" value="Abruf bearbeiten" style="position:relative;top:20px;left:30%">
    </td>
    </tr>
    </table>
    </form>
    </div>
    <%
    if(session.getAttribute("isource") == null){
    System.out.println("before pressing");%>
    <div style="position:absolute;top:0px;left:200px;width:100%;height:100%" id = "userFrameDiv">
    <h1 style="position:relative;left:7%;font-family:verdana"> Mobilit�tsabruf-Managementsystem </h1>
    <iframe width="850" height="590" id="frame1" name="frame1" ></iframe>
    </div>
    <% }
    if(session.getAttribute("isource") != null) {
    System.out.println("after pressing:"+ (String)session.getAttribute("isource"));%>
    <div style="position:absolute;top:0px;left:200px;width:100%;height:100%" id = "userFrameDiv">
    <h1 style="position:relative;left:7%;font-family:verdana"> Mobilit�tsabruf-Managementsystem </h1>
    <iframe src = <%=(String)session.getAttribute("isource")%> width="850" height="590" id="frame1" name="frame1" ></iframe>
    </div>
    <%session.setAttribute("isource", null);
    }%>
    </body>
    </html>
    <%-- <%=(String)session.getAttribute("isource")%> --%>
    <%-- Abruf 38 LwA.pdf --%>
    <%--
    Document : NeuAbrufS
    Created on : 08.05.2008, 13:45:02
    Author : razvanb
    --%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Abruf</title>
    </head>
    <body>
    <%-- start web service invocation --%><hr/>
    <%
    try {
    localPackage.UserWsdlService service = new localPackage.UserWsdlService();
         localPackage.UserWsdlPortType port = service.getUserWsdlPort();
         // TODO initialize WS operation arguments here
         localPackage.UserAccount input = new localPackage.UserAccount();
    input.setUsername((String)session.getAttribute("username"));
    input.setPassword((String)session.getAttribute("password"));
    System.out.println(input.getUsername() + ", " + input.getPassword());
         // TODO process result here
         boolean result = port.createNewPdf(input);
    } catch (Exception ex) {
         // TODO handle custom exceptions here
    java.util.Random random = new java.util.Random();
    int randomNr = random.nextInt();
    session.setAttribute("isource", "Abruf 38 LwA.pdf?rubbish="+ randomNr);
    request.getRequestDispatcher("user.jsp").forward(request, response);
    %>
    <%-- end web service invocation --%><hr/>
    <%-- <jsp:forward page="user.jsp"></jsp:forward> --%>
    </html>

    Hi Alha,
    when that file is locked by the other program you can't do anything about that - apart from quitting that other program. Probably this isn't an option to you…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • IFRAME Page being redirected to iFrame SRC url instead.

    I am having a problem in getting iFRAME code to work in iWeb 08.
    I have a link on page A which takes me to page B where I have pasted following code within a Html Snippet :
    +<IFRAME SRC="http://www. google.com" WIDTH=1000 HEIGHT=500>+
    +Not working but here is a link to it :+
    +link+
    </IFRAME>
    When I click on link in page A, instead of going to 'http://web.me.com/........page_B.html' and staying there, it parks there (http://web.me.com/........page_B.html) for a second and then is redirected to :
    'https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false &continue=http%3A%2F%2Fmail.google.com%2Fmail%2F%3Fui%3Dhtml%26zy%3Dl&bsv=zpwhty gjntrz&scc=1&ltmpl=default&ltmplcache=2'.
    Can anyone please help me with this.
    many thanks.
    Message was edited by: mnaseersj

    Whatever it is you try to accomplish, it's a great mess.
    This is what's in the HTML Snippets (I had to kill the loading of the pages):
    widget0
    <IFRAME SRC="http://www.googlemail.com" WIDTH=1000 HEIGHT=500>
    Not working but here is a link to it :
    <A HREF="http://www.googlemail.com">link</A>
    </IFRAME>
    widget1
    <IFRAME SRC="http://www.apple.com" WIDTH=1000 HEIGHT=500>
    Not working but here is a link to it :
    <A HREF="http://www.googlemail.com">link</A>
    </IFRAME>
    widget2
    <IFRAME SRC="http://www.googlemail.com" WIDTH=1000 HEIGHT=500>
    Not working but here is a link to it :
    <A HREF="http://www.googlemail.com">link</A>
    </IFRAME>
    What are the links to google and apple doing there?
    The correct code for a <iframe> is :
    <iframe src="url.to.page.html" width="500" height="500" scrolling="no" frameborder="0"></iframe>
    Perhaps getting acquainted with HTML is in order : [IFRAME - Inline Frame|http://htmlhelp.com/reference/html40/special/iframe.html]

  • Firefox 3.6 crashes or hangs when setting an iframe src to a pdf via javascript. 3.5 works fine

    Firefox hangs or crashes when setting iframe src to a pdf via javascript. Works fine in all previous versions of Firefox. This is using the most recent version of Adobe Reader 9.
    == This happened ==
    Every time Firefox opened
    == I upgraded to Firefox 3.6

    More info:
    Seems to be the same issue as this
    [http://support.mozilla.com/en-US/forum/1/585926#threadId622326]
    and this
    [http://support.mozilla.com/en-US/forum/1/585926?forumId=1&comments_threshold=0&comments_parentId=585926&comments_offset=20&comments_per_page=20&thread_style=commentStyle_plain#threadId659555]

  • Iframe src bound to backend bean url

    Hello there,
    I have a jspx page with an iframe. I would like to bind
    the src of that iframe to an url which is in my backend
    bean - populated by reading a property file.
    Here the code. .jspx
    <f:verbatim>
    <IFRAME src="http://my.oracle.com" frameborder="0"
    align="middle" height="800" scrolling="auto"
    width="1000" name="myoiFrame"
    id="oiFrame"/>
    </f:verbatim>
    Thanks very much.
    Regards

    Hi,
    only JSF components can be bound to a managed bean.
    Frank

  • In a region iframe src a blob file problem?

    hi ,
    I try to make an example like this:I have a table which store blob files.And I try to see the file content in html region
    htp.p('<iframe src="ptest?n='||:P1_FILE_ID||'" width="650" height="450" />
    </iframe>
    <item name="deneme" type="button" onclick="doSubmit(NEXT)"></item>');
    to display the file in a frame but ı cant see in the frame.when button next submit the other file must be seen but always alert open file or save message but ı dont want this ı want to see the file content in iframe region.Can you help.
    thanks.

    This is how i am setting the property.
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModuleImpl am =(OAApplicationModuleImpl)pageContext.getRootApplicationModule();
    OAPageLayoutBean pagelayoutbean = pageContext.getPageLayoutBean();
    OAStackLayoutBean stacklayoutbean = (OAStackLayoutBean)pagelayoutbean.findIndexedChildRecursive("xxdbdIROneTimeAddressRN");
    if("enableaddress".equals(pageContext.getParameter(EVENT_PARAM))) {
    stacklayoutbean.setRendered(true);
    The region 'xxdbdIROneTimeAddressRN' is having messagelovinput bean.

  • Safari doesn't recognize & encoded in iframe src

    I'm trying to render in an iframe a page that allows authentication to be sent as part of the URL, but I can't get Safari 4 Beta (10.5.7) to properly escape (or unescape) the '&' required to separate the parameters I'm passing as part of the URL. I've pasted two code snippets, neither of which work, but both work fine in Firefox. Can I change the code, is there better XHTML to be using?
    <iframe src="https://www.visualcoaching.com/login.ashx?user=[email protected]&pas sword=passwd&branding=off">
    <iframe src="https://www.visualcoaching.com/login.ashx?user=[email protected]&amp ;password=passwd&amp;branding=off">
    In both cases, I get the login page of the visualcoaching.com site, not the page I'm supposed to see after authenticating. When I check the page source in Safari I see both '&' and '& amp;' rendered as '& amp;' (without the space) in the iframe tag, which is not working when it comes to logging in. Any suggestions?
    Message was edited by: Brayton Osgood

    There may be a problem with the banking website and not your system.
    For example Chase has had tons of problems with log ons or downloads using Safari even the newest versions and in both OS 10.3 and 10.4.x. Chase claims that they are not Safari compatible so I and other users had to resort to Netscape. This may not be your problem, but Chase and Apples. If this is the problem then it is clearly lousy support from Chase and your bank, as many other banking sites such as Wells Fargo, BofA and MBNA manage to play well with Safari!

  • ' iframe src="display_file?p_file_id=' || nvl(file_catalog_id,0) || '" / '

    Hi,
    I'm using a file catalog to display a small ifram of each file on one catalog page.
    I added '<iframe src="display_file?p_file_id='||nvl(file_catalog_id,0)||'" />' framepic
    and it displays a PDF in the iframe correctly IF there is only one file.
    If there are 2 files it shows the 1st ones details and then both the iframes in the same row...
    I'm new to iframes so any ideas?
    select FILE_CATALOG_ID,
    FILE_CATALOG_ID "DISPLAY_FILE_ID",
    substr(FILE_NAME,instr(FILE_NAME,'/')+1) "FILE_NAME",
    "DESCRIPTION",
    "UPLOADED_ON",
    "MIME_TYPE",
    '<iframe src="display_file?p_file_id='||nvl(file_catalog_id,0)||'" />' framepic
    from FILE_CATALOG
    Thank you! Bill

    Also
    when I have pictures and use this instead of the iframe it displays a row of detail and the picture for each.
    '<img src="display_file?p_file_id='||nvl(file_catalog_id,0)||'" />' pic
    AND I have the development links to be able to edit the page as normal.
    But, when I use the iframe I lose my dev edit links at the bottom of the page...
    Is this normal?
    :) Bill

  • Iframe src-attribute fails in Safari 3.0.4

    Hey there.
    I have a page with a iframe tag. The src-attribute fails and renders about:blank instead of the given path. I have tried the same page in firefox, where it works just fine, so I don't think the problem is in the code, but in Safari.
    The code that fails looks like this: <iframe src="http://google.com"></iframe>
    - Emil

    I solved the problem my self. The problem is that the prototype library is used like this:
    Event.observe(window, 'load', function(){ initialize(); });
    And this event apparently fires when the iframe loads. So moving the initialize function to the bottom of the page, and running it manually solved the problem of the initialize not firering.
    But the src is still not showing as it shoud. Im working on solving it.

  • Dynamic IFrame

    Hi,
    I'm having a hard time making a Iframe Tag with dynamic request parameters. What I'm looking for is a way to make the following code work:
    <f:verbatim>
       <iframe height="500" id="iframe1" src="RTFCreatorServlet?examNo=#{ExamForm.examParam}"
                                            width="700">
        </iframe>
    </f:verbatim>Unfortunatelly, the jsf container doesn't recognize the EL above because it's within the verbatim tag. I've erased the verbatim tag still nothing happened. Seems to me that there isn't a corresponding JSF tag to the HTML <iframe>. So, what can I do?
    Thanks,
    Tiago.

    I've found a partial solution. SJSC has a component called Markup. It represents a HTML markup tag. I had to setup the tag name (iframe) and the Extra Atributes (src, height and width). But, i'm having other problems now. The page is rendered only once. When I click in the second link, the request parameter doesn't change and it shows the same page always. How can I solve it?

  • Hidden iframe src = servlet with a persistent connection

    Hello all,
    I am messing around with trying to embed a hidden iframe in a jsp and this hidden iframe's src is a servlet that never calls out.close().
    The code for the servlet is as follows:
                while(true)
                   //here I call a random number generator method and then out.print() the results.
                    out.flush();
                    try
                        Thread.sleep(1000);
                    catch(InterruptedException ie){ie.printStackTrace();}
            catch(Exception e){e.printStackTrace();}This all works fine.
    Now I need to grab the results of this endless loop which are currently in an iframe within a jsp and make the iframe hidden and somehow pass the results of this hidden iframe to a div on the jsp. This is the part that I cant get to work.
    Any Ideas?
    TIA!

    why not... ditch the iframe and use Ajax to asynchronously fill your div? Toolkits such as Dojo make this fairly easy and cross-browser:
    http://dojotoolkit.org/

  • How to set iframe src from java dynammically

    Hi,
    Iam calling a servlet from jsp and servlet calls the databse query and returns the value,
    in my jsp i have ifrme, i want to change the source of iframe from java depends on the result from database , and the result must display on the iframe can any one tell me how to do this

    aurelian_cl wrote:
    I need to know how to set environment variables from java
    I want to set from java for example the environment variable "TestVar" with the value "TestValue"!1) That functionality does not belong in an application. You're trying to set environment variables, which are global across all applications, at either the user level as a whole, or across the entire machine (system level). Or, if you're only trying to set a variable active for the current process, you don't need to do that.
    2) Environment variables are not a platform-independent entity, and are thus against the nature of Java.
    My gut feel is that you are designing something in a backwards way, so my point is mainly to point that out, not to try to help you solve that particular problem.

  • Dynamic img src in a JSP

    Hey all
    Nevermind!
    cheers
    Message was edited by:
    syncro

    SeniorProject, don't cross post the same question in multiple forums.
    AnanSmriti: No, that is incorrect. That code is for including jsp pages - NOT images.
    http://forum.java.sun.com/thread.jspa?threadID=721993&messageID=4165741#4165741

  • To dynamically assosciate an iframe with a new managed bean instance

    I have a datatable populated with records.Each row consists of a checkbox and the corresponding row data. I need to select 2 rows to display the same in 2 different iframes rendered in the next page. I have one managed-bean (Display.java) registered in the faces-config.xml in the session scope. But I would like to assosciate each iframe with a different instance of Display.java. Is it possible?

    Now, I have each iframe assosciated with a different instance of managed bean.
    Also the requests are distinguished based on the rowId appended as a
    parameter to the querystring.
    eg:<IFRAME src="display.jsf?rowId=1">.
    The iframes are drawn dynamically based on the no of rows selected.
    But there is a mixup of data, i.e the first row data appears in both the iframes. Is it to do with rendering of iframes? How do i resolve this?

  • Iframe on a symbol created dynamically

    Hello,
    -I have a button that creates a symbol dynamically. That is OK
    -then I move this symbol with TweenMax. That is Ok, I tested it.
    -and finally I want to load into this symbol  an external URL. That doesn't work.
    The problem is, I think, I don"t know how to address this dynamically created symbol.
    This is my code :
    var externalURL ="portfolio/FFD.html";
    var mywrapper = $(sym.createChildSymbol("wrapper","Stage").getSymbolElement());
    var wrapperMove = TweenMax.to(mywrapper,2, {css:{top:"2500", left:"0"},ease:Sine.easeOut} );
    sym.$("mywrapper").html("<iframe src="+externalURL+" height=100% width=100%></iframe>");
    Thanks for any help

    Hi,
    I will try this code:
    var externalURL ="portfolio/FFD.html";
    var mywrapper = sym.createChildSymbol("wrapper","Stage");
    var wrapperMove = TweenMax.to(mywrapper.getSymbolElement(),2, {css:{top:"2500", left:"0"},ease:Sine.easeOut} );
    sym.$("mywrapper").html( '<iframe src='+ externalURL +' height="99%" width="99%"></iframe>' );

Maybe you are looking for

  • Help, no sound, no sound output devices

    Hi all, I tried this over in the Tiger section with little help. About a week ago I told my grand-daughter she could plug her iPod headphones into the headphone jack on the the front of the G4. Now, I have no sound at all except for through the headp

  • How to place a JSlider in the middle of an image?

    Hi, Here is the deal. I have an image inside a JLabel. That JLabel is inside a JPanel, which in turn is encompassed by a JScrollPane. This image represents some curve or a frequency function, lets say for instance a sine curve. What I need to do is h

  • Indesign CS3

    Indesign CS3 is crashing when file> place. Two months back I remedied the problem by uninstalling & reinstalling the entire CS3. Surely there has to be a better way.

  • Get row ID

    How do I get the row id number if a row?

  • J2me http connection error

    Hi, I got null value from my hand set when getting conn.getHeaderField value while my J2ME emulator is working fine. Any one hv a clue on tis.. My snipet of code HttpConnection conn = (HttpConnection)Connector.open("http://61.6.108.195:8001/Frens/tes