Re: update visibility of resourcelink

2015-05-10 Thread Martin Grigorov
On Sun, May 10, 2015 at 3:15 PM, Chris chris...@gmx.at wrote:

 Hi Tobias,

 I have followed your approach (update from parent) and it works. Thanks a
 lot.
 But could you show me also how to overwrite the visibility directly in the
 ResourceLink?
 ResourceLink pl = new ResourceLink(pdfLink, new
 ByteArrayResource(application/pdf) {…}?


Move ByteArrayResource bar = new ByteArrayResource() {...} a line above,
as a separate statement. Then override ResourceLink's #isVisible() method.
This way you'll notice your error in the old version.



 By the way, in the panel I have added another list view which does not use
 the model of the panel but has to calculate the model dynamically.
 With the following code, it seems also to be only called once in the
 constructor but not via ajaxUpdate. How to change this?

 ListModelString listModel = new ListModelString() {
@Override
 public ListString getObject() {

 Thanks, Chris


  Am 09.05.2015 um 20:38 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
  In your snippet you put the isVisible in the ByteArrayResource. That's
 why you get the error message - move it to your ResourceLink
 
  One easy way to update from parent would be: make a method in your panel
 which returns your link then make your panel a field in the parent and call
 the getter in the callback and add the link to your AjaxRequestTarget there.
 
  kind regards
 
  Tobias
 
  Am 09.05.2015 um 20:19 schrieb Chris chris...@gmx.at:
 
  Hi,
 
  thanks, I am getting the message method does not override method from
 its superclass.
 
  The problem is that I do not have the callback method in this panel but
 in its parent; I would need to have a getter method so that I can directly
 access the resource link from the panel instance and change its visibility.
 
  ResourceLink pl = new ResourceLink(pdfLink, new
 ByteArrayResource(application/pdf) {
 
@Override
protected boolean isVisible() {
return ;
}
 
});
 
  Chris
 
 
  Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
  Yes - should work because isVisible is inherited from component:
 
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
  But watch out not to put in expensive calls in it! The user guide is
 also mentioning a lot about that topic:
 
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
  At this place it is good to mention the new location of the guide:
 
  http://ci.apache.org/projects/wicket/guide/6.x/
 
  http://ci.apache.org/projects/wicket/guide/7.x/
 
  kind regards
 
  Tobias
 
  Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
  Hi Tobias,
 
  thanks! Can the isVisible method be directly overridden also by  a
 ResourceLink?
 
  ResourceLink pl = new ResourceLink(..) {
  protected boolean isVisible() {…}
  }
  Chris
 
 
  Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
  Hi,
 
  the constructor of your panel is only called at a normal request -
 you have to set the visibility of your link in the ajax callback via
 AjaxRequestTarget.
 
  1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to
 true (in your constructor)
 
  2. set the visibility to your component in the callback method
 (based on your Model)
 
  3. add the component to the AjaxRequestTarget so that it is updated
 
  Another solution would be to override the isVisible method and
 return the visibility based on your model and then only add the component
 to the AjaxRequestTarget.
 
  kind regards
 
  Tobias
 
  Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
  Hi all,
 
  currently, the visibility of the resource link is not updated when
 the parent component of the panel is rendered again based on an ajax call.
 
  How can the visibility set dynamically based on the model’s data?
 
  Thanks, Chris
 
  public SomePanel(String id, final IModelListA model) {
  super(id, model);
 
  ResourceLink pl = new ResourceLink(pdfLink, new
 ByteArrayResource(application/pdf) {...}
  pl.setVisible(routingModel.getObject().get(0).getElements().size()
  0);
  ...
  }
 
 -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
  -
  To unsubscribe, e-mail: 

Re: update visibility of resourcelink

2015-05-10 Thread Chris
Hi Tobias,

I have followed your approach (update from parent) and it works. Thanks a lot.
But could you show me also how to overwrite the visibility directly in the 
ResourceLink?
ResourceLink pl = new ResourceLink(pdfLink, new 
ByteArrayResource(application/pdf) {…}?

By the way, in the panel I have added another list view which does not use the 
model of the panel but has to calculate the model dynamically.
With the following code, it seems also to be only called once in the 
constructor but not via ajaxUpdate. How to change this?

ListModelString listModel = new ListModelString() {
   @Override
public ListString getObject() {

Thanks, Chris


 Am 09.05.2015 um 20:38 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 In your snippet you put the isVisible in the ByteArrayResource. That's why 
 you get the error message - move it to your ResourceLink 
 
 One easy way to update from parent would be: make a method in your panel 
 which returns your link then make your panel a field in the parent and call 
 the getter in the callback and add the link to your AjaxRequestTarget there.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 20:19 schrieb Chris chris...@gmx.at:
 
 Hi,
 
 thanks, I am getting the message method does not override method from its 
 superclass.
 
 The problem is that I do not have the callback method in this panel but in 
 its parent; I would need to have a getter method so that I can directly 
 access the resource link from the panel instance and change its visibility.
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {
 
   @Override
   protected boolean isVisible() {
   return ;
   }
 
   });
 
 Chris
 
 
 Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Yes - should work because isVisible is inherited from component:
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
 But watch out not to put in expensive calls in it! The user guide is also 
 mentioning a lot about that topic:
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
 At this place it is good to mention the new location of the guide:
 
 http://ci.apache.org/projects/wicket/guide/6.x/
 
 http://ci.apache.org/projects/wicket/guide/7.x/
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you 
 have to set the visibility of your link in the ajax callback via 
 AjaxRequestTarget.
 
 1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true 
 (in your constructor)
 
 2. set the visibility to your component in the callback method (based on 
 your Model)
 
 3. add the component to the AjaxRequestTarget so that it is updated 
 
 Another solution would be to override the isVisible method and return the 
 visibility based on your model and then only add the component to the 
 AjaxRequestTarget.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the 
 parent component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
 super(id, model);
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
 pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
 ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 



Re: update visibility of resourcelink

2015-05-10 Thread Tobias Soloschenko
Hi,

have a look at models in the user guide there are some good approaches to 
update them.

Visibility:

ResourceLink pl = new ResourceLink(pdfLink, new 
ByteArrayResource(application/pdf)) {

// visibility method

}

kind regards

Tobias

 Am 10.05.2015 um 14:15 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 I have followed your approach (update from parent) and it works. Thanks a lot.
 But could you show me also how to overwrite the visibility directly in the 
 ResourceLink?
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {…}?
 
 By the way, in the panel I have added another list view which does not use 
 the model of the panel but has to calculate the model dynamically.
 With the following code, it seems also to be only called once in the 
 constructor but not via ajaxUpdate. How to change this?
 
 ListModelString listModel = new ListModelString() {
   @Override
public ListString getObject() {
 
 Thanks, Chris
 
 
 Am 09.05.2015 um 20:38 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 In your snippet you put the isVisible in the ByteArrayResource. That's why 
 you get the error message - move it to your ResourceLink 
 
 One easy way to update from parent would be: make a method in your panel 
 which returns your link then make your panel a field in the parent and call 
 the getter in the callback and add the link to your AjaxRequestTarget there.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 20:19 schrieb Chris chris...@gmx.at:
 
 Hi,
 
 thanks, I am getting the message method does not override method from its 
 superclass.
 
 The problem is that I do not have the callback method in this panel but in 
 its parent; I would need to have a getter method so that I can directly 
 access the resource link from the panel instance and change its visibility.
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {
 
  @Override
  protected boolean isVisible() {
  return ;
  }
 
  });
 
 Chris
 
 
 Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Yes - should work because isVisible is inherited from component:
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
 But watch out not to put in expensive calls in it! The user guide is also 
 mentioning a lot about that topic:
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
 At this place it is good to mention the new location of the guide:
 
 http://ci.apache.org/projects/wicket/guide/6.x/
 
 http://ci.apache.org/projects/wicket/guide/7.x/
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you 
 have to set the visibility of your link in the ajax callback via 
 AjaxRequestTarget.
 
 1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true 
 (in your constructor)
 
 2. set the visibility to your component in the callback method (based on 
 your Model)
 
 3. add the component to the AjaxRequestTarget so that it is updated 
 
 Another solution would be to override the isVisible method and return 
 the visibility based on your model and then only add the component to 
 the AjaxRequestTarget.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the 
 parent component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
 super(id, model);
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
 pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
 ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional 

Re: update visibility of resourcelink

2015-05-10 Thread Chris
hi, thanks a lot.

I have done it with a LDM and overriding the isVisible and onDetach method:

model = new LoadableDetachableModelListString() {

@Override
protected ListString load() {
ListString locationsNotInRoute = Lists.newArrayList();
ListString locationsInRoute = Lists.newArrayList();

for (Route route : routingModel.getObject()) {
for (Location location : route.getLocations()) {
locationsInRoute.add(location.getOntologicalName());
}
}


for (Poi poi : user.getSelectedPois()) {
if (!locationsInRoute.contains(poi.getOntologyLocalName())) 
{
locationsNotInRoute.add(poi.getName());
}
}

return locationsNotInRoute;
}

};


ListViewString locationsNotInRoutesView = new 
ListViewString(locationsNotInRoutes, model) {

@Override
protected void populateItem(ListItemString 
listItem) {
listItem.add(new Label(locationNotInRoute, 
listItem.getModel()));

listItem.setOutputMarkupId(true);
}

@Override
public boolean isVisible() {
return calculationDone  
model.getObject().size()  0;
}

};


@Override
public void onDetach() {
if(model != null)
   model.detach();

super.onDetach();
}




 Am 10.05.2015 um 14:25 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 have a look at models in the user guide there are some good approaches to 
 update them.
 
 Visibility:
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf)) {
 
 // visibility method
 
 }
 
 kind regards
 
 Tobias
 
 Am 10.05.2015 um 14:15 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 I have followed your approach (update from parent) and it works. Thanks a 
 lot.
 But could you show me also how to overwrite the visibility directly in the 
 ResourceLink?
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {…}?
 
 By the way, in the panel I have added another list view which does not use 
 the model of the panel but has to calculate the model dynamically.
 With the following code, it seems also to be only called once in the 
 constructor but not via ajaxUpdate. How to change this?
 
 ListModelString listModel = new ListModelString() {
  @Override
   public ListString getObject() {
 
 Thanks, Chris
 
 
 Am 09.05.2015 um 20:38 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 In your snippet you put the isVisible in the ByteArrayResource. That's why 
 you get the error message - move it to your ResourceLink 
 
 One easy way to update from parent would be: make a method in your panel 
 which returns your link then make your panel a field in the parent and call 
 the getter in the callback and add the link to your AjaxRequestTarget there.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 20:19 schrieb Chris chris...@gmx.at:
 
 Hi,
 
 thanks, I am getting the message method does not override method from its 
 superclass.
 
 The problem is that I do not have the callback method in this panel but in 
 its parent; I would need to have a getter method so that I can directly 
 access the resource link from the panel instance and change its visibility.
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {
 
 @Override
 protected boolean isVisible() {
 return ;
 }
 
 });
 
 Chris
 
 
 Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Yes - should work because isVisible is inherited from component:
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
 But watch out not to put in expensive calls in it! The user guide is also 
 mentioning a lot about that topic:
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
 At this place it is good to mention the new location of the guide:
 
 http://ci.apache.org/projects/wicket/guide/6.x/
 
 http://ci.apache.org/projects/wicket/guide/7.x/
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you 
 

Re: update visibility of resourcelink

2015-05-10 Thread Tobias Soloschenko
Yes thats the right way - LDM saves the model object for the whole request! 
(Load method is invoked once per request) - good! 

kind regards

Tobias

 Am 10.05.2015 um 14:47 schrieb Chris chris...@gmx.at:
 
 hi, thanks a lot.
 
 I have done it with a LDM and overriding the isVisible and onDetach method:
 
model = new LoadableDetachableModelListString() {
 
@Override
protected ListString load() {
ListString locationsNotInRoute = Lists.newArrayList();
ListString locationsInRoute = Lists.newArrayList();
 
for (Route route : routingModel.getObject()) {
for (Location location : route.getLocations()) {
locationsInRoute.add(location.getOntologicalName());
}
}
 
 
for (Poi poi : user.getSelectedPois()) {
if 
 (!locationsInRoute.contains(poi.getOntologyLocalName())) {
locationsNotInRoute.add(poi.getName());
}
}
 
return locationsNotInRoute;
}
 
};


ListViewString locationsNotInRoutesView = new 
 ListViewString(locationsNotInRoutes, model) {
 
@Override
protected void populateItem(ListItemString listItem) {
listItem.add(new Label(locationNotInRoute, 
 listItem.getModel()));
 
listItem.setOutputMarkupId(true);
}
 
@Override
public boolean isVisible() {
return calculationDone  model.getObject().size()  0;
}
 
};
 
 
 @Override
 public void onDetach() {
if(model != null)
   model.detach();
 
super.onDetach();
 }
 
 
 
 
 Am 10.05.2015 um 14:25 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 have a look at models in the user guide there are some good approaches to 
 update them.
 
 Visibility:
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf)) {
 
 // visibility method
 
 }
 
 kind regards
 
 Tobias
 
 Am 10.05.2015 um 14:15 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 I have followed your approach (update from parent) and it works. Thanks a 
 lot.
 But could you show me also how to overwrite the visibility directly in the 
 ResourceLink?
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {…}?
 
 By the way, in the panel I have added another list view which does not use 
 the model of the panel but has to calculate the model dynamically.
 With the following code, it seems also to be only called once in the 
 constructor but not via ajaxUpdate. How to change this?
 
 ListModelString listModel = new ListModelString() {
 @Override
  public ListString getObject() {
 
 Thanks, Chris
 
 
 Am 09.05.2015 um 20:38 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 In your snippet you put the isVisible in the ByteArrayResource. That's why 
 you get the error message - move it to your ResourceLink 
 
 One easy way to update from parent would be: make a method in your panel 
 which returns your link then make your panel a field in the parent and 
 call the getter in the callback and add the link to your AjaxRequestTarget 
 there.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 20:19 schrieb Chris chris...@gmx.at:
 
 Hi,
 
 thanks, I am getting the message method does not override method from 
 its superclass.
 
 The problem is that I do not have the callback method in this panel but 
 in its parent; I would need to have a getter method so that I can 
 directly access the resource link from the panel instance and change its 
 visibility.
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {
 
@Override
protected boolean isVisible() {
return ;
}
 
});
 
 Chris
 
 
 Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Yes - should work because isVisible is inherited from component:
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
 But watch out not to put in expensive calls in it! The user guide is 
 also mentioning a lot about that topic:
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
 At this place it is good to mention the new location of the guide:
 
 http://ci.apache.org/projects/wicket/guide/6.x/
 
 http://ci.apache.org/projects/wicket/guide/7.x/
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias 

Re: update visibility of resourcelink

2015-05-09 Thread Tobias Soloschenko
Hi,

the constructor of your panel is only called at a normal request - you have to 
set the visibility of your link in the ajax callback via AjaxRequestTarget.

1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true (in 
your constructor)

2. set the visibility to your component in the callback method (based on your 
Model)

3. add the component to the AjaxRequestTarget so that it is updated 

Another solution would be to override the isVisible method and return the 
visibility based on your model and then only add the component to the 
AjaxRequestTarget.

kind regards

Tobias

 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the parent 
 component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
  super(id, model);
 
  ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
  pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
  ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 

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



Re: update visibility of resourcelink

2015-05-09 Thread Tobias Soloschenko
Yes - should work because isVisible is inherited from component:

http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html

But watch out not to put in expensive calls in it! The user guide is also 
mentioning a lot about that topic:

https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5

At this place it is good to mention the new location of the guide:

http://ci.apache.org/projects/wicket/guide/6.x/

http://ci.apache.org/projects/wicket/guide/7.x/

kind regards

Tobias

 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you have 
 to set the visibility of your link in the ajax callback via 
 AjaxRequestTarget.
 
 1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true (in 
 your constructor)
 
 2. set the visibility to your component in the callback method (based on 
 your Model)
 
 3. add the component to the AjaxRequestTarget so that it is updated 
 
 Another solution would be to override the isVisible method and return the 
 visibility based on your model and then only add the component to the 
 AjaxRequestTarget.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the 
 parent component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
 super(id, model);
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
 pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
 ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 

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



Re: update visibility of resourcelink

2015-05-09 Thread Chris
Hi,

thanks, I am getting the message method does not override method from its 
superclass.

The problem is that I do not have the callback method in this panel but in its 
parent; I would need to have a getter method so that I can directly access the 
resource link from the panel instance and change its visibility.

ResourceLink pl = new ResourceLink(pdfLink, new 
ByteArrayResource(application/pdf) {

@Override
protected boolean isVisible() {
return ;
}

});

Chris


 Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Yes - should work because isVisible is inherited from component:
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
 But watch out not to put in expensive calls in it! The user guide is also 
 mentioning a lot about that topic:
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
 At this place it is good to mention the new location of the guide:
 
 http://ci.apache.org/projects/wicket/guide/6.x/
 
 http://ci.apache.org/projects/wicket/guide/7.x/
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you have 
 to set the visibility of your link in the ajax callback via 
 AjaxRequestTarget.
 
 1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true (in 
 your constructor)
 
 2. set the visibility to your component in the callback method (based on 
 your Model)
 
 3. add the component to the AjaxRequestTarget so that it is updated 
 
 Another solution would be to override the isVisible method and return the 
 visibility based on your model and then only add the component to the 
 AjaxRequestTarget.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the 
 parent component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
 super(id, model);
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
 pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
 ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


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



Re: update visibility of resourcelink

2015-05-09 Thread Chris
Hi Tobias,

thanks! Can the isVisible method be directly overridden also by  a 
ResourceLink?  

ResourceLink pl = new ResourceLink(..) {
protected boolean isVisible() {…}
}
Chris


 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you have 
 to set the visibility of your link in the ajax callback via AjaxRequestTarget.
 
 1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true (in 
 your constructor)
 
 2. set the visibility to your component in the callback method (based on your 
 Model)
 
 3. add the component to the AjaxRequestTarget so that it is updated 
 
 Another solution would be to override the isVisible method and return the 
 visibility based on your model and then only add the component to the 
 AjaxRequestTarget.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the 
 parent component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
 super(id, model);
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
 pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
 ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 



Re: update visibility of resourcelink

2015-05-09 Thread Tobias Soloschenko
In your snippet you put the isVisible in the ByteArrayResource. That's why you 
get the error message - move it to your ResourceLink 

One easy way to update from parent would be: make a method in your panel which 
returns your link then make your panel a field in the parent and call the 
getter in the callback and add the link to your AjaxRequestTarget there.

kind regards

Tobias

 Am 09.05.2015 um 20:19 schrieb Chris chris...@gmx.at:
 
 Hi,
 
 thanks, I am getting the message method does not override method from its 
 superclass.
 
 The problem is that I do not have the callback method in this panel but in 
 its parent; I would need to have a getter method so that I can directly 
 access the resource link from the panel instance and change its visibility.
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {
 
@Override
protected boolean isVisible() {
return ;
}
 
});
 
 Chris
 
 
 Am 09.05.2015 um 20:12 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Yes - should work because isVisible is inherited from component:
 
 http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/link/ResourceLink.html
 
 But watch out not to put in expensive calls in it! The user guide is also 
 mentioning a lot about that topic:
 
 https://wicket.apache.org/guide/guide/bestpractices.html#bestpractices_5
 
 At this place it is good to mention the new location of the guide:
 
 http://ci.apache.org/projects/wicket/guide/6.x/
 
 http://ci.apache.org/projects/wicket/guide/7.x/
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:58 schrieb Chris chris...@gmx.at:
 
 Hi Tobias,
 
 thanks! Can the isVisible method be directly overridden also by  a 
 ResourceLink?  
 
 ResourceLink pl = new ResourceLink(..) {
 protected boolean isVisible() {…}
 }
 Chris
 
 
 Am 09.05.2015 um 19:46 schrieb Tobias Soloschenko 
 tobiassolosche...@googlemail.com:
 
 Hi,
 
 the constructor of your panel is only called at a normal request - you 
 have to set the visibility of your link in the ajax callback via 
 AjaxRequestTarget.
 
 1. setOutputMarkupId and setOutputMarkupPlaceholder of the link to true 
 (in your constructor)
 
 2. set the visibility to your component in the callback method (based on 
 your Model)
 
 3. add the component to the AjaxRequestTarget so that it is updated 
 
 Another solution would be to override the isVisible method and return the 
 visibility based on your model and then only add the component to the 
 AjaxRequestTarget.
 
 kind regards
 
 Tobias
 
 Am 09.05.2015 um 19:29 schrieb Chris chris...@gmx.at:
 
 Hi all,
 
 currently, the visibility of the resource link is not updated when the 
 parent component of the panel is rendered again based on an ajax call.
 
 How can the visibility set dynamically based on the model’s data?
 
 Thanks, Chris
 
 public SomePanel(String id, final IModelListA model) {
 super(id, model);
 
 ResourceLink pl = new ResourceLink(pdfLink, new 
 ByteArrayResource(application/pdf) {...}
 pl.setVisible(routingModel.getObject().get(0).getElements().size()  0);
 ...
 }
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 

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