简体   繁体   中英

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

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 !!!

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. Ie 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 .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM