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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:50:17+00:00 2026-06-11T22:50:17+00:00

So, I’m currently working with JSF trying to create a simple project that takes

  • 0

So, I’m currently working with JSF trying to create a simple project that takes input from a JSF inputText field, does something to it, and then spits it back out. Unfortunately i’ve reached an infuriating roadblock when trying to pull data from the inputText field. Whenever I attempt to pull from this field, it always returns null, even though there is obviously data in the field. Also, whenever I pull data from this inputText field, the field goes blank. Help with this issue would be greatly appreciated. Here is my code:

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>Title</title>
</h:head>
<h:body>
    <h:inputText id="username" required="true"
                 binding="#{mBean.searchField}" />
    <h:button onclick="#{mBean.pull()}"/>
    <script type="text/javascript" language="javascript">
        function doThing(i){
            document.getElementById('myDiv').innerHTML = i;
        }
    </script>
    <button onclick="alert('clicked')" onmouseup="doThing('#{mBean.value}')">display</button><br/>
    <div id="myDiv"></div>
</h:body>

and then the backend managed bean is as follows:

package bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UIInput;

@ManagedBean
@RequestScoped
public class MBean {

/**
 * Creates a new instance of MBean
 */
public String value;
public String otherValue;
public UIInput searchField;

public MBean() {
    System.out.println("starting mbean");
}

public String getValue() {
    System.out.println("returning first value " + value);
    return value;
}

public void setValue(String v) {
    this.value = v;
    System.out.println("setting value to " + v);
}
public void report(){
    System.out.print("SUBMIT----");
    System.out.println("value: " + value);
    System.out.println("otherValue: " + otherValue);
}
public String getOtherValue() {
    System.out.println("got " + otherValue);
    return otherValue;
}
public void pull(){
    value = (String)searchField.getValue();
    System.out.println("pulled value is " + value);
}
public void setOtherValue(String otherValue) {
    this.otherValue = otherValue;
    System.out.println("otherValue was set to " + otherValue);
}

public UIInput getSearchField() {
    return searchField;
}

public void setSearchField(UIInput searchField) {
    this.searchField = searchField;
}

}

I’ve been pulling my hair trying to figure this out for hours, so any help is very welcome. Thanks in advance,

-Paul

  • 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-11T22:50:18+00:00Added an answer on June 11, 2026 at 10:50 pm

    Try:

     <h:inputText id="username" required="true" immediate="true"
                      binding="#{mBean.searchField}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.