Pregunta

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

¿Fue útil?

Solución

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.

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top