11 Replies Latest reply on Jan 11, 2008 10:47 AM by sammy Jenkis

    Wildcard for pages action

    Bieth Bruno Newbie

      I'd like to use wildcard in the from-action attribute like this :

      <navigation from-action="#{logoEditor.editLogo(*)}">
       <redirect view-id="/logo/edit.xhtml"/>

      So each time I use logoEditor.editLogo whatever the parameter is I'm redirected to edit.xhtml.

      I tried with 1.2.1 GA but it doesn't work. I didn't find anything like that in JIRA as well.


        • 1. Re: Wildcard for pages action
          Monkey Den Master

          Did you try it without the per ens and the star?

          • 2. Re: Wildcard for pages action
            Monkey Den Master

            ....which would be agnostic of the value passed.

            • 3. Re: Wildcard for pages action
              Monkey Den Master

              Sorry for being so noisy, but on second look, that's not a page action. It's a navigation rule. A page action would be:

              <page view-id="/someFile.xhtml" action="#{logoEditor.editLogo(*)"/>

              • 4. Re: Wildcard for pages action
                Bieth Bruno Newbie

                Yes it's a navigation rule.
                Thanks anyway.

                • 5. Re: Wildcard for pages action
                  sammy Jenkis Newbie

                  Is there any interest in this? I also thought this made sense because from-action's that involve parameter names seem a bit brittle.

                  • 6. Re: Wildcard for pages action

                    could you please rephrase your question and maybe give some detailed example?
                    I have no idea what you wanna do...

                    • 7. Re: Wildcard for pages action
                      sammy Jenkis Newbie

                      I'm asking if there's any community interest in supporting wildcards in the from-action in pages.xml.

                      For example:

                      <navigation from-action="#{logoEditor.editLogo(*)}">
                       <redirect view-id="/edit.xhtml"/>

                      <h:commandLink value="LinkOne" action="#{logoEditor.editLogo(goodLogo)}"/>
                      <h:commandLink value="LinkTwo" action="#{logoEditor.editLogo(badLogo)}"/>

                      For this example, both LinkOne and LinkTwo would navigate to /edit.xhtml because both of the actions match the #{logoEditor.editLogo(*)} pattern.

                      In other words, the specific variable names on an action don't matter when the navigation is evaluated because pages.xml specifies a wildcard (*) for the parameters.

                      • 8. Re: Wildcard for pages action
                        Pete Muir Master

                        File a JIRA and try to collect votes for it.

                        • 9. Re: Wildcard for pages action
                          sammy Jenkis Newbie

                          Thanks. JIRA opened: http://jira.jboss.org/jira/browse/JBSEAM-2481

                          Two other quick things on this:
                          1) One thing that surprised me when I first used Seam navigation was that you cannot define navigation cases based on the outcome of an action. I know that rules can operate on outcomes, but I like to define navigation cases based on a known action and then have rules which inspect the state within that case. (Otherwise I get strange behavior where a user can back up and click through a wizard using any links because the state to satisfy the rules in still in the conversation).

                          Here's a code snippet that demonstrates what I mean (in Pages.navigate). Does something like this make sense in general for Seam?

                           Navigation navigation = page.getNavigations().get(actionExpression);
                           if (navigation==null)
                           // New Code here:
                           if (actionOutcomeValue != null) {
                           navigation = page.getNavigations().get(actionOutcomeValue);

                          2) For anyone interested in doing something like this, you can always provide a custom "org.jboss.seam.navigation.pages" component. For example, I have:
                          @Install(precedence=APPLICATION, classDependencies="javax.faces.context.FacesContext")
                          public class Pages extends org.jboss.seam.navigation.Pages {
                           public boolean navigate(FacesContext context, String actionExpression, String actionOutcomeValue) {...}

                          • 10. Re: Wildcard for pages action
                            Pete Muir Master

                            (1) Whats wrong with

                            <navigation from-action="#{foo.bar}">
                             <rule if-outcome="baz">
                             <redirect view-id="/baz.xhtml" />

                            • 11. Re: Wildcard for pages action
                              sammy Jenkis Newbie

                              There's nothing wrong with that.

                              However, it's not possible for me to use from-action as defined by Seam because most of my actions are being passed into facelet components as strings. Inside the facelet component, I execute the action at the right time:


                              This causes a problem with navigation because all of the action expressions look the same!

                              Also, we are designing our actions to be very granular and only expose one execute() method. Action.exeucte() either returns NULL (failure) or it's component name (success). (This seems a lot more simple than asking developers to return different arbitrary outcomes). When an action succeeds and returns it's component name, I will want to be able to conditionally navigate based on the state of the system.

                              For example:

                               <navigation from-action="searchAction">
                               <rule if="#{searchManager.searchResults.size == 1}">
                               <redirect view-id="/showRecord.xhtml" />
                               <rule if="#{searchManager.searchResults.size > 1}">
                               <redirect view-id="/SearchResults.xhtml" />

                              Let me know what you think of all of this and if you see any inherent problems with these approaches.