3 Replies Latest reply on Feb 4, 2007 4:11 PM by Leo Baschy

    request parameter gets ignored sometimes

    Leo Baschy Novice

      Starting out from seam-gen. Let's say we have three kinds of entities, Car, Boat and Plane. We only need Car to illustrate.

      There is a page each like CarList.xhtml, Car.xhtml, CarEdit.xhtml and their CarList.page.xml, Car.page.xml, CarEdit.page.xml.

      It all works fine with the generated code. Then my colleague introduces a different menu, and in that menu he doesn't use s:link with propagation="none". I'll explain what breaks and why it shouldn't break, it should work.

      What breaks is this: Go to list of cars, go to view a car (select it), go on to edit the car, and then while on the car edit page, change your mind and go to somewhere else in the menu. Important: Do that with a link that isn't an s:link with propagation="none". Could happen, e.g. a help page, sidebar, top level menu, anything. You can't make the whole world (even in your company) use s:link. Then ... come back (e.g. through "the usual" link in the menu) to the list of cars, go to view another car, and voila, you're back at the car you selected first time, not the one you selected this time!

      Just now to reproduce it I tried it a couple of times. First time I couldn't, probably not right sequence, but second or third time I got it again. When I demoed yesterday I got it all the time.

      What seems to be broken is this: While in the list of cars the s:link to select (i.e. the one to view the car) does contain an f:param with a carId, and it does show up in the URL with the new carId, it seems "the model" (EntityHome?) keeps using the Car.id from last time. (Or CarHome's id. You know better. I'm just imitating seam-gen.

      It is very clear and striking, up there in the Address field of the browser in the URL I see the correct carId for the newly chosen car, but in the display of contents below there is the wrong car id from before.

      That shouldn't be that way, ever, should it? I mean that parameter is a clear indication of what should happen.

      Now, in case that matters, there is an increase in cid (conversation id) from Car.xhtml to the CarEdit.xhtml through a propagation="begin", per seam-gen. While the use and non-use of propagation might be worth discussing anyway, the point is though that a request parameter shouldn't be ignored either way, right?

      I'm not going to go into details about what I think about methods in Param.java, so as not to soil the team's thoughts with my possibly wrong ideas. I don't have a complete answer anyway, just some methods I tried following where they are used. Like getValueFromRequest in Param.java, versus getValueFromModel.

      Running off CVS, building here.

      PS: In Car.page.xml I have

      <param name="carId" value="#{carHome.id}" />


      Then as in CarHome I define

      @Factory("car")
      public Car initCar() {
       return getInstance();
      }


      I use in Car.xhtml fields like

      <h:outputText id="description" value="#{car.description}" />


      I don't use like seam-gen

      <h:outputText id="description" value="#{carHome.instance.description}" />


      Could that be related, or can someone make a statement that car and carHome.instance are identical objects, all the time, for the records?

        • 1. Re: request parameter gets ignored sometimes
          Leo Baschy Novice

          Problem pinpointed better. Now, is that a feature or a bug?

          The problem is after the second time in the same conversation coming in with

          <param name="carId" value="#{carHome.id}" />


          when having

          @Factory("car")
          public Car initCar() {
           return getInstance();
          }


          then when that second time coming in with a different id then carHome.instance

          <h:outputText id="description" value="#{carHome.instance.description}" />


          is correct for new (second) id car, but the factory made car

          <h:outputText id="description" value="#{car.description}" />


          still remains the same as for first time id.

          Is that a feature or a bug?

          • 2. Re: request parameter gets ignored sometimes
            fhh Expert

            You are accessing two different objects: One is the car created by the factory method and then outjected into whatever scope you declared. The other is the member variable of the CarHome object. Since the last one is not outjected the scoped object is not replaced.

            I'm just guessing. I have never used the home objects and you did not post your code.

            Regards

            Felix

            • 3. Re: request parameter gets ignored sometimes
              Leo Baschy Novice

              I only got the idea to do it that way because of shorter syntax promised in seam_reference, in chapter 10.2 Home objects, "adding a @Factory".

              If I think of what a factory normally does, how contexts normally work, etc. then of course it seems I should stick with carHome.instance.

              Now, having fallen into that trap, and now knowing to stick to using carHome.instance, what will happen with that chapter 10.2 suggestion to use a factory for shorter syntax?

              Will the recommendation to use a factory be removed? Will it get a use warning? Or will Seam be changed to allow some shorter syntax to work in more/all cases?