4 Replies Latest reply on Jun 23, 2007 8:57 AM by David Radunz

    Entry Point

    Todd Main Newbie

      After almost a year of working with Seam and JSF, I still struggle with the issue of external entry points.

      That is, I want to load the "main" page of the application with some data, but I don't want to load that page that way every time.

      I have accomplished this so far with the following type of URL:

      http://host/app/mypage.seam?actionMethod=load&someParam=abc

      In an old-style servlet/struts app, you really never load JSPs directly. You always invoke a url that forwards or redirects to a JSP.

      In JSF/Seam, this happens naturally when you click a button or a command link. However, it's not clear to me what the "proper" way is to invoke an action as the app's entry point (as opposed to some REST-style page that always invokes a particular action).

      I particularly have trouble with the page action (in the pages.xml file) approach when working with IceFaces, as the page action is getting invoked every time a "partial submit" component is invoked.

        • 1. Re: Entry Point
          Gavin King Master

          A page action is the right way to do it. If you don't want it to be reinvoked on subsequent partial submits, you have two options:

          (1) map the page action to a "fake" view id - yes, a page action is allowed to perform navigation and result in a different view id, just like struts! Perhaps thats not clear in the docs.

          (2) set a page scope variable in the action, and do

          <action if="#{empty wasCalledBefore}"/>


          I would say that (1) is most elegant.

          • 2. Re: Entry Point
            Gavin King Master

            pages.xml for a fake view id is like:

            <page view-id="/entryPoint.xhtml">
             <action execute="#{something.doSomething}"/>
             <navigation>
             <render view-id="/displayWelcome.xhtml"/>
             </navigation>
            </page>


            or something close to that.

            There is no /entryPoint.xhtml file. thats just the URL you want to appear in the browser.

            • 3. Re: Entry Point
              Todd Main Newbie

              Perfect! As always, thanks so much for answering so many questions!!!

              • 4. Re: Entry Point
                David Radunz Newbie

                Hi,

                Should the same technique be used to layer xhtml resources like EJB's can be (using the @Install annotation)? If so, how would you have multiple pages.xml files - and would it conflict?

                Say I had a real view: "/product/function.xhtml" and I had customised version of it deployed at a particular site called "/site/product/function.xhtml". Could (or rather should) I use this approach:

                <page view-id="/product/function.xhtml">
                 <navigation>
                 <render view-id="/site/product/function.xhtml"/>
                 </navigation>
                </page>



                And refer to the view generally as only "/product/function.xhtml", but actually load "/site/product/function.xhtml". Or should I use something like EL at all times and resolve the actual resource via a method call or resource bundle?

                What methodology have you used to address this in the past?

                Cheers,

                David