2 Replies Latest reply on Sep 7, 2010 5:45 AM by Sergey Vidyuk

    How to provide link back to my application in email

    Sergey Vidyuk Newbie

      I'm implementing periodical events which provides some background changes and notify users affected by those changes. I need to provide links to the parts of the system. For example if class is going to start on the next week all student of this class should get notification with the link to the lessons timetable.


      I have two issues which I don't know how to handle in a good way.


      1. First of all I need to store base URL (like http://hostname/appname). What is the best practice to get this information from the asyncronyous event?


      2. How can I calculate relative URL to the view. If I have view /class/view.xhtml in working system by default it will be accessed like /class/view.seam but there are a lot of ways to reconfigure this behavior. Are there any equivalent to django {% url %} tag?


      Since s:link doesn't work in emails I don't know how to handle this two issues in a good way without ugly kludges. Can somebody give an advise of best way to handle this situation?

        • 1. Re: How to provide link back to my application in email
          Marcio Dantas Newbie

          1) You can declare a factory in your components.xml with the base url.
          Are you using Maven? If you are, then you could set the factory value depending on the used profile (development, production, ...).


          2) I didn't understand very well.. Are you concerned with the configurable extension .seam, .faces, .jsf?
          You could use (again) a factory to get this.


          3)
          In the e-mail body, you will have something like http://hostname/appname/login.seam?user=userId&nextOutcome=timeTable


          When the link is clicked, the user goes to a login page. Once authenticated, the application would use the nextOutcome parameter to know which view the user intends to go after login.


          Got the idea? This is a way to do it.


          best regards.

          • 2. Re: How to provide link back to my application in email
            Sergey Vidyuk Newbie

            No I'm not using maven. I've added property containing base url to the seam.properties and mapped it to one application scope component which holds all logical constants of my application. But I still interested in other solution used by other people maybe there are more elegant and flexible solutions.


            Abut the 2nd issue: By default if I have some view like {project-root}/view/qwe/rty.xhtml I can access it by url qwe/rty.seam. It's simple to change suffix so the url to access this page will turn into qwe/rty.asd or something like this. At the same time one might add {project-root}/view/qwe/rty.page.xml and specify url rewriting so this page can be accessed only by something/meaningful url. There are several ways to change which url is used to access this certain page.


            In my mail templates I'm using h:otputLink to generate link back to the system and I need to track such changes manually. It's not reliable way. You suggestion to use additional parameter to the login url is good since in this case I need to track only changes of login url but still it requires to modify every mail template in the application if login url is changed.


            s:link handles this situation perfectly but it generates link. Is there any way to get part of the path in the url relative to the context root which should be used to access certain *.xhtml template?