aspose file tools*
The moose likes JSF and the fly likes Please Help : Problem getting submitted value for dynamic input text field    Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Please Help : Problem getting submitted value for dynamic input text field    " Watch "Please Help : Problem getting submitted value for dynamic input text field    " New topic
Author

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

PrashantKumar
Greenhorn

Joined: May 03, 2006
Posts: 2
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 :
JSP
<h:panelGrid id="panelgrid1" columns="2">
<h:panelGroup id="panelgroup1" binding="#{TradeDetailsPageBean.groupPanel}">
...............
....................
Here the dynamic input fields will be added.
</h:panelGroup>
</h:panelGrid>

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

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


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();
setFilterName(filterName);
setTradeFilter(getSelectedFilter());
populatePanel(filterName);
FacesContext.getCurrentInstance().renderResponse();
}

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

groupPanel.getChildren().clear();
groupPanel.setRendered(true);

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();
label.setValue(fltRule.getSubject()+"?");
groupPanel.getChildren().add(label);

//UIInput inputText = new UIInput();
HtmlInputText inputText = new HtmlInputText();
inputText.setId(fltRule.getSubject());
//inputText.encodeEnd(facesContext);
inputText.saveState(facesContext);
inputText.getAttributes().put("styleClass","formInputs");
ValueBinding inputValBind = application.createValueBinding("#{TradeDetailsPageBean.textVal}");
inputText.setValueBinding("value"+i,inputValBind);
groupPanel.getChildren().add(inputText);
}
}
}

public String searchDetailsResultsAction()
{
System.out.println("The input text field entered value is "+textVal+" hello "+getTextVal()); // This is coming as null
}
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

"PrashantKumar"

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Don't get me started about those stupid light bulbs.
 
subject: Please Help : Problem getting submitted value for dynamic input text field
 
Similar Threads
Dynamic t:dataTable display oddness.
Difference Between JSF request and HttpServletRequest and how do you retreive parameters from them
JSF ValueChange problems and Default method where the form submits to
Add component on a button click
Clearing forms