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 8908169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:06:39+00:00 2026-06-15T03:06:39+00:00

In my Facelets page I have a <div> and that contains some input text

  • 0

In my Facelets page I have a <div> and that contains some input text boxes for user to enter values to submit. I will generate the PDF using this HTML source.

<div id="wrapper">
    <h:form prependId="false">
        <h:inputHidden id="source" value="#{bean.source}" />
        <h:inputText id="fName" value="#{bean.firstName}"/>
        <h:inputText id="lName" value="#{bean.lastName}"/>
        <h:inputText id="age" value="#{bean.age}"/>
    </h:form>
</div>

Like this I have other form fields too. When user enters all the data in the form and click on submit button I am getting the source inside this <div> using JavaScript.

function getHtml() {
    document.getElementById('source').value = document.getElementById('wrapper').innerHTML;
}

And passing to bean on click of submit.

<h:commandButton type="submit" id="appl-submit" action="#{bean.submit}"
                 value="Submit" onclick="javascript:getHtml();"/>

In the backing bean class

@ManagedBean
@SessionScoped
public class Bean{

    private String firstName;
    private String lastName;
    private int age;
    private String source;

    // Getters and setters for all properties.
}

But I am only getting the form with empty input fields instead of HTML source along with user entered values. How can I get the HTML source along with form values?

  • 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-15T03:06:42+00:00Added an answer on June 15, 2026 at 3:06 am

    But I am only getting the form with empty input fields instead of HTML source along with user entered values.

    That’s expected behaviour. This approach works only if you’ve already submitted the form and are thus redisplaying the submitted form (as kind of confirmation or so).


    How can I get the HTML source along with form values?

    That’s already answered in your previous question which you never gave feedback on: Get the URL of current XHTML page which has user data filled in the form into the JSF Managed bean. In your particular case, that can even be done simpler as you’ve apparently a session scoped bean already (which is however still bad design as the same page in multiple browser windows/tabs in the same session may interfere with each other):

    public void submit() throws IOException {
        ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
        HttpServletRequest request = (HttpServletRequest) externalContext.getRequest();
        HttpSession session = (HttpSession) externalContext.getSession(true);
        String url = request.getRequestURL().append(";jsessionid=").append(session.getId()).toString();
    
        Document doc = Jsoup.connect(url).get();
        String html = doc.select("#wrapper").html();
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a facelets page with a ui:repeat tag that outputs the rows of
I have created a JSF 2 page which uses Facelets to define the structure
I have a Facelets Composite component that includes, among other things, a commandButton: <?xml
I have a problem with my facelets: I constricted a nav part that displays
I have created a custom facelets component and I need to set some value
In my .xhtml page, I have the following form: <ui:composition xmlns:ui=http://java.sun.com/jsf/facelets template=./../template/CustomerTemplate.xhtml xmlns:h=http://java.sun.com/jsf/html xmlns:f=http://java.sun.com/jsf/core
I'm having some trouble with navigation when using Facelets. I have my master template
I have seen examples of creating a Facelets page template where each defined region
I have main page that looks like this: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html
I have a combo box(drop down list) and a text field on the page.

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.