7 Replies Latest reply on Dec 16, 2008 11:53 AM by wespe

    seam param passing problem

    wespe

      Error message is this:




      22:20:07,875 WARN  [Param] could not create converter for: userId
      java.lang.NullPointerException

      Menu bean:



      @Name("ssMenu")
      public class SsMenu {
           
           @In Identity identity;
           
           public String doEditUser() {
                return "editUser";
           }
      
      }



      menu.xhtml:



                          <s:link action="#{senseMenu.doEditUser}" value="#{identity.username}"
                               rendered="#{identity.loggedIn}" propagation="none" >
                               <f:param name="userId" value="#{currentUserId}" />
                          </s:link>



      pages.xml:


                 



                 <rule if-outcome\="editUser">
                      <redirect view-id\="/editUser.xhtml">
                           <param name\="userId" value\="#{currentUserId}"/>
                      </redirect>
                  </rule>






      Link shown in Firefox:




      http://localhost:8080/sense/editUser.seam?userId=1&actionMethod=editUser.xhtml%3AsenseMenu.doEditUser


      So as you can see it in the link above the first part is perfect.. userId=1
      But what's that actionmethod thingie doing there at all? Or at least without the userId param?
      What am I doing wrong?! :(

        • 1. Re: seam param passing problem
          wespe

          Forgot this one:



          @Name("userHome")
          public class UserHome extends EntityHome<User>
          {
              @RequestParameter
              Long userId;
          
              @Override
              public Object getId()
              {
                  if (userId == null)
                  {
                      return super.getId();
                  }
                  else
                  {
                      return userId;
                  }
              }
          ...
          }


          • 2. Re: seam param passing problem
            wespe

            You might need this also:



            @Name("currentUser")
            public class CurrentUser {
            
                 @Logger
                 Log log;
                 @Out(scope=ScopeType.SESSION)
                 private Long currentUserId;
            
                 @Observer(JpaIdentityStore.EVENT_USER_AUTHENTICATED)
                 public void authenticatedUser(User user) {
                      log.info("Authenticated user " + user.getUsername());
                      currentUserId = user.getId();
                 }
            }


            • 3. Re: seam param passing problem
              wespe

              Experimenting around now I'm getting a new error with this rule:



                 <rule if-outcome="editUser">
                  <redirect view-id="/editUser.xhtml">
                   <param name="userId" value="#{currentUserId}" converter="javax.faces.converter.LongConverter" />
                  </redirect>
                 </rule>



              Error:




              23:43:43,484 WARN  [Param] could not create converter for: userId
              java.lang.ClassCastException: java.lang.String cannot be cast to javax.faces.convert.Converter

              String? WTF? :)

              • 4. Re: seam param passing problem
                abafna.bafna.amit.gmail.com

                Change converter on param to


                converterId="javax.faces.Long"


                • 5. Re: seam param passing problem
                  wespe

                  Thanks for the reply but this didn't help.. I get the same error message.

                  • 6. Re: seam param passing problem
                    abafna.bafna.amit.gmail.com

                    I once faced the same exception when I used converter instead of converterId and changing it appropriately fixed my problem. If you've changed it and still does not fix the issue, I am sorry I could not be of ore help.


                    Cheers!!!


                    Amit

                    • 7. Re: seam param passing problem
                      wespe

                      Shhhh*t....... :)
                      Sorry Mate!
                      I made a mistake again..
                      Your solution seems just perfect!


                      Thank you very much!


                      Gabor