在JavaServer Faces中导航,并使用正确的参数进行重定向 [英] Navigation in JavaServer Faces, redirecting with correct parameters

查看:80
本文介绍了在JavaServer Faces中导航,并使用正确的参数进行重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面: http://mypage.com/items.jsf .

此页将以下内容视为理所当然:

  • ID由GET设置或ID由POST设置.

现在,我可以手动调用items.jsf?ID = 10

但是我真正想做的是有一个Button,它调用一个返回导航URL的函数.

public String test()
{
    return "10";
}

现在在 JSF 文件中具有以下代码.

    <h:form>
        <h:commandButton action="#{itemsBean.test}" value="Redirect me" />
    </h:form>

我想发生的是,当我按重定向我"时,我希望导航规则知道我要去:items.jsf?ID = 10

这可能吗?感觉确实是个小问题.

解决方案

仅使用核心JSF框架和Facelets库,您可能会发现这很困难. JSF 1.2库不支持将请求参数添加到重定向URL.

想到一些解决方案:

I have a page: http://mypage.com/items.jsf.

This page takes the following for granted:

  • ID is set by GET or ID is set by POST.

Now, I can manually call items.jsf?ID=10

But what I really want to do is have a Button which calls a function that returns the navigation URL.

public String test()
{
    return "10";
}

Now having the following code in the JSF file.

    <h:form>
        <h:commandButton action="#{itemsBean.test}" value="Redirect me" />
    </h:form>

What I want to happen is that when I press "Redirect me", I want a Navigation-Rule to know that I want to go to: items.jsf?ID=10

Is this possible? It feels like it's a trivial problem really.

解决方案

With only the core JSF framework and the Facelets library, you may find this difficult. The JSF 1.2 library does not include support for adding request parameters to the redirect URL.

A few solutions spring to mind:

这篇关于在JavaServer Faces中导航,并使用正确的参数进行重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆