3 Replies Latest reply on Oct 22, 2010 4:20 AM by Shervin Asgari

    Include URL link in Email to trigger Seam Action?

    ginni machamer Newbie

      I am new here. New to Seam, also.

      I need to include a URL link in an automated email notice that will open a specific record in a Seam/JSF web app when clicked.

      So far my approach to this is to add a method openFromLink() to a backing bean.  I am trying this code:

             public String openFromLink() {
                      FacesContext context = FacesContext.getCurrentInstance();
                      Map<String, String> params = context.getExternalContext().getRequestParameterMap();
                      String aid = params.get("aid");
                      // needs to be a Long 
                      try {
                       Long authorizationId = Long.parseLong(aid.trim());
                       System.out.println("long id = " + authorizationId);
                       AbstractAuthorization authorization = authorizationService.getAuthorization(authorizationId);
                       return editAuthorization(authorization);
                  } catch (NumberFormatException nfe) {
                       System.out.println("NumberFormatException: " + nfe.getMessage());
                       return null;

      Then I added an entry for this in pages.xml (under page view-id -equals- -asterisk-):

                     <navigation from-action="#{authorizationListManager.openFromLink}">
                              <rule if-outcome="delegation">
                                      <redirect view-id="/pages/delegation/delegation.xhtml"/>
                              <rule if-outcome="exception">
                                      <redirect view-id="/pages/delegation/exception.xhtml"/>

      Baby steps, obviously.

      I do not know how to invoke this from outside the JSF. 

      If I just type in the URL:


      I get:
      The requested resource (/icams-view/authorizationListManager/openFromLink) is not available.

      This seems like something straightforward, so I hope I am missing something obvious.  Ideas?

      Thank you!

        • 1. Re: Include URL link in Email to trigger Seam Action?
          ginni machamer Newbie

          A little more info:

          I am looking at the Blog example.  I can see how the bookmark concept is implemented here.  How would I modify that approach to just enable the user to run a specific action from the URL link, whereas the same page will be accessed from other actions? I am referring to pages.xml.

          I can add:

                  <rewrite pattern="/delegation/{authId}" />
                  <rewrite pattern="/delegation" />
                  <param name="authId" 
                  <action execute="#{fromLinkAction.loadAuthorization(authorization.id)}"/>

          to the node:

          <page view-id="/pages/delegation/delegation.xhtml">

          but won't that affect ANY interaction with the delegation.xhtml page?

          We have other actions triggered from pages that also load these records into delegation.xhtml. Will this approach not break them if no authorization object is passed in?


          • 2. Re: Include URL link in Email to trigger Seam Action?
            ginni machamer Newbie

            And a little more info.  I added:

               <rewrite pattern="/delegation/{authId}" />
                    <rewrite pattern="/delegation" />
                    <param name="authId" 
                    <action execute="#{fromLinkAction.loadAuthorization(authorization.id)}"

            Which does allow me to open a delegation from my list page and to create a new one (both cases use the delegation.xhtml page for display).

            But... if I just try the url:

            The existing record should open, but instead I get an error (browser only, nothing in the console) that states The requested resource (/icams-view/seam/pages/delegation/delegation.xhtml) is not available.

            I cannot see what is going on otherwise.  Is anything obvious here?

            Thanks, Ginni

            • 3. Re: Include URL link in Email to trigger Seam Action?
              Shervin Asgari Master

              Just a wild shot.
              Have you tried .seam at the end instead of .xhtml?