Reputation: 31
I'm using JBoss AS / WildFly with JSF 2.2. This is an example of my faces-config.xml file. From outcome of my starting page (the menu page) I want to call the next one, to-view-id uses EL.
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<!-- Sales -->
<navigation-case>
<from-outcome>AUFTRAGSSUCHE</from-outcome>
<to-view-id>#{salesOrders.start()}</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>AUFTRAGSERFASSUNG</from-outcome>
<to-view-id>#{salesOrderEntry.start()}</to-view-id>
</navigation-case>
</navigation-rule>
Works, but problem is, that user chose AUFTRAGSERFASSUNG the EL for all cases before, here only AUFTRAGSSUCHE get evaluated. Although the from-outcome is different. In reality the list of navigation-cases is much longer. If user chose to start the last entry, all others before get evaluated. Means the beans get instantiated, ... Not a lightweight thing. So you can feel the difference, first menu entries start fast, last ones very slow.
Why are those EL expressions evaluated? Do I have a chance to switch this off? Any other hint how to improve this?
Upvotes: 0
Views: 548
Reputation: 2983
Reading the mojorra 2.2 source, it is clear that the to-view-id gets evaluated no matter the from-outcome as you observed. There is no way to configure it otherwise.
Why is the el-expression there in the first place? Are you doing some action and then returning the view id?
A better way to do it might be to use a view action:
<navigation-rule>
<from-view-id>/index.xhtml</from-view-id>
<!-- Sales -->
<navigation-case>
<from-outcome>AUFTRAGSSUCHE</from-outcome>
<to-view-id>/sales-order/start.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
And then in /sales-order/start.xhtml do this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h=" "
xmlns:f=" ">
<f:metadata>
<f:viewAction action="#{salesOrders.start}"/>
</f:metadata>
<h:head>
<title>Sales Order Start< /title>
</h:head>
<h:body>
<!-- Sales order page here -->
</h:body>
</html>
You would just have salesOrder.start() return void
Upvotes: 1