Hi,
I had the same issue yesterday and found a solution somewhere else in this mailing list. Adding some random query to the url forces the browser not to reuse a cached image. To achieve that you have to subclass Image and override onComponentTag like this:

   @Override
   protected void onComponentTag(ComponentTag tag)
   {
       super.onComponentTag(tag);
       String src = (String) tag.getAttributes().get("src");
       src = src + "&rand=" + Math.random();
       tag.getAttributes().put("src", src);
   }

Bernard.


Igor Vaynberg wrote:
most people want stable urls for their images i would imagine, so they
can be cached by the browser.

in case of ajax this doesnt work because the url has to change so that
browser needs to know to refresh it.

maybe image can know if its requested within an ajax request and
automatically add random noise to the url...there maybe room for
improvement here.

please add an rfe

-igor


On Wed, Feb 27, 2008 at 11:12 AM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
Should nocachingImage be default, and then have a cachingImage? Or would
 that result in the same amount of confusion? WDYT?

 As a couple of people has been confused by this...

 regards Nino



 Igor Vaynberg wrote:
 > use NonCachingImage
 >
 > -igor
 >
 >
 > On Wed, Feb 27, 2008 at 2:43 AM, Karol Wrzesniewski
 > <[EMAIL PROTECTED]> wrote:
 >
 >> Hi,
 >>
 >>  I'm having problems with refreshing an Image using AjaxLink.
 >>
 >>  I have a ModalWindow. On it's left side theres a ListView containing Ajax
 >>  links:
 >>
 >>  ----------
 >>          add(listaObrazow = new ListView("pics", obrazki) {
 >>              public void populateItem(final ListItem listItem) {
 >>                  final String obr = (String)listItem.getModelObject();
 >>                  listItem.add(new Label("pic",new Model(obr)));
 >>
 >>                  listItem.add(new AjaxLink("picAjaxLink") {
 >>                      public void onClick(AjaxRequestTarget
 >>  ajaxRequestTarget) {
 >>
 >>                          imgPreview.setImageResource(
 >>                                  EbokTools.getImageResource(
 >>                                  (String)listItem.getModelObject()
 >>                                  )
 >>                                  );
 >>
 >>                          ajaxRequestTarget.addComponent(imgPreview);
 >>
 >>
 >>                          
myModal.setObraz((String)listItem.getModelObject());
 >>                          ajaxRequestTarget.addComponent(wyborObrazow);
 >>                      }});
 >>              }
 >>          });
 >>  ----------
 >>
 >>
 >>
 >>  imgPreview is an Image object, placed on the same modal Window. What Im
 >>  trying to achieve is to refresh this image after the AjaxLink is clicked.
 >>  Unfortunately it doesn't. After I click on AjaxLink content of form
 >>  "wyborObrazow" is refreshed, but image stays unchanged.
 >>
 >>  Image resource is being changed - i know that because after i close modal
 >>  and open it again "imgPreview" is showing me  the "right" Resource.
 >>
 >>  The problem is that calling ajaxRequestTarget.addComponent(imgPreview);
 >>  after changing imageResource doesn't seem to be enough.
 >>
 >>  I would be very grateful for some hints.
 >>
 >>  best regards,
 >>  Zyx
 >>
 >>  --
 >>
 >>  ---------------------------------------------------------------------
 >>  To unsubscribe, e-mail: [EMAIL PROTECTED]
 >>  For additional commands, e-mail: [EMAIL PROTECTED]
 >>
 >>
 >>
 >
 > ---------------------------------------------------------------------
 > To unsubscribe, e-mail: [EMAIL PROTECTED]
 > For additional commands, e-mail: [EMAIL PROTECTED]
 >
 >
 >

 --
 Nino Martinez Wael
 Java Specialist @ Jayway DK
 http://www.jayway.dk
 +45 2936 7684




 ---------------------------------------------------------------------
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--
Cordialement,
Bernard Niset.
------------------------------------------------------------------------
SmartObjects SPRL
Avenue Hergé, 21/14
1050 - Bruxelles
BELGIQUE
------------------------------------------------------------------------
Tel: +32 (0)2 770 68 04
Fax: +32 (0)2 791 92 78
E-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------

Reply via email to