开发者

Unwanted parameters in URL after s:link and f:param

Here is the code (Seam 2, JSF 1.2)

<s:link style="color: white;" value="Full Listing "
    rendered="#{not listControl.fullList}"
    action="#{listControl.setFullList(true)}" >
    <f:param name="maxResults" value="" />
    <f:param name="firstResult" value="" />
</s:link>

<s:link style="color: white;" value="Limited Listing "
    rendered="#{listControl.fullList}" 
    action="开发者_高级运维#{listControl.setFullList(false)}" >
    <f:param name="maxResults" value="#{entityMaxResult}" />
    <f:param name="firstResult" value="" />
</s:link>

The goal is to use this link to toggle between a results listing displayin maxResults and all results.

The original URL is this

_http://localhost:8080/ond/ONDList.seam?maxResults=2&state=DE

When I click the link I get the correct functionality, but the resulting URL is this

_http://localhost:8080/ond/ONDList.seam?state=DE&actionMethod=pages%2Flist%2FONDList.xhtml%3AlistControl.setFullList%28true%29

And I click again I get

_http://localhost:8080/ond/ONDList.seam?maxResults=2&state=DE&actionMethod=pages%2Flist%2FONDList.xhtml%3AlistControl.setFullList%28false%29

What I was expecting to get was simply these 2 URLs:

_http://localhost:8080/ond/ONDList.seam?maxResults=15&firstResult=0&state=AL

and

_http://localhost:8080/ond/ONDList.seam?state=AL

Where do the extra parameters on those URLs come from?


Since s:link is using http GET and not http POST, then seam needs to somehow know which action to invoke. Thus it appends the action in the request parameter.

If you want to avoid seeing anything in the request parameter, then you have to use a link that produces http post such as <h:commandLink>

However, I don't see any reason why you would want to hide the action. If you are afraid of request forgery you can enforce the action by using the @Restrict or @Permission annotation on the component or method.


That's correct. Because you have an action parameter in s:seam. The action will be executed in backend, and then page navigation rules will be evaluated.

Maybe you want to use a h:outputLink?


You may use URL rewrite filter to make URLs look nicer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜