You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marius Oancea <ma...@yahoo.ca> on 2005/11/01 10:38:33 UTC

JSF and IFRAME

Hi, I want to create a JSF page having an IFRAME on it. I want IFRAME
to be loaded from an action.

I created the following:

In the action I have:
    public String viewContent() {
         HttpServletResponse response =
(HttpServletResponse)facesContext.getExternalContext().getResponse();   
   
        response.setContentType("text/plain");
        ServletOutputStream out;
        try {
          out = response.getOutputStream();
          out.write(("This is a test" +
learnitem.getLearnitemTitle()).getBytes());
          out.flush();
        } catch (Exception e) {
            log.debug("Exception during writing content to iframe", e);
        }
        facesContext.responseComplete();
        return null;
    }


in the XHTML page I have:

    <h:commandLink value="download" action="#{learn.viewContent}"
target="xxxx" />
    <iframe name="xxxx">
    </iframe>



When I press download button the content gets loaded into the iframe
(as expected).

QUESTION: How to get rid of download button? I want to automatically
get the content when master page is loaded.
In a NON JSF application I would do <iframe src="aServlet"></iframe>
but here how do I found what to srite for src to obtain a call to
learn.viewContent() ?

Thanx
  Marius






Re: JSF and IFRAME

Posted by Mike Kienenberger <mk...@gmail.com>.
Marius,

You might take a look at the implementation of
sandbox:graphicImageDynamic.
(org.apache.myfaces.custom.graphicimagedynamic in the sandbox)

The renderer sets up the URL (in your case, the <iframe
src="aServlet"></iframe> stuff) with a custom request parameter, and
then the phase listener intercepts requests with that parameter and
renders out content based on that parameter value.

This seems similar to what you're trying to do, so maybe it'll provide
you with some ideas.

-Mike

On 11/1/05, Marius Oancea <ma...@yahoo.ca> wrote:
> Hi, I want to create a JSF page having an IFRAME on it. I want IFRAME
> to be loaded from an action.
>
> I created the following:
>
> In the action I have:
>     public String viewContent() {
>          HttpServletResponse response =
> (HttpServletResponse)facesContext.getExternalContext().getResponse();
>
>         response.setContentType("text/plain");
>         ServletOutputStream out;
>         try {
>           out = response.getOutputStream();
>           out.write(("This is a test" +
> learnitem.getLearnitemTitle()).getBytes());
>           out.flush();
>         } catch (Exception e) {
>             log.debug("Exception during writing content to iframe", e);
>         }
>         facesContext.responseComplete();
>         return null;
>     }
>
>
> in the XHTML page I have:
>
>     <h:commandLink value="download" action="#{learn.viewContent}"
> target="xxxx" />
>     <iframe name="xxxx">
>     </iframe>
>
>
>
> When I press download button the content gets loaded into the iframe
> (as expected).
>
> QUESTION: How to get rid of download button? I want to automatically
> get the content when master page is loaded.
> In a NON JSF application I would do <iframe src="aServlet"></iframe>
> but here how do I found what to srite for src to obtain a call to
> learn.viewContent() ?
>
> Thanx
>   Marius
>
>
>
>
>
>
>
>