Here is the source code without tabs: /* advanced search link */ add(new AjaxSubmitLink("advancedSearch") {
private static final long serialVersionUID = 3847759110695405700L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { advancedSearch = !advancedSearch; target.addComponent(findUserAcountForm); } }.add(new NonCachingImage("expandCollapse", new Model<String>() { private static final long serialVersionUID = 3430522655787763141L; @Override public String getObject() { return advancedSearch ? "/img/collapse.gif" : "/img/expand.gif"; } }))); I hope it's more readable this way :-) Zhubin Zhubin Salehi wrote: > > Hi guys, > > I have a similar problem that NonCachingImage does not solve. I have > implemented a simple expand/collapse button. I check the rendered page > source in FireFox and image name is always "/img/expand.gif". Here is the > code: > > /* advanced search link */ > add(new AjaxSubmitLink("advancedSearch") { > > private static final long serialVersionUID = > 3847759110695405700L; > > @Override > protected void onSubmit(AjaxRequestTarget > target, Form<?> form) { > advancedSearch = !advancedSearch; > target.addComponent(findUserAcountForm); > } > }.add(new NonCachingImage("expandCollapse", new > Model<String>() { > > private static final long serialVersionUID = > 3430522655787763141L; > > @Override > public String getObject() { > return advancedSearch ? > "/img/collapse.gif" : "/img/expand.gif"; > } > }))); > > Thanks, > Zhubin > > > Marco Santos wrote: >> >> Hello there! >> >> I'm with problems refreshing an Image. On my web application i'm trying >> to refresh or change an Image that is on a Panel. On the panel there is a >> Image (it is rendered the first time) and a label. Outside the panel i >> have AjaxLink's (that are images too) that refresh the panel, and >> consequently the components on it, the image and the label. when the link >> is clicked, the label e refreshed with the new text, but the image still >> the same. The code is the following: >> >> /** >> *The Panel with the image to be refreshed: >> *(the label on the panel is freshed when the link is pressed. >> **/ >> public class PhotoPanel extends Panel { >> /** Creates a new instance of PhotoPanel*/ >> public PhotoPanel(String id, byte[] photoData, int size, Integer >> index) { >> super(id); >> setOutputMarkupId(true); >> >> MyImage mainPhoto = new MyImage("mainPhoto", photoData, >> size);//component that extends Image >> mainPhoto.setOutputMarkupId(true); >> >> Label label = new Label("index", "MYLABEL: " + index.toString()); >> >> add(mainPhoto); >> add(label); >> } >> } >> >> /** >> * The AjaxLink's on a Parent panel that holds a panel with the links, >> and the panel with the image >> * to be refreshed >> **/ >> private class PhotoSlideLink extends AjaxLink { >> private byte[] photoSlideData = null; >> Integer index = 0; >> public PhotoSlideLink(String id, byte[] photoSlideData ) { >> super(id); >> this.photoSlideData = photoSlideData ; >> >> MyImage photoSlide = new MyImage("photoSlide", photoSlideData >> , 100); >> add(photoSlide ); >> } >> >> @Override >> public void onClick(AjaxRequestTarget ajaxRequestTarget) { >> Panel newMainPhotoPanel = new PhotoPanel("mainPhotoPanel", >> photoSlideData , MAIN_PHOTO_SIZE, index++); >> newMainPhotoPanel .setOutputMarkupId(true); >> >> /*the first PhotoPanel created when the page was loaded*/ >> mainPhotoPanel.replaceWith(newMainPhotoPanel); >> mainPhotoPanel= newMainPhotoPanel ; >> >> ajaxRequestTarget.addComponent(newMainPhotoPanel); >> } >> } >> >> Does any one know why refreshing the panel, the label change, but not the >> image? Am i forgetting to do something? >> >> Thanks a lot >> > > -- View this message in context: http://www.nabble.com/Problems-Refreshin-a-Image-from-AjaxLink-tp14472713p22376853.html Sent from the Wicket - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org