Wicket
  1. Wicket
  2. WICKET-1340

Bogus LocalizedImageResource#isStateless()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0-final, 1.3.1
    • Fix Version/s: 1.3.2
    • Component/s: wicket
    • Labels:
      None

      Description

      Image without resource/resource reference should be stateless.

      Bug is located in LocalizedImageResource#isStateless(), which should read "return resourceReference == null;"

      Test case is attached.

      1. ImageTest.java
        0.4 kB
        Marat Radchenko
      2. Image2Test.java
        0.5 kB
        Marat Radchenko

        Issue Links

          Activity

          Hide
          Johan Compagner added a comment -

          this is not true.

          an Image is statefull if it doesn't have a ResourceReference
          If it does have a resource reference then it is a shared resources with a shared resource reference url and then it is stateless.

          Look at the method: protected void onComponentTag(final ComponentTag tag) of Image if the image doesn't have a RR then
          it will generate a callback to itself and that mean statefull

          Show
          Johan Compagner added a comment - this is not true. an Image is statefull if it doesn't have a ResourceReference If it does have a resource reference then it is a shared resources with a shared resource reference url and then it is stateless. Look at the method: protected void onComponentTag(final ComponentTag tag) of Image if the image doesn't have a RR then it will generate a callback to itself and that mean statefull
          Hide
          Marat Radchenko added a comment -

          Sadly I have to reopen this issue. Please find attached testcase (Image2Test.java). It tries to prove what you say (and fails...).

          I cannot find any way to create a stateless Image. Could you show me an example?

          Show
          Marat Radchenko added a comment - Sadly I have to reopen this issue. Please find attached testcase (Image2Test.java). It tries to prove what you say (and fails...). I cannot find any way to create a stateless Image. Could you show me an example?
          Hide
          Marat Radchenko added a comment -

          Sorry, mistyped your name

          Show
          Marat Radchenko added a comment - Sorry, mistyped your name
          Hide
          Johan Compagner added a comment -

          ok that made it more clear what you tried to test.
          it should be fixed now in head.

          Show
          Johan Compagner added a comment - ok that made it more clear what you tried to test. it should be fixed now in head.
          Hide
          Marat Radchenko added a comment -

          Just some thoughts:

          1) Wrong assersion messages:
          testEmpty -> "image withOUT resource reference should be statefull"
          testResource -> "image with resource should be statefull"

          2) Confusing javadoc in LocalizedImageResource#isStateless(). It says:
          @return If it is stateless (if resource is null)

          But current implementation checks if resource is NOT null.

          3) I still doesn't understand why rr-less image is statefull. What's it's state? It doesn't have any variables defined -> no state. And image with rr has state - it contains knowledge about what exact resource this image references.
          Look at your test case. Empty images has state, but non-empty image doesn't have state. This is very confusing.

          So I strongly recommend you to take a deep breath and thing about this issue once more.

          Show
          Marat Radchenko added a comment - Just some thoughts: 1) Wrong assersion messages: testEmpty -> "image withOUT resource reference should be statefull" testResource -> "image with resource should be statefull" 2) Confusing javadoc in LocalizedImageResource#isStateless(). It says: @return If it is stateless (if resource is null) But current implementation checks if resource is NOT null. 3) I still doesn't understand why rr-less image is statefull. What's it's state? It doesn't have any variables defined -> no state. And image with rr has state - it contains knowledge about what exact resource this image references. Look at your test case. Empty images has state, but non-empty image doesn't have state. This is very confusing. So I strongly recommend you to take a deep breath and thing about this issue once more.
          Hide
          Johan Compagner added a comment -

          I fixed the message for testResource, deleted the testEmpty because when i thought about it that one didn't make any sense.
          Because the empty one is completely depending on the markup the image has.

          improved the javadoc: "@return true if it has a resourceReference. (it points to a shared resource)"

          stateless is not about variables or that kind of stuff.
          A component is statefull if it generates a callback link to itself. And if an Image doesn't have a resourceReference but only a Resource then it generates a callback link so that it will serve the Resource itself.

          Show
          Johan Compagner added a comment - I fixed the message for testResource, deleted the testEmpty because when i thought about it that one didn't make any sense. Because the empty one is completely depending on the markup the image has. improved the javadoc: "@return true if it has a resourceReference. (it points to a shared resource)" stateless is not about variables or that kind of stuff. A component is statefull if it generates a callback link to itself. And if an Image doesn't have a resourceReference but only a Resource then it generates a callback link so that it will serve the Resource itself.
          Hide
          Marat Radchenko added a comment -

          > And if an Image doesn't have a resourceReference but only a Resource then it generates a callback link so that it will serve the Resource itself.

          I understand case with Resource. However empty image (that takes url from template) doesn't have any resource. And it doesn't generate callback to itself.

          If image is empty then LocalizedImageResource searches for src attribute on tag and invokes LocalizedImageResource#loadStaticImage. Which sets ResourceReference! So empty image turns into image with ResourceReference (which is stateless as you say).

          Show
          Marat Radchenko added a comment - > And if an Image doesn't have a resourceReference but only a Resource then it generates a callback link so that it will serve the Resource itself. I understand case with Resource. However empty image (that takes url from template) doesn't have any resource. And it doesn't generate callback to itself. If image is empty then LocalizedImageResource searches for src attribute on tag and invokes LocalizedImageResource#loadStaticImage. Which sets ResourceReference! So empty image turns into image with ResourceReference (which is stateless as you say).
          Hide
          Johan Compagner added a comment -

          if you are looking through the code
          then do look through ALL the code, there is one case that a resource is made
          But this is why i removed the test with just the id constructor
          Because testing it doesn't make any sense without markup that specifices more stuff.

          Show
          Johan Compagner added a comment - if you are looking through the code then do look through ALL the code, there is one case that a resource is made But this is why i removed the test with just the id constructor Because testing it doesn't make any sense without markup that specifices more stuff.
          Hide
          Marat Radchenko added a comment - - edited

          Ok, let's sum up.

          1) Image should be stateful if it has Resource [either in LocalizedImageResource or in model].
          2) Otherwise (if it has ResourceReference [either in LocalizedImageResource or in model]) it should be stateless.
          3) If image is empty (it doesn't have R/RR in model and it doesn't have R/RR in LocalizedImageResource) then it cannot become stateful because in this case src tag attribute will be used and RR will be created so image will be the same as in 2.

          Right?

          Show
          Marat Radchenko added a comment - - edited Ok, let's sum up. 1) Image should be stateful if it has Resource [either in LocalizedImageResource or in model] . 2) Otherwise (if it has ResourceReference [either in LocalizedImageResource or in model] ) it should be stateless. 3) If image is empty (it doesn't have R/RR in model and it doesn't have R/RR in LocalizedImageResource) then it cannot become stateful because in this case src tag attribute will be used and RR will be created so image will be the same as in 2. Right?
          Hide
          Johan Compagner added a comment -

          better would be:

          1> an Image is statefull it the LocalizedImageResource doesnt have a ResourceReference (to a null or to a current resource)

          2> if Image is empty then most likely a ResourceReference is generated (and <1> applies) but a Resource could be generated in one spefic case (ImageFactory) then it is statefull

          Show
          Johan Compagner added a comment - better would be: 1> an Image is statefull it the LocalizedImageResource doesnt have a ResourceReference (to a null or to a current resource) 2> if Image is empty then most likely a ResourceReference is generated (and <1> applies) but a Resource could be generated in one spefic case (ImageFactory) then it is statefull

            People

            • Assignee:
              Johan Compagner
              Reporter:
              Marat Radchenko
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development