1

如何在 dataList 项目链接中使用 PrettyFaces?

<p:dataList value="#{mybean.cities}" var="city">
  <h:link outcome="pretty:goCity">
      TEXT
      <f:param name="city" value="#{city.city}" />
      <f:param name="cityId" value="#{city.id}" />
  </h:link>
</p:dataList>

这是我的漂亮配置:

<url-mapping id="goCity">
    <pattern value="/#{cityId:city.id}/#{city:city.city}" />
    <view-id value="/page.xhtml" />
</url-mapping>

我收到了这个错误:

com.ocpsoft.pretty.PrettyException: PrettyFaces: Exception occurred while processing <goCity:#{city.id}> for URL </144/London>
com.ocpsoft.pretty.faces.beans.ParameterInjector.injectPathParams(ParameterInjector.java:96)
com.ocpsoft.pretty.faces.beans.ParameterInjector.injectParameters(ParameterInjector.java:54)
com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:98)
com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)

javax.el.PropertyNotFoundException: Target Unreachable, identifier 'city' resolved to null
org.apache.el.parser.AstValue.getTarget(AstValue.java:98)
org.apache.el.parser.AstValue.getType(AstValue.java:82)
org.apache.el.ValueExpressionImpl.getType(ValueExpressionImpl.java:176)
com.ocpsoft.pretty.faces.util.FacesElUtils.getExpectedType(FacesElUtils.java:50)
com.ocpsoft.pretty.faces.beans.ParameterInjector.injectPathParams(ParameterInjector.java:79)
com.ocpsoft.pretty.faces.beans.ParameterInjector.injectParameters(ParameterInjector.java:54)
com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:98)
com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:189)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:107)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:110)
4

1 回答 1

1

您的设置看起来绝对正确。看起来<p:dataList>不像<h:dataTable><ui:repeat>在这里工作。

您可以尝试将组件替换为以下内容:

<ul>
  <ui:repeat var="city" value="#{mybean.cities}">
    <li>
      <h:link outcome="pretty:goCity">
        TEXT
        <f:param name="city" value="#{city.city}" />
        <f:param name="cityId" value="#{city.id}" />
      </h:link>
    </li>
  </ui:repeat>
</ul>

<pretty:link>代替<h:link>

<ul>
  <ui:repeat var="city" value="#{mybean.cities}">
    <li>
      <pretty:link mappingId="goCity">
        TEXT
        <f:param name="city" value="#{city.city}" />
        <f:param name="cityId" value="#{city.id}" />
      </pretty:link>
    </li>
  </ui:repeat>
</ul>
于 2012-06-02T08:48:39.323 回答