OK I couldn't figure out what was wrong so I did it as a last resort:
/* advanced search link */
AjaxSubmitLink advancedSearchLink;
mainTable.add(advancedSearchLink = new AjaxSubmitLink("advancedSearch") {
private static final long serialVersionUID = 4373219220751138123L;
@Override
protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
advancedSearch = !advancedSearch;
target.addComponent(mainTable);
}
});
advancedSearchLink.add(new WebComponent("expand") {
private static final long serialVersionUID = 1566267580506427230L;
@Override
public boolean isVisible() {
return !advancedSearch;
}
});
advancedSearchLink.add(new WebComponent("collapse") {
private static final long serialVersionUID = 4204455496315941511L;
@Override
public boolean isVisible() {
return advancedSearch;
}
});
It's not the best way to go, but it works.
Zhubin
Zhubin Salehi wrote:
>
> I figured out if the page starts with 'advancedSearch = false' the image
> is always expand.gif and if it starts with 'advancedSearch = true' the
> image is always collapse.gif. So the value of Model object is cached
> somewhere, but not in the browser for sure.
>
> What I don't understand is that every time the panel is rendered,
> getObject() method is called but apparently the return value is ignored.
>
>
>
> Zhubin Salehi wrote:
>>
>> advancedSearch is in PersonDetailTab that is a panel in an AbstractTab in
>> a PanelCachingTab in FindUserAcountForm.
>>
>> Zhubin
>>
>>
>> igor.vaynberg wrote:
>>>
>>> is advancedSearch inside findUserAccountForm?
>>>
>>> -igor
>>>
>>> On Fri, Mar 6, 2009 at 9:23 AM, Zhubin Salehi <[email protected]>
>>> wrote:
>>>>
>>>> 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: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Problems-Refreshin-a-Image-from-AjaxLink-tp14472713p22380009.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]