You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ned Collyer <ne...@gmail.com> on 2008/11/11 23:06:42 UTC

Re: wicket 1.4 - Localizer getCacheKey BUG

I'm in the process of updating to 1.4m3.

The following is resulting in the same cache key for each item. (which did
not happen in 1.4m1)

ListView createLinks = new ListView<Link>("createLinks", links) {
    protected void populateItem(ListItem<Link> item) {
				Link link = item.getModelObject();
				link.add(new Label("banana"))
        item.add(link);
    }
};

Is this the correct behaviour?  It's causing my links to all have the same
label (ie, whichever was hit first)


Rgds

Ned

igor.vaynberg wrote:
> 
> should be fixed in m3 which is coming out any hour
> 
> -igor
> 
> On Sat, Jul 12, 2008 at 9:07 AM, FakeBoy <da...@gmail.com> wrote:
>>
>> Hi,
>> I migrate my app from wicket 1.3 to wicket 1.4.
>> Everything works fine, but one thing behaves strange.
>> I have BasePage and all others pages in my app extends this page.
>> BasePage have some responsibilities and one of them is set correct page
>> title.
>> Example:
>> public class BasePage ext WebPage {
>>
>>  public BasePage() {
>>    add(new Label("title", getTitle()));
>>  }
>>
>>  protected IModel getTitle() {
>>    return new ResourceModel("pageTitle");
>>  }
>> }
>> All pages, which extends BasePage need to define properties file with key
>> "pageTitle" if want to declare own page title.
>>
>> In Wicket 1.3 everythigs works correct, but in Wicket 1.4 NOT.
>> The problem is in constructing CacheKey for localizer's properties cache.
>>
>> In Wicket 1.3 CacheKey containts:
>> 1. component.getPageRelativePath()
>> 2. component.findPage() -> page.getClass().getName()
>> There is all suffcient information for correct cashing properties.
>>
>> But in Wicket 1.4 it changed and page class name missed in constructing
>> CacheKey.
>> CacheKey containts:
>> 1. resourceKey
>> 2. component class name
>> 3. component id
>> 4. locale
>> 5. style
>>
>> Result :
>> If page identifier missed, title on my pages are still same, they are
>> cached.
>> Reason is that CacheKey is same for all my pages, although they contains
>> properties file with own declared "pageTitle".
>> CacheKey is:
>> pageTitle-org.apache.wicket.markup.html.basic.Label:title-en_EN-null
>> This CacheKey is same for Page1, Page2, Page3 because it don't care about
>> page.
>>
>> What are you think about it?
>> Thanks
>>
> 

-- 
View this message in context: http://www.nabble.com/wicket-1.4---Localizer-getCacheKey-BUG-tp18421093p20449490.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket 1.4 - Localizer getCacheKey BUG

Posted by Ned Collyer <ne...@gmail.com>.
actually.. found out what it was (and the example i gave was incorrect -
oops).

the new Localizer#getCacheKey(String, Component) assumes that for a given
key in the markup, there will only ever be a single translation.

I have my own resource resolver, which allows for resolution of the keys
based on the class of the model object (which saves having to duplicate
translations, and allows me to store translations against the domain
entities).  Igor has mentioned this is a bad idea, but it has been VERY
useful, and means that the translations are appropriate outside of the
wicket world (I also use them for web services through another application).

Previously, the following would result in different cache keys based on the
index of the list item - which was good because my custom
StringResourceResolver relied upon it.

    <wicket:container wicket:id="createLinks">
         # <wicket:message key="entity">[entity]</wicket:message> 
    </wicket:container>

I have fixed this by overriding the getCacheKey method with the old code.

It could be cleaned up a bit - the cache keys are HUGE...

Rgds

Ned



I'm in the process of updating to 1.4m3.

The following is resulting in the same cache key for each item. (which did
not happen in 1.4m1)

ListView createLinks = new ListView<Link>("createLinks", links) {
    protected void populateItem(ListItem<Link> item) {
				Link link = item.getModelObject();
				link.add(new Label("banana"))
        item.add(link);
    }
};

Is this the correct behaviour?  It's causing my links to all have the same
label (ie, whichever was hit first)


Rgds

Ned

igor.vaynberg wrote:
> 
> should be fixed in m3 which is coming out any hour
> 
> -igor
> 

-- 
View this message in context: http://www.nabble.com/wicket-1.4---Localizer-getCacheKey-BUG-tp18421093p20449836.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org