Hello Guys,
I have been bumping my head against the wall on this issue. I appreciate any insights...
I have a InputText within a DataTable. When user clicks on "Add New Row" commandButton, it calls ActionListener which calls a method in BackingBean to add a new empty row to the table. Once the new row is created on the web page, the user enters the data in the row and clicks on "Save" which triggers an action call to the backing bean, which for some reason does not retrieve the user entered data. Please see below on code and appreciate any help I can get to resolve this issue.
Thanks in advance. Looking forward to your response anxiously.
Facelets -> content.xhtml
<h:panelGroup>
<t:dataTable id="foodTable" border="1" styleClass="tableStyle"
value="#{foodBean.foodItems}" var="food"
headerClass="tableHeader" rowClasses="tableRow">
<t:column>
<f:facet name="header" id="h1">
<t:outputText value="Item" />
</f:facet>
<t:inputText id="itemId" size="10" styleClass="inputTextClass"
value="#{food.item}" />
</t:column>
<t:column>
<f:facet name="header" id="h2">
<t:outputText value="Calories" />
</f:facet>
<t:inputText id="caloriesId" size="4" value="#{food.calories}" />
</t:column>
<t:column>
<f:facet name="header" id="h3">
<t:outputText value="Fat(Calories)" />
</f:facet>
<t:inputText id="fatCaloriesId" size="4"
value="#{food.fatCalories}" />
</t:column>
<t:column>
<f:facet name="header" id="h4">
<t:outputText value="Portion" />
</f:facet>
<t:inputText id="portionId" size="2" value="#{food.portion}" />
</t:column>
</t:dataTable>
<h:commandButton value="Add Food Items" type="submit"
actionListener="#{foodBean.addItem}"/>
<h:outputText value=" " />
<h:commandButton value="Save Food Items" type="submit"
action="#{foodBean.executeFoodData}" />
<h:outputText value=" " />
</h:panelGroup>
Backing Bean action method called by "Save" commandButton:
public
String executeFoodData() {
log.debug("executeFoodData() with foodItems size of "
+ foodItems.size());
Iterator<Food> f = foodItems.iterator();
while (f.hasNext()) {
Food fd = f.next();
log.debug("food Items is " + fd.getItem() + " With Calories "
+ fd.getCalories());
}
foodService.storeFoodDateAll(foodItems);
return Constants.SUCCESS;
}