Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:20:52+00:00 2026-06-05T18:20:52+00:00

I have a property in my backing bean that returns html code: public String

  • 0

I have a property in my backing bean that returns html code:

public String getHtmlPrevisualizar() {
    return "<html><head><title></title></head><body>Hello world.</body></html>";
}

What I want to do is show this html code in a iframe. I do this with javascript. This is the xhtml page:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <f:loadBundle basename="resources" var="msg" />
<head>
    <title>#{msg['pageTitle']}</title>
</head>
<body>
<ui:composition template="/WEB-INF/facelets/templates/sqa/plantilla.xhtml">  
    <ui:define name="title">#{msg['pageTitle']}</ui:define>
    <ui:define name="javascript">
        <script type="text/javascript">
            function showPreview() {
                var doc = document.getElementById('iframePreview').contentWindow.document;
                doc.open();
                doc.write('#{nuevoEditarEstructura.htmlPrevisualizar}');
                doc.close();
                return false;
            }
            function showPreview2() {
                var doc = document.getElementById('iframePreview').contentWindow.document;
                doc.open();
                doc.write('<html><head><title></title></head><body>Hello world.</body></html>');
                doc.close();
                return false;
            }
        </script>
    </ui:define>
    <ui:define name="content">
        <h:form>
            <a4j:commandLink value="Preview" styleClass="boton" onclick="showPreview();"/>
            <a4j:commandLink value="Preview2" styleClass="boton" onclick="showPreview2();"/>
            <br/>
            <br/>
            <h:outputText value="#{nuevoEditarEstructura.htmlPrevisualizar}" />
            <br/>
            <br/>
            #{nuevoEditarEstructura.htmlPrevisualizar}
            <br/>
            <br/>
        </h:form>
        <iframe id="iframePreview">
        </iframe>
    </ui:define>  
</ui:composition>
</body>
</html>

There are two commandLinks. The first one gets the html code from the backing bean, the second one has the html code written in a string in javascript. The first commandLink doesn’t work. If I view the source code of the page, the value thas should have returned from the backing bean is empty.

I have printed the value from the property in the backing bean also with this:

        <h:outputText value="#{nuevoEditarEstructura.htmlPrevisualizar}" />
        <br/>
        <br/>
        #{nuevoEditarEstructura.htmlPrevisualizar}

But nothig is shown. I have called getHtmlPrevisualizar() and printed its content in the eclipse console, and it returns the right html code.

I know that there can be some problems with escaped characters and facelets, I was expecting to have to deal with the characters in the html being escaped, but I don’t get anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:20:53+00:00Added an answer on June 5, 2026 at 6:20 pm

    Well, this is embarrassing. The problem was that the backing bean name was misspelled, nothing else. I wish that we could get some kind of warning for this, instead of just silently fail.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a a button that is setting a property to a backing bean
I have the problem that my code isn't triggering the action in my backing
In a few cases, I have a property that needs a backing property for
hi i have property named. public bool ShowLabels{get; set;} and one toolbar menu button
I have a property that can accept different formats as values: format1 - 2
I have a property in a class: public int this[int index] { get {
I have this property value and i need its string value as its being
I have an property in my class that i will make optional. Only probem
I have a simple JSF+RichFaces form with some fields and obviously a backing bean
I have a problem with a binding p:commandButton to a property in a backing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.