I am trying to figure out how to render a form after pressing a button that is part of a different form. I have successfully done this with datatables with no problem but I need to render input fields this time. I am using the latest version of JSF with netbeans and bootfaces.
There is a boolean member of the bean BookList
called showAdd
which should determine if the form is rendered and the method toggleShowAdd()
changes this value to the opposite of its current value.
Starting from the button to view the form:
<h:commandButton action="#{bookList.toggleShowAdd}"
value="Add to Inventory">
<f:ajax render=":addForm" />
</h:commandButton>
</h:form>
<h:form id="addForm" rendered="#{bookList.showAdd}">
<b:row>
<b:column span="1">ISBN:</b:column>
<b:column span="1">
<h:inputText binding="#{isbn}" />
</b:column>
</b:row>
<b:row>
<b:column span="1">Title:</b:column>
<b:column span="1">
<h:inputText binding="#{title}" />
</b:column>
</b:row>
<b:row>
<b:column span="1">Author:</b:column>
<b:column span="1">
<h:inputText binding="#{author}"/>
</b:column>
</b:row>
<b:row>
<b:column span="1">Price:</b:column>
<b:column span="1">
<h:inputText binding="#{price}" />
</b:column>
</b:row>
<b:row>
<b:column span="1">
<h:commandButton value="Add"
action="#{bookList.addToInventory(isbn, title, author, price)}">
<f:ajax render="@form :inventoryview" />
</h:commandButton>
</b:column>
</b:row>
</h:form>