How to disable jftfdi jffi query params in JSF

拟墨画扇 提交于 2019-11-27 06:20:57

问题


I tried the last version of JavaServer Faces 2.2 (Mojarra 2.2.4) and noticed changing my query string in this unwanted way:

page.jsf?jftfdi=&jffi=

instead of

page.jsf

I've found that it is the new JSF 2.2 feature. But these query params(jftfdi, jffi) spoil me SEO-friendly urls. How can I disable it?


回答1:


This is a bug in Mojarra. They should not have been appended when there's no means of any flow navigation configuration (by the new @FlowScoped annotation and <j:flow-xxx> tags).

Basically, the OutcomeTargetRenderer class who's responsible for HTML output generation of the <h:link> and <h:button> is incorrectly checking if NavigationCase#getToFlowDocumentId() returns non-null before appending the flow navigation parameters. However, based on the javadoc the base implementation never returns null, but an empty string. Therefore, the renderer always thinks that it's in middle of a flow navigation and always appends the associated jftfdi and jffi request parameters. The fix is to let it check as well if it returns a non-empty string.

I reported it as issue 3054 and they confirmed that this is a bug and are currently working on it. The fix will likely be available in Mojarra 2.2.5.

Update: as of now, less than a day later, it's fixed for 2.2.5.


By the way, the jftfdi stands for "javax.faces To Flow Document ID" which is specified as follows in the javadoc:

Components that are rendered by Renderers of component-family javax.faces.OutcomeTarget must use this constant as the parameter name for a parameter representing the defining document id of the flow that this component will cause to be entered.

and the jffi stands for "javax.faces Flow ID" which is specified as follows in the javadoc:

Components that are rendered by Renderers of component-family javax.faces.OutcomeTarget must use this constant as the parameter name for a parameter representing the flow id of the flow that this component will cause to be entered.




回答2:


I had the same error before. The origin of this bug is the version of jsf. Just try to upgrade version to 2.2.5 like this :

    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.5</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.5</version>
    </dependency> 

Hope it's helpfull



来源:https://stackoverflow.com/questions/19255367/how-to-disable-jftfdi-jffi-query-params-in-jsf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!