仅在按下按钮时呈现表单

时间:2015-02-23 23:53:48

标签: ajax jsf jsf-2.2

我想弄清楚如何在按下属于不同表单的按钮后呈现表单。我已成功地使用数据表完成此操作没有问题,但这次我需要渲染输入字段。我正在使用最新版本的JSF与netbeans和bootfaces。

有一个名为BookList的bean showAdd的布尔成员,它应该确定是否呈现表单,方法toggleShowAdd()将此值更改为其当前值的相反值。< / p>

从按钮开始查看表单:

<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>

0 个答案:

没有答案