my problem is following: i have a accordionPanel with different tabs. And in one tab there is a dropdown, an input and a commandButton. And when user add something by clicking the button, an item is added to an list which should be displayed in the datatable above. And above there should be rendered another Inputfield and another button.
With JSF it worked fine, but the <h:commandButton/>
updates the whole accordionpanel, closes the current and opens the first. The <p:commandButton/>
was "ok" first, but it did not update anything, or the identifier was not found.
Now I even get a NullPointerException because the button triggers obviously automatically on pageload. I don't know the error. I have tried several thing, but nothing works. Can anyone help?
<p:accordionPanel id="tabPanel" header="Lebensmittel" multiple="true">
<p:tab title="Neue Mahlzeit erstellen">
<h:form>
<h:outputText value="Neue Mahlzeit erstellen: "/>
<br/>
<p:selectOneMenu value="#{kcalModel.grocPrototype}">
<f:converter binding="#{kcalModel.grocProtoConverter}"/>
<f:selectItem itemLabel="Bitte auswählen.." itemValue="" />
<f:selectItems value="#{kcalModel.grocPrototypes}" var="groc" itemValue="#{groc.name}"
itemLabel="#{groc.name}"/>
</p:selectOneMenu>
<!--<h:inputText value="#{kcalModel.amount}"/> Gramm-->
<p:inputNumber value="#{kcalModel.amount}" size="5"/> Gramm
<p:commandButton value="+ zu neuer Mahlzeit hinzufügen" process="@form" update="form:meal" action="#{kcalModel.addGroceryToMeal()}"/>
</h:form>
<h:form id="meal">
<p:fragment>
<p:autoUpdate />
<h:dataTable id="grocs" value="#{kcalModel.meal.groceries}" var="groc">
<h:column>
<h:outputText value="#{groc.name}"/>
</h:column>
<h:column>
<h:outputText value="#{groc.volumeInGramm}"/>
</h:column>
</h:dataTable>
<h:inputText id="titel" value="#{kcalModel.meal.title}" pt:placeholder="Bezeichnung" required="true"
requiredMessage="Bezeichnung fehlt." rendered="#{kcalModel.meal.groceries.size() > 0}">
<h:message for="titel" style="color:indianred"/>
</h:inputText>
<h:selectOneMenu value="#{kcalModel.meal.mealType}" rendered="#{kcalModel.meal.groceries.size() > 0}">
<f:selectItem itemLabel="Bitte auswählen.." itemValue="" />
<f:selectItems value="#{kcalModel.mealTypes}" var="type" itemValue="#{type}"
itemLabel="#{type.toString()}"/>
</h:selectOneMenu>
<h:commandButton value="neue Mahlzeit erstellen" action="#{kcalModel.createMeal()}"
rendered="#{kcalModel.meal.groceries.size() > 0}"/>
</p:fragment>
</h:form>
</p:tab>
<p:tab title="Benutzerdefinierte Mahlzeiten" rendered="#{kcalModel.userDefinedMeals.size() > 0}">
<h:form>
<p:selectOneMenu value="#{kcalModel.meal}" rendered="#{kcalModel.userDefinedMeals.size() > 0}">
<f:selectItems value="#{kcalModel.userDefinedMeals}" var="uMeal" itemValue="#{uMeal}" itemLabel="#{uMeal.title}"/>
<f:converter binding="#{kcalModel.mealConverter}"/>
</p:selectOneMenu>
<p:commandButton value="+ Mahlzeit hinzufügen" action="#{kcalModel.addMeal()}"
rendered="#{kcalModel.userDefinedMeals.size() > 0}" update=":revenue, :kcals"/>
</h:form>
</p:tab>
</p:accordionPanel>