Win a copy of Spring in Action (5th edition) this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Please Help : Problem getting submitted value for dynamic input text field  RSS feed

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am adding, dynamically, text field when a value is selected from a (static)dropdown. There are other static fields in the JSF/JSP page too.

My problem is : On pressing a command button, in my action method, i am not able to get the user-entered value of the dynamic text field. I am able to get the values from the static fields.

I create the dynamic text field by creating a Panel and adding the HtmlInput text field in my managed bean. I then do a Value binding for this field. I bind it to a variable in the managed bean. But i am not getting any value of this variable. PLEASE HELP.

here is the code :
<h:panelGrid id="panelgrid1" columns="2">
<h:panelGroup id="panelgroup1" binding="#{TradeDetailsPageBean.groupPanel}">
Here the dynamic input fields will be added.

<div class="field">
<h:selectOneMenu id="filterName" onchange="this.form.submit()" styleClass="formInputs" value="#{TradeDetailsPageBean.filterName}" valueChangeListener="#{TradeDetailsPageBean.setFilterOnChange}">
<f:selectItems value="# TradeDetailsPageBean.availableTradeFilters}"/>

<div class="field">
<span><h:commandButton id="searchButton" action="#{TradeDetailsPageBean.searchDetailsResultsAction}"styleClass="btns" value="Search" />

Backing bean code:
private String textVal; // the String attached to the dynamic input field

public String getTextVal()
return textVal;
public void setTextVal(String textVal)
this.textVal = textVal;

public void setFilterOnChange(ValueChangeEvent valChangeEvent)
String filterName = (String) valChangeEvent.getNewValue();

private void populatePanel(String filterName)
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
FilterTO fltTO = (FilterTO) htAvailableTradeFilters.get(filterName);
List rules = fltTO.getRules();


if(rules != null) {
for(int i = 0; i < rules.size();i++)
FilterRuleTO fltRule = (FilterRuleTO)rules.get(i);
String valueType = fltRule.getValueType();
if(valueType != null && valueType.equalsIgnoreCase("prompt"))
UIOutput label = new UIOutput();

//UIInput inputText = new UIInput();
HtmlInputText inputText = new HtmlInputText();
ValueBinding inputValBind = application.createValueBinding("#{TradeDetailsPageBean.textVal}");

public String searchDetailsResultsAction()
System.out.println("The input text field entered value is "+textVal+" hello "+getTextVal()); // This is coming as null
Posts: 19972
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Welcome to the JavaRanch!

Our Naming Policy requires that your display name not be a single word. If you could change it to "Prashant Kumar" (as 2 words), we'd really appreciate it.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!