使用漂亮面孔导航的动态视图ID无效 [英] Dynamic view id using pretty faces navigation refuses to work

查看:156
本文介绍了使用漂亮面孔导航的动态视图ID无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将应用程序从JSF 1.2迁移到JSF 2.1.下面的代码在1.2中起作用. 我正在使用PrettyFaces 3.3.3,MyFaces 2.1.

I am attempting to migrate an application from JSF 1.2 to JSF 2.1. The code below worked in the 1.2. I am using PrettyFaces 3.3.3, MyFaces 2.1.

在pretty-config.xml中:

in pretty-config.xml:

<url-mapping id="seSite">
  <pattern value="/sites/#{seViewChooserBean.urlSiteType}/#{seViewChooserBean.siteId}"/>
  <view-id value="#{seViewChooserBean.getSiteViewId}"/>
</url-mapping>

<url-mapping id="seSiteProps">
  <pattern value="/sites/#{sePropsBean.urlSiteType}/#{sePropsBean.siteId}/properties"/>
  <view-id value="/pages/se/site/props.xhtml"/>
  <action>#{sePropsBean.init}</action>
</url-mapping>

我有一个网址请求: http://example.com/myapp/sites/object /309847 此请求成功匹配URL映射ID"seSite",并在seViewChooserBean上调用了getSiteViewId,并返回结果"pretty:seSiteProps".我已经调试并确认了这一点.供您参考,这是ViewChooserBean.java的Bean代码:

I have a request with URL: http://example.com/myapp/sites/object/309847 This request successfully matches the url mapping id "seSite" and getSiteViewId is invoked on seViewChooserBean and returns the result "pretty:seSiteProps". I have debugged and confirmed this. For your reference this is the bean code for ViewChooserBean.java:

public String getSiteViewId() {

    if (siteType == SiteType.TYPE) {
        // redirect to tag list view
        initSiteBean("seTagListBean", TagListBean.class);
        return "pretty:seTagList";
    }
    else {
        // redirect to site properties view
        initSiteBean("sePropsBean", PropertiesBean.class);
        return "pretty:seSiteProps";
    }
}

在那之后,prettyfaces然后尝试转发到新的视图ID seSiteProps,但是由于(从日志中)漂亮的面孔未映射请求,请继续,"漂亮的面孔没有处理新生成的URL.

After that prettyfaces then attempts to forward to the new view id seSiteProps but the new generated URL is not processed by pretty faces because (from the logs): "Request is not mapped using PrettyFaces. Continue."

所以我收到URL http://://example.com/myapp/sites/object/309847/properties的404响应.

So I get 404 response for URL http:://example.com/myapp/sites/object/309847/properties.

请注意,此URL与查看ID seSiteProps匹配.

Note that this url match to view id seSiteProps.

我已经将其调试到漂亮的面孔过滤器中,并发现了以下内容:

I have debugged this up into the pretty faces filter and discovered the following:

在最初请求 http://example.com/myapp/sites/object/309847之后,调用DynaviewEngine.processDynaView并生成正确的目标网址http :://example.com/sites/object/309847/properties并通过faces请求转发.

After the initial request for http://example.com/myapp/sites/object/309847, the DynaviewEngine.processDynaView is invoked and generates the correct target url http:://example.com/sites/object/309847/properties and forwards via faces request.

然后,在PrettyFilter.doFilter()中使用断点,观察到以下情况: 在PrettyFilter.doFilter()方法中:isUrlMappingForward(req)返回false,因此prettyfaces不会处理请求.为什么?

Then, with a breakpoint in PrettyFilter.doFilter() I observed the following: In PrettyFilter.doFilter() method: isUrlMappingForward(req) returns false, therefore request is not processed by prettyfaces. Why??

// isUrlMappingForward returns false.  The request has url http:://example.com/myapp/sites/object/309847/properties on it.
if (!isUrlMappingForward(req))
{
  mapping = getConfig().getMappingForUrl(url);
}

此外,请注意,如果我将请求http://://example.com/myapp/sites/object/309847/properties直接放在浏览器中,则页面由prettyfaces处理,并且isUrlMappingForward(req)返回true并加载在浏览器中正确显示.

Also, note that if I put the request http:://example.com/myapp/sites/object/309847/properties directly in the browser the page IS processed by prettyfaces and isUrlMappingForward(req) returns true and it loads correctly in the browser.

我想我在这里错过了一些明显的事情,因为据我所知,该问题尚未在其他地方得到报道.任何帮助是极大的赞赏.谢谢. 布雷特(Brett)

I was thinking I've missed something obvious here as the problem hasn't been reported elsewhere as far as I can tell. Any help is greatly appreciated. Thanks. Brett

推荐答案

实际上,我很惊奇地发现从dynaview方法返回PrettyFaces导航字符串曾经奏效.这没有记录在任何地方,我怀疑是否已经过详细测试.因此,基本上,您以非常奇怪的方式使用dynaview功能.

Actually I'm very surprised that returning PrettyFaces navigation strings from dynaview methods ever worked. This isn't documented anywhere and I doubt that this has been tested in detail. So basically you are using the dynaview feature in an very weird way.

因此,我建议返回简单的JSF视图ID,这应该可以正常工作.有关详细信息,请参见文档:

So I recommend to return plain JSF view IDs instead which should work fine. See the documentation for details:

http://ocpsoft. org/docs/prettyfaces/3.3.3/zh-CN/html/Configuration.html#config.dynaview

这篇关于使用漂亮面孔导航的动态视图ID无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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