JSF faces-config.xml with external navigation-rules *.xml file

ぃ、小莉子 提交于 2019-12-24 01:44:53

问题


I have my faces-config.xml with a lot of navigation-rules inside, so I was wondering if there's a chance to write an external xml with navigation rules only, and import that nav-rules.xml into faces-config.xml.

I would like to keep well structured my faces-config, because a lot of navigation rules made it too long.

Thank you in advance !!!


回答1:


Yes, it's possible to split webapp's own /WEB-INF/faces-config.xml file's contents over multiple files. You only need to alter the web.xml to specify the javax.faces.CONFIG_FILES context parameter with comma separated webcontent-relative paths to all external files:

<context-param>
    <param-name>javax.faces.application.CONFIG_FILES</param-name>
    <param-value>/WEB-INF/navigation-config.xml</param-value>
</context-param>

Alternatively, if you're already on JSF 2.x, then you could also get rid of all navigation cases altogether by utilizing the JSF 2.0 new implicit navigation feature. I.e. just make the from-outcome exactly the same as to-view-id as in return "/result.xhtml"; or return "/result"; instead of return "success";. This way the whole navigation case becomes superflous and can be removed from faces-config.xml.




回答2:


Multiple faces-config.xml file can be collated at runtime. So, you can create a faces-config.xml file and store it in the META-INF/faces-config.xml file in some jar and it will get picked up at runtime.

What portions of the original file, you decide to put in it is up to you.



来源:https://stackoverflow.com/questions/19277637/jsf-faces-config-xml-with-external-navigation-rules-xml-file

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