Wicket
  1. Wicket
  2. WICKET-4487

TextTemplate in RenderHead() on component doesn't Re-Render for every page

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.5
    • Fix Version/s: 1.5.6, 6.0.0-beta2
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      Tomcat 6.x

      Description

      I have a project that uses a menu thats repeated on every page. If I first view it on a mounted page /PageName and then look at it on a BookMarkable page
      /wicket/bookmarkable/page.class.name?foo the images referenced in my template do not appear.(the javascript template image strings do not change)

      1. test.war
        4.17 MB
        Tom Burton
      2. test.zip
        101 kB
        Tom Burton
      3. WICKET-4487.patch
        15 kB
        Martin Grigorov
      4. PackageTextTemplateVersion.zip
        173 kB
        Andrea Del Bene

        Activity

        Hide
        Andrea Del Bene added a comment -

        @Martin

        The patch looks good, I don't see any reason to not integrate it.

        Show
        Andrea Del Bene added a comment - @Martin The patch looks good, I don't see any reason to not integrate it.
        Hide
        Tom Burton added a comment -

        Andrea, thanks for the solution to keep me moving forward.

        Martin, thanks for telling me to file a bug report. I didn't think it was a bug with wicket. I thought maybe there was some other way I should be storing/accessing resources for my application.

        Show
        Tom Burton added a comment - Andrea, thanks for the solution to keep me moving forward. Martin, thanks for telling me to file a bug report. I didn't think it was a bug with wicket. I thought maybe there was some other way I should be storing/accessing resources for my application.
        Hide
        Andrea Del Bene added a comment -

        Don't worry Martin!
        I will take a look at the patch as soon as possible

        Show
        Andrea Del Bene added a comment - Don't worry Martin! I will take a look at the patch as soon as possible
        Hide
        Martin Grigorov added a comment -

        Attaching a patch that makes TextTemplateResourceReference more dynamic by:
        constructing its resource data on the fly and by re-registering itself in the global ResourceReferenceRegistry because otherwise its variableModel got stale.

        Show
        Martin Grigorov added a comment - Attaching a patch that makes TextTemplateResourceReference more dynamic by: constructing its resource data on the fly and by re-registering itself in the global ResourceReferenceRegistry because otherwise its variableModel got stale.
        Hide
        Martin Grigorov added a comment -

        Hey Andrea,

        Sorry for not assigning the ticket when I start working on it. Now we both worked on the same task.. Not that this is too bad, now we have two opinions

        I think it is actually a bug. TextTemplateResourceReference is just too static in its current state. Since I'm not sure whether it should be static or dynamic I'll attach my patch here to discuss it.

        Show
        Martin Grigorov added a comment - Hey Andrea, Sorry for not assigning the ticket when I start working on it. Now we both worked on the same task.. Not that this is too bad, now we have two opinions I think it is actually a bug. TextTemplateResourceReference is just too static in its current state. Since I'm not sure whether it should be static or dynamic I'll attach my patch here to discuss it.
        Hide
        Andrea Del Bene added a comment -

        Hi,

        actually this is not a bug. Wicket keeps a registry of every ResourceReference used in an application. The registry its like a Map where the key is composed, among other things, by Class name and resource name which in case of TextTemplateResourceReference are the scope Class and the fileName (i.e. BasePage.class and "includes/javascript/jqueryslidemenu.js")
        When you go from homepage to a bookMarkable one Wicket keeps using the previous TextTemplateResourceReference with the wrong url for arrow pics.
        To solve your problem you could use a PackageTextTemplate to generate the dynamic JavaScript.

        I will upload your code with this solution in a few minutes...

        Show
        Andrea Del Bene added a comment - Hi, actually this is not a bug. Wicket keeps a registry of every ResourceReference used in an application. The registry its like a Map where the key is composed, among other things, by Class name and resource name which in case of TextTemplateResourceReference are the scope Class and the fileName (i.e. BasePage.class and "includes/javascript/jqueryslidemenu.js") When you go from homepage to a bookMarkable one Wicket keeps using the previous TextTemplateResourceReference with the wrong url for arrow pics. To solve your problem you could use a PackageTextTemplate to generate the dynamic JavaScript. I will upload your code with this solution in a few minutes...
        Hide
        Tom Burton added a comment -

        Here is a compiled war and the sources I used to create it.

        Show
        Tom Burton added a comment - Here is a compiled war and the sources I used to create it.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Tom Burton
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development