I would like to use view parameters to get bookmarkable URLs with JSF 2, but I use JSPs and all the help and examples I can find, uses facelets. Here is want I have done so far:

search.jsp (calling page):

  <t:commandLink action="...">
      <f:param name="param1" value="foo"/>
      <h:outputText value="..."/>                  
  </t:commandLink>

faces-config.xml:

  <navigation-rule>
    <navigation-case>
      <from-outcome>go_edit</from-outcome>
      <to-view-id>/views/edit.jsp</to-view-id>
      <redirect>
        <view-param>
          <name>param1</name>
          <value>#{edit.param1}</value>
        </view-param>
      </redirect>
    </navigation-case>
  </navigation-rule>

Edit.java (edit page backing bean):

public class Edit extends ... {

  private String param1;

  public String getParam1(){
    return param1;
  }

  public void setParam1(String param1){
    this.param1 = param1;
  }

  ...
}

I think the problem is, that I didn't add the view params to the edit page (e.g. edit.jsp). I only found facelet examples, which look like this:

<f:metadata>
    <f:viewParam name="id" value="#{bean.id}" />
</f:metadata>

My question is, can I use JSP view params? Can someone provide or point me to an complete example? Especially the part with the target page (e.g. edit.jsp).

有帮助吗?

解决方案

This isn't possible. JSP is deprecated since JSF 2.0 in December 2009 (almost 4 years ago already!). All new JSF 2.x specific tags are available to Facelets only and not to JSP. Basically, with JSP you've only JSF 1.x specific tags available. In other words, the JSF 2.x tags <f:metadata>, <f:viewParam>, <f:ajax>, <h:head>, <h:outputScript>, etc are not available to JSP.

There's no point working with deprecated technology. It's high time to migrate.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top