【问题标题】:h:commandButton's action not being invoked [duplicate]h:commandButton 的操作未被调用 [重复]
【发布时间】:2017-03-07 09:22:43
【问题描述】:

我正在使用 JSF 2.0,并且在 home.xhml 的 div 部分中有一个 commandButton。它不工作。我没有看到destinationPage,只保留在home.xhtml 中。

home.xhmtl:

<div id="left_side">
    <ui:include src="login.xhtml" />
        <h:form>
           <h:commandButton value="register" action="register"/>
        </h:form>
</div>

register.xhtml 在一个 h:body 和一个 h:form 中

还有 faces-config.xml 配置:

<navigation-rule>
    <from-view-id>home.xhtml</from-view-id>
    <navigation-case>
        <from-outcome>register</from-outcome>
        <to-view-id>register.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

【问题讨论】:

    标签: jsf richfaces


    【解决方案1】:

    如果home.xhtmlregister.xhtml 位于应用程序的根目录,则需要定义导航规则如下:

    <navigation-rule>
        <from-view-id>/home.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>register</from-outcome>
            <to-view-id>/register.xhtml</to-view-id>
        </navigation-case>
    </navigation-rule>
    

    否则,您将添加相对于根目录的路径.. 这将由反斜杠指示

    更新

    实际上,在您的情况下,您似乎并不真正需要由commandButton 生成的 POST 请求。一个会生成 GET 请求的简单按钮似乎就足够了:

    <h:button outcome="register" value="register" /> 
    

    【讨论】:

    • 乳清在 webapp(root)/templates.. 所以,我添加了:/templates/home.xhtml/templates/register.xhtml..事情并没有好转..
    • 试试我的更新答案
    • 完成.. 现在它写在注册按钮上:已禁用,因为无法匹配导航案例...faces-config 配置有问题?为什么会这样?
    • 你把它放在哪里了?也请与 web.xml 一起添加内容
    • 我已经添加到 WEB-INF(faces 配置文件)中。还有 web.xml(内容:Faces Servletname> /faces/*Faces Servlet .. Faces Servlet *.faces .. *.xhtmljavax.faces.PROJECT_STAGE开发
    猜你喜欢
    • 1970-01-01
    • 2015-02-14
    • 2012-10-30
    • 2020-03-09
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    相关资源
    最近更新 更多