0

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?

FrankL
  • 31
  • 3
  • My first suggestion would be (since you use jsf 2.x) is to use implicit navigation. http://stackoverflow.com/questions/18037884/jsf-implicit-vs-explicit-navigation – Kukeltje Aug 08 '15 at 12:33
  • Are you using Jboss AS or Wildfly? JBoss AS only supports JSF 2.1. – Tea Curran Aug 08 '15 at 14:16
  • I'm tried with WildFly 10 which is using JSF 2.2. But older versions show the same effect. – FrankL Oct 19 '15 at 20:22

1 Answers1

1

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

Tea Curran
  • 2,923
  • 2
  • 18
  • 22
  • Problem is, that #{salesOrders.start()} returns the name of the view to start with. Not only used for executing some logic. Depending on configuration the first view might be different. – FrankL Oct 19 '15 at 20:25
  • Why don't you have the index.xhtml call a command link with an action, that action can return the view you want to go to? You wouldn't need anything in your faces-config.xml. A navigation-case with-out a from-action is pretty useless because it will evaluate for every action taken on the from-view-id. – Tea Curran Oct 19 '15 at 20:35