1 2 Previous Next 23 Replies Latest reply on Aug 7, 2007 6:45 AM by pmuir

    Page action not called

    sammy8306

      I'm having trouble calling page actions from PageName.page.xml files. When I put the following line into the top level pages.xml file:

      <pages>
       <page view-id="/PageName.xhtml" action="#{PageComponent.someaction}">
      </pages>
      


      everything works fine. However, when putting this in PageName.page.xml:
      <!DOCTYPE page PUBLIC "-//JBoss/Seam Pages Configuration DTD 1.1//EN" "http://jboss.com/products/seam/pages-1.1.dtd" >
      
      <page action="#{PageComponent.someaction}" />
      


      someaction is not called. I've tried lots of things (using a nested tag, adding a view-id even though it is implied), but nothing worked so far... what am I doing wrong? The PageName.page.xml is the same directory as PageName.xhtml.


        • 1. Re: Page action not called
          sammy8306

          Anyone got a hint? I really need this to work, to keep my implementation manageable...

          • 2. Re: Page action not called
            gavin.king

            Put the Seam src in your sourcepath and use your debugger. (Put a breakpoint in the Pages class.)

            I'm sure you'll quickly find the problem.

            • 3. Re: Page action not called
              sammy8306

              So you're saying what I am doing should work, or are you saying that it won't work (for some reason, to be found in the Pages class)?

              • 4. Re: Page action not called
                gavin.king

                Sure, it looks about right.

                • 5. Re: Page action not called
                  sammy8306

                  I decided to look into this again, since I would really like this to work. First step was to put the log4J level at debug, since there are several debug statements in Pages.java (e.g. log.debug("reading pages.xml");). And lo and behold, these messages do not even appear in the debug output. Does this mean Seam isn't parsing my pages.xml? (it must be, since directives in pages.xml are followed, only in *.page.xml they are ignored)...

                  • 6. Re: Page action not called
                    sammy8306

                    Ok, figured out why the debug statement didn't appear, parsing pages only happens when a request is handled, not at startup. Original question still stands though. I've tried to move the *.page.xml to the WEB-INF directory, but no success.

                    • 7. Re: Page action not called
                      sammy8306

                      (I'll keep talking to myself :-), since I think it might be useful for others too)

                      minor breakthrough: the resource loading seems to be the culprit. Pages.java strips the leading slash of the view id, replaces its extension with .page.xml and delegates to Resources.getResourceAsStream(), which fails all its options to load the file. However, if I prepend "/WEB-INF" to the resource string used in Pages.java, it works (of course the *.page.xml files need to be present in this dir)!!

                      However, I would rather not use my own patched version of Seam. Why aren't the files loaded when they are in the root of the webapp, along with the facelets .xhtml files?

                      • 8. Re: Page action not called
                        wise_guybg

                        *.page.xml should be next to your xhtml file.

                        I have :
                        \AuthProject\AuthWebApp\resources\noauth\login.page.xml
                        \AuthProject\AuthWebApp\resources\noauth\login.xhtml

                        • 9. Re: Page action not called
                          sammy8306

                           

                          "wise_guybg" wrote:
                          *.page.xml should be next to your xhtml file.

                          That's what I thought too, but apparently that doesn't work, at least if the xhtml/page.xml files are in the root of the WAR.

                          The structure is your source structure I presume, what is the layout of the generated WAR?

                          • 10. Re: Page action not called
                            sammy8306

                            Is there anybody with more insight into the Seam codebase who can comment on this issue? Very strange.

                            • 11. Re: Page action not called
                              wise_guybg

                              Well this would be:
                              \AuthWebApp.war\noauth\login.page.xml
                              \AuthWebApp.war\noauth\login.xhtml

                              I think you should place the page.xml files next to the xhtml. You should determine what's wrong in your configuration.

                              You can debug the Pages.java to see what is wrong. See Pages.createPage()

                              • 12. Re: Page action not called
                                sammy8306

                                 

                                "wise_guybg" wrote:
                                Well this would be:
                                \AuthWebApp.war\noauth\login.page.xml
                                \AuthWebApp.war\noauth\login.xhtml

                                Right, so your view pages are not in the root of the war (as they are in some of the Seam example apps), I'm speculating that might be part of the problem.

                                I think you should place the page.xml files next to the xhtml.

                                Yup, that's what I initially had:

                                \WebApp.war\Foo.xhtml
                                \WebApp.war\Foo.page.xml

                                No succes.


                                You should determine what's wrong in your configuration.
                                You can debug the Pages.java to see what is wrong. See Pages.createPage()


                                Yeah, that's what I described in the previous posts. The debugging showed that Pages.java tries to load Foo.page.xml, but Resources.java fails loading it (it has several strategies to load external resources which all fail). It does work when I patch Pages.java to search for the files in /WEB-INF explicitly (as it does to lookup pages.xml). But, that's not really a solution since I'd have to run a patched version of Seam. I'm just stumped that the page.xml files cannot be loaded when they are in the root of the webapp, alongside the xhtml files.

                                Thanks for your help though!

                                Oh, one more thought: may be my servlet container precludes access to these files? Though facelets can freely load the xhtml files in the same location, so I doubt it...

                                • 13. Re: Page action not called
                                  wise_guybg

                                  Apart making modifications to the Pages class, have you tried putting a .xhtml and a .page.xml in a folder inside the root. Like my "noauth". Just to be sure that you have exactly localized the problem. If this works and putting them in root doesn't then I consider this a bug.

                                  I have tested the opposite, on my deploy. Seam correctly found AuthWebApp.war\error.page.xml in my root folder. It was processed by the Pages class.

                                  What version of Seam are you actually using? Mine is 2.0.0.BETA1.

                                  • 14. Re: Page action not called
                                    wise_guybg

                                    Do not consider /WEB-INF as a repository for the *.page.xml As you have probably seen the Pages class gets the configuration file's name like this

                                    String resourceName = replaceExtension(viewId, ".page.xml");


                                    It should really be next to the .xhtml file. After all this is the idea behind this feature, to have the configuration next to the source file. Not in a single really big repository location.

                                    1 2 Previous Next