This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes Not getting the Edited Value of InputText when creating editable DataTable on server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Not getting the Edited Value of InputText when creating editable DataTable on server" Watch "Not getting the Edited Value of InputText when creating editable DataTable on server" New topic
Author

Not getting the Edited Value of InputText when creating editable DataTable on server

Hemant
Greenhorn

Joined: Dec 10, 2007
Posts: 4
Hello All,

I want to show a dynamic editable dataTable on Page. So, I am creating the dataTable on server and displaying it on page. It is working fine for me.My dataTable have some editable Cells with InputText in it. I have Added HtmlAjaxSupport onChange event of it, and ajax method is getting called properly, but I am not getting the changed value of that InputText in that Ajax call.

This is how my code looks :-
HtmlPanelGrid testGrid = new HtmlPanelGrid();
List<UIComponent> testComponentUI = testGrid .getChildren();

HtmlDataTable productTable = new HtmlDataTable();
productTable.setId("testTable" + productCount);
productTable.setVar("testTable");
productTable.setValue(groupedProducts);

HtmlInputText attribComponentType = new HtmlInputText();

// Add Ajax Support for onChange event
HtmlAjaxSupport ajaxSupport = new HtmlAjaxSupport();
ajaxSupport.setId("attribute_" + i + "_" + attribCount);
MethodExpression action = FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createMethodExpression( FacesContext.getCurrentInstance().getELContext(), "#{placeOrderManager.getItemTotalPrice(testTable)}", String.class, new Class[] {});
ajaxSupport.setActionExpression(action);
ajaxSupport.setEvent("onchange");
ajaxSupport.setReRender("testTable" + productCount); attribComponentType.getFacets().put("a4jsupport", ajaxSupport);

ValueExpression valueExpression = createValueExpression("#{productTable.testList[" + count + "].orderAttributeValue}", String.class);
attribComponentType.setValueExpression("value",
valueExpression);
attributeColumn.getChildren().add(attribComponentType);

productComponentUI.add(productTable);// Add datTable to panelGrid

And my xhtml is like this,

<h:panelGrid id="demoGrid" binding="#{testGridAction.testGrid}" />

When I am changing the any InputText value of my dataTable to Ajax method get called, but when I inspect the the bean, I am not getting the changed value for that inputText variable.

Can anyone please guide me here, what am I missing?

Thanks


Hemant
Greenhorn

Joined: Dec 10, 2007
Posts: 4
I got the solution for it!!!

I haven't given the id for the inputText ffield.
I just added
attribComponentType.setId("textInput_" + idCnt + "_" + attribCount);

and it is working fine javascript:%20x()
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not getting the Edited Value of InputText when creating editable DataTable on server
 
Similar Threads
Not able to submit datatable
setAction Problem HtmlCommandButton
java.lang.NumberFormatException: For input string
Multiple Data Tables
Dynamic JSF, programatically adding components