3 Replies Latest reply on Jan 18, 2007 12:02 AM by fabio.ita04

    Entity Id as Page Parameters (pages.xml)

      Hi,

      I'm trying to write a simple application using Seam Framework, based on the seam reference documentation. I have a search screen, that displays a list of entities. For each entity on the list, there's a hyperlink that can be clicked to display an edit page.

      Seam reference tells the developer to write the hyperlink as <s:link> with <f:param>, and declares that param at pages.xml, so it can be passed to EntityHome.

      So I'm facing a problem: the param is passed to EntityHome as String, and EntityHome invokes

      E result = getEntityManager().find( getEntityClass(), getId() );

      but my entity identifier is Long typed, so hibernate throws

      org.hibernate.TypeMismatchException: Provided id of the wrong type. Expected: class java.lang.Long, got class java.lang.String.

      How can I solve this?

      Thanx,
      Fábio.

        • 1. Re: Entity Id as Page Parameters (pages.xml)
          kahliburke

          I believe you need to specify a Faces converter for the string:

          <param name="entityId" value="#{entity.id}" converterId="javax.faces.Long" />
          


          This is in the documentation, Section 5.1.1

          Hope it helps.

          Kahli

          • 2. Re: Entity Id as Page Parameters (pages.xml)
            gavin.king

            Yes, declare it as a page parameter, and specify a converter.

            • 3. Re: Entity Id as Page Parameters (pages.xml)

              It's working now! I haven't read chapter 5 yet, and when tried to follow the examples in chapter 14, had no knowledge about the need of converter.

              Seam Application Framework is a nice solution! Learn Seam become easier after I read chapter 14, because it showed a lot of cool stuffs:

              1) compares two alternatives to install seam components (annotations and components.xml);
              2) makes easier to understands "factory" usages;
              3) shows IoC properties initialization at components.xml;
              4) shows that Seam annotated classes can be easily extended;
              5) ilustrates how productive can be using Seam!

              Maybe it could be interesting to place an example at the first chapter (Seam Tutorial) so new Seam users can have an earlier "tasting" of its advantages.

              Thanx again!
              Fábio.