8 Replies Latest reply on Oct 30, 2006 3:21 PM by gavin.king

    Unable to call a method on my statefull session bean

      Again, I must be overlooking something simple.

      So I have a page that has a header/footer. menu on the left and content in the center right.

      So the menu on the left is working with a stateless session bean, They click a link on the left and a form appears in the center, with two buttons a Begin and a Cancel button. The actions of these buttoms should call my statefull session bean, but it isn't.

      Here is the start of my statefull session bean

      @Stateful
      @Local
      @Name("tripmanager")
      public class TripManagerImpl implements TripManager {
      
      



      Here is the jsf tags in my xhtml page

       <tr>
       <td>
       <h:commandButton action="#{tripmanager.startRoadTrip}"
       value="Begin" />
       </td>
       <td>
       <h:commandButton action="#{tripmanager.cancel}"
       value="Cancel" />
       </td>
       </tr>
      



      Here is the method that is linked to the Begin button

      @In (value="start", required=true, scope=ScopeType.SESSION)
       @Out (value="roadTrip", scope=ScopeType.SESSION)
       public String startRoadTrip(Location start) {
       System.out.println("Starting the startRoadTrip Method");
       TripLookup lookup = new TripLookup(start, null);
       try {
       RoadTrip roadTrip = lookup.getTripInformation();
       RoadTripDAO dao = new RoadTripDAO();
       dao.saveRoadTrip(roadTrip);
       } catch (RoadTripException e) {
       e.printStackTrace();
       return "failed";
       }
       System.out.println("***********************");
       System.out.println("Returning Entry from startRoadTrip");
       return "entry";
       }
      


      And here is my navigation rule defined in the faces-config.xml

      <navigation-rule>
       <from-view-id>/*</from-view-id>
       <navigation-case>
       <from-outcome>entry</from-outcome>
       <to-view-id>/fullentry.xhtml</to-view-id>
       </navigation-case>
       <navigation-case>
       <from-outcome>cancel</from-outcome>
       <to-view-id>/index.xhtml</to-view-id>
       </navigation-case>
       <navigation-case>
       <from-outcome>start</from-outcome>
       <to-view-id>/roadtripentry.xhtml</to-view-id>
       </navigation-case>
       <navigation-case>
       <from-outcome>list</from-outcome>
       <to-view-id>/roadtripentry.xhtml</to-view-id>
       </navigation-case>
       <navigation-case>
       <from-outcome>cancel</from-outcome>
       <to-view-id>/index.xhtml</to-view-id>
       </navigation-case>
       <navigation-case>
       <from-outcome>failed</from-outcome>
       <to-view-id>/failed.xhtml</to-view-id>
       </navigation-case>
       </navigation-rule>
      



      Any ideas where I might try to look. I have tried a lot of different things but have not had success.

      Thanks

        • 1. Re: Unable to call a method on my statefull session bean

          Oh, basically the bean is not being called and the page stays on the exact same page it was on.

          • 2. Re: Unable to call a method on my statefull session bean

            I just read one thing in the JSF Javadocs that the h:commandButton action must call a method that takes no parameters? Could that be the reason why? And the @In annotation is enough to get my object in the method, then how do I reference that object?

            • 3. Re: Unable to call a method on my statefull session bean
              gavin.king

              @In and @Out go on a field or property setter, not on the action method.

              please follow the Seam examples.

              • 4. Re: Unable to call a method on my statefull session bean

                Thanks, I also noticed that my comment above about parameters in an action method is not allowed. In looking at all the examples I noticed this.

                • 5. Re: Unable to call a method on my statefull session bean

                  So I then have this form that has values to #{location.xxx}, In the statefull session bean, I would then have a property called Location location that has an @In annotation on it for the bean to have access to that object created by the form. Correct?

                  • 6. Re: Unable to call a method on my statefull session bean

                    My understanding is this:

                    Seam calls the methods in your session beans when it encounters the action="#{name.action}" declarations, where name is the name of the Seam managed component, and action is the name of the method in the managed component.

                    However, before the method actually gets called, the Seam interceptor gets invoked, which populates all the @In and @DataModelSelection annotated fields. After the method invocation, control is passed back to the Seam interceptor and it updates the contexts with the @Out and @DataModel annotated fields.

                    Hope this helps...

                    • 7. Re: Unable to call a method on my statefull session bean

                       

                      "bsheward" wrote:
                      My understanding is this:

                      Seam calls the methods in your session beans when it encounters the action="#{name.action}" declarations, where name is the name of the Seam managed component, and action is the name of the method in the managed component.

                      However, before the method actually gets called, the Seam interceptor gets invoked, which populates all the @In and @DataModelSelection annotated fields. After the method invocation, control is passed back to the Seam interceptor and it updates the contexts with the @Out and @DataModel annotated fields.

                      Hope this helps...


                      Thanks, yes that helps, and I understood that. However, the Stateful Session bean is not being called. Nothing happens, or something happens but it just stays on the same page and does not reflect any changes and you can't tell anything happened. However, I know the bean is not being called because I logged some things in those methods to see if they were being called.

                      Is there a way to remote debug the JSF Phase and Seam calls with an IDE?

                      Thanks



                      • 8. Re: Unable to call a method on my statefull session bean
                        gavin.king

                        Just install JBoss IDE and put the source for Seam and MyFaces in your sourcepath.