8 Replies Latest reply on Feb 13, 2006 4:21 AM by theute

    Bookmakring jsf pages in seam?

    liudan2005

      I am trying to make my jsf pages search engine friendly

      I've had a search in google and have got some basic ideas but don't know how to make this working.

      In booking example, main.xhtml, if I put:
      <h:outputLink action="#{hotelBooking.selectHotel}>
      <f:param name="id" value="${hot.id}">
      </h:outputLink>

      and in java I may add:
      String id = facesContext.getExternalContext().getRequestParameterMap().get("id");
      em.load(Hotel.class, id);

      The problem is, where the trigger point would be when user type http://abc.com/hotel.seam?id=1 in their browser. Where should I put the java code in?

      Is there a good way to do the bookmarking in seam?

        • 1. Re: Bookmakring jsf pages in seam?
          gavin.king

          Use an @Factory method. Let me know if you need more help.


          By the way, there is a FAQ item on this...

          • 2. Re: Bookmakring jsf pages in seam?
            liudan2005

            Thanks Gavin. I've just noticed beta2 is out.

            Here is what I've tried.

            I've modified HotelBookingAction so it doesn't require login. Here is its class annotations:
            @Stateful
            @Name("hotelBooking")
            @Scope(SESSION)
            @Interceptors(SeamInterceptor.class)

            I then added a method:
            @Factory("hotels")
            public void comeFromUrl() {
            System.out.println("**** comeFromUrl:");
            if (id != null) {
            hotel = em.find(Hotel.class, id);
            }
            }

            Also I've defined the request parameter:
            @RequestParameter
            private String id;

            After all, I tried this url in my browser:
            http://localhost:8080/seam-booking/hotel.seam?id=2

            The comeFromUrl() method is not triggered at all. The hotel.seam page is deplayed with all fields in blank. Is there anything I'm doing wrong?

            • 3. Re: Bookmakring jsf pages in seam?
              gavin.king

              It should be @Factory("hotel")

              not "hotels".

              • 4. Re: Bookmakring jsf pages in seam?
                liudan2005

                I've changed it to hotel, here is what I've got now:

                javax.el.ELException: /hotel.xhtml: create method not found
                at com.sun.facelets.compiler.UIText.encodeBegin(UIText.java:51)
                at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:511)
                at com.sun.facelets.FaceletViewHandler.encodeRecursive(FaceletViewHandler.java:518)
                at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:447)
                at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:352)
                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:107)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                at org.jboss.seam.servlet.SeamRedirectFilter.doFilter(SeamRedirectFilter.java:23)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
                at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
                at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
                at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
                at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
                at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
                at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
                at java.lang.Thread.run(Thread.java:595)
                Caused by: java.lang.NoSuchMethodException: $Proxy208.comeFromUrl()
                at java.lang.Class.getMethod(Class.java:1581)
                at org.jboss.seam.Component.callComponentMethod(Component.java:1116)
                at org.jboss.seam.Component.getInstanceFromFactory(Component.java:1078)
                at org.jboss.seam.Component.getInstance(Component.java:1041)
                at org.jboss.seam.Component.getInstance(Component.java:1027)
                at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableResolver.java:43)
                at com.sun.facelets.el.LegacyELContext$LegacyELResolver.getValue(LegacyELContext.java:130)
                at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:41)
                at com.sun.el.parser.AstValue.getValue(AstValue.java:85)
                at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:183)
                at com.sun.facelets.el.ELText$ELTextVariable.write(ELText.java:142)
                at com.sun.facelets.el.ELText$ELTextComposite.write(ELText.java:97)
                at com.sun.facelets.compiler.UIText.encodeBegin(UIText.java:49)
                ... 27 more


                Another question is, both hotels and hotel would null. why use hotel would give a different result?

                • 5. Re: Bookmakring jsf pages in seam?
                  gavin.king

                  You need to add comeFromUrl() to the local interface.

                  Another question is, both hotels and hotel would null. why use hotel would give a different result?

                  depends which appears first in the jsp



                  • 6. Re: Bookmakring jsf pages in seam?
                    liudan2005

                    What a stupid mistake I've made. Thanks Gavin. It works now.

                    • 7. Re: Bookmakring jsf pages in seam?
                      robjellinghaus

                       

                      "gavin.king@jboss.com" wrote:
                      By the way, there is a FAQ item on this...

                      Where *is* the FAQ? I don't see a FAQ link on the wiki?

                      • 8. Re: Bookmakring jsf pages in seam?
                        theute

                        The link was on the main product page ;)

                        I added the link on the Wiki page, thanks !