【问题标题】:CommandButton's action URL depending on the form contentCommandButton 的操作 URL 取决于表单内容
【发布时间】:2012-05-17 05:56:10
【问题描述】:

我正在为我的网络应用做一个简单的搜索引擎,但我遇到了一个问题。

我的search.xhtml 通过获取参数来工作,因此search.xhtml?key=lol 将返回“lol”的结果。

我需要做的是我的搜索命令按钮将重定向做search.xhtml?key=INPUT TEXT CONTENT。

这是我的简单代码:

<div id="searchBox">
        <pou:panel id="searchPanel">                
            <h:form>
                <h:inputText id="searchInput" value="#{dispensaRicercaBean.query}" size="99" maxlength="99"/> <pou:commandButton icon="ui-icon-search" action="ricerca?faces-redirect=true"/>
                <pou:watermark value="Search" for="searchInput"/>
            </h:form>                
        </pou:panel>            
    </div> 

其中dispensaRicercaBean 是@RequestScoped,我的结果页面加载了调用executeQuery(#{request.getParameter('key')) 的数据(一个粗略的例子,实际上存在一些差异)

我该怎么做?

【问题讨论】:

    标签: forms jsf redirect primefaces managed-bean


    【解决方案1】:

    使用纯 HTML &lt;form&gt;

    <form action="ricera.xhtml">
        <h:inputText id="key" size="99" maxlength="99" />
        <pou:watermark value="Search" for="key" />
        <pou:button icon="ui-icon-search" onclick="submit(); return;" />
    </form>                
    

    【讨论】:

      猜你喜欢
      • 2016-11-07
      • 1970-01-01
      • 2013-11-16
      • 2012-09-29
      • 1970-01-01
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多