首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Richfaces弹出窗口中的清除按钮不起作用

Richfaces弹出窗口中的清除按钮不起作用
EN

Stack Overflow用户
提问于 2012-08-21 02:08:35
回答 2查看 1.7K关注 0票数 1

我的按钮代码是:

代码语言:javascript
运行
复制
<h:commandButton value="Clean" action="#{facesBean.cleanFilter()}" >
    <f:ajax execute="@form" render="result id name"/>
</h:commandButton> 

我可以看到它调用了我的操作,我的属性在backbean上是空的,但是我的表单输入没有得到清理。它应该清理两个输入和一个表。表被清理了,但我的输入却没有。

我已经寻找了一些解决方案,但没有运气。

有什么问题吗?

我的弹出窗口有自己的文件popup.xhtml,我通过ui:include使用它。下面是我弹出窗口的代码:

代码语言:javascript
运行
复制
<h:form id="userForm">
    <rich:popupPanel id="popup-user" modal="true" headerClass="popup-header" styleClass="popup" domElementAttachment="form" keepVisualState="true" width="620" autosized="true" top="50">
        <f:facet name="header" >
            <h:outputText value="Search User" />
        </f:facet>
        <f:facet name="controls">
            <h:commandLink>
                <h:graphicImage url="/images/icon-close.png" alt="Close" styleClass="icone-close"/>
                <rich:componentControl target="popup-user" operation="hide" />
            </h:commandLink>
        </f:facet>

        <fieldset>
            <legend class="section">Search User Filter</legend>
            <h:panelGrid styleClass="form" columns="1" cellspacing="0" columnClasses="item">
                <h:panelGroup>
                    <h:outputLabel styleClass="label-form" value="ID" for="id" />
                    <br />
                    <h:inputText id="id" value="#{facesBean.filter.id}" styleClass="textfield" maxlength="8"/>
                </h:panelGroup>
                <h:panelGroup>
                    <h:outputLabel styleClass="label-form" value="Name" for="name" />
                    <br />
                    <h:inputText id="name" value="#{facesBean.filter.name}" styleClass="textfield" />
                </h:panelGroup>
            </h:panelGrid>
        </fieldset>

        <div id="buttons">
            <h:commandButton value="Search" action="#{facesBean.search()}">
                <f:ajax execute="@form" render="result-users" />
            </h:commandButton>
            <h:commandButton value="Clean" action="#{facesBean.clean()}" >
                <f:ajax execute="@form" render="id name result-user"/>
            </h:commandButton> 
        </div>      

        <h:panelGroup id="result-user">
                <rich:dataScroller for="userTable" styleClass="pagination" maxPages="5" boundaryControls="hide" renderIfSinglePage="false" fastControls="hide" stepControls="auto" execute="@form" render="userTable" />
                <rich:dataTable id="userTable" value="#{facesBean.list}" var="user" style="width:600px;" rows="10">
                    <f:facet name="header">
                        <rich:columnGroup>
                            <rich:column styleClass="left" style="width: 5%">
                                <h:outputText value="Action" />
                            </rich:column>
                            <rich:column styleClass="left" style="width: 10%">
                                <h:outputText value="ID" />
                            </rich:column>
                            <rich:column styleClass="left" style="width: 25%">
                                <h:outputText value="Name" />
                            </rich:column>
                            <rich:column styleClass="left" style="width: 25%">
                                <h:outputText value="E-mail" />
                            </rich:column>
                        </rich:columnGroup>
                    </f:facet>

                    <rich:columnGroup>
                        <rich:column>
                            <h:commandButton image="/images/icon-select.png" alt="Select" actionListener="#{mainBean.selectUser(user)}" styleClass="icon-select">
                                <f:ajax execute="@form" render=":form:#{field}" />
                                <rich:componentControl target="popup-user" operation="hide" />
                            </h:commandButton>
                        </rich:column>
                        <rich:column>
                            <h:outputText value="#{user.id}" />
                        </rich:column>
                        <rich:column>
                            <h:outputText value="#{user.name}" />
                        </rich:column>
                        <rich:column>
                            <h:outputText value="#{user.email}" />
                        </rich:column>
                    </rich:columnGroup>
                </rich:dataTable>
            </h:panelGroup>
        </h:panelGroup>
    </rich:popupPanel>
</h:form>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-08-22 03:49:27

在尝试了这么多东西后,我试着把我的输入放在a之间,并改变了我的臀部,它起作用了。

它看起来是这样的:

代码语言:javascript
运行
复制
    <a4j:outputPanel id="search-filter">
     <fieldset>
        <legend class="section">Search User Filter</legend>
        <h:panelGrid styleClass="form" columns="1" cellspacing="0" columnClasses="item">
            <h:panelGroup>
                <h:outputLabel styleClass="label-form" value="ID" for="id" />
                <br />
                <h:inputText id="id" value="#{facesBean.filter.id}" styleClass="textfield" maxlength="8"/>
            </h:panelGroup>
            <h:panelGroup>
                <h:outputLabel styleClass="label-form" value="Name" for="name" />
                <br />
                <h:inputText id="name" value="#{facesBean.filter.name}" styleClass="textfield" />
            </h:panelGroup>
        </h:panelGrid>
    </fieldset>
    </a4j:outputPanel>
    <div id="buttons">
        <h:commandButton value="Search" action="#{facesBean.search()}">
            <f:ajax execute="@form" render="result-users" />
        </h:commandButton>
        <a4j:commandButton value="Clean" action="#{facesBean.clean()}" >
            <f:ajax execute="@form" render="search-filter result-user"/>
        </a4j:commandButton> 
    </div>              
票数 1
EN

Stack Overflow用户

发布于 2012-08-21 15:49:21

感谢您更新您的帖子。我想你有两个选择:

  • 在popupPanel内移动窗体,或
  • 使用rich:popupPanel domElementAttachment=" form“...

为什么会这样呢?非常令人困惑的是,popupPanel在dom中被移为h:body标记的子级。所以你要写这个结构:

代码语言:javascript
运行
复制
<h:body>
  <h:form id="userForm">
    <rich:popupPanel id="popup-user" ...>

它变成了这样:

代码语言:javascript
运行
复制
<body>
  <div id="popup-user"> ...
  <form id="userForm"> ... </form>

问题是popup-user的内容不再是表单。发生这种情况的原因是需要将对话框定位到相对于视口的位置,以及使用css的复杂性。以下是我在研究它为什么会这样工作时为自己写的一些笔记:

对话框使用绝对定位使其在视口中居中。它只是一个使用position: absolute、top: xxpx、left: xxpx和display: none或block的div。对话框占位符中的任何内容都是position: relative,这意味着“我内部的所有定位元素都应该相对于我的位置进行定位”。

仅当div具有绝对位置且未嵌套在任何具有绝对、相对或固定位置的标记中时,它才相对于浏览器窗口定位。否则,它将相对于包含标记进行定位。

因此,为了实现相对于视口的定位,无论您将对话框放在何处(即div),它都将作为body的子级重新定位。因此,即使对话框在表单中,它也会移到表单之外。这就是为什么如果你想要在对话框中有按钮和链接,就必须有它自己的形式。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12042777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档