Skip to content

Commit

Permalink
Fix Layer>Publishing dynamic LegendGraphic
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarsballe committed Jan 21, 2016
1 parent 09ca94b commit 2fce040
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Expand Up @@ -8,6 +8,7 @@
import java.io.Serializable;

import org.apache.wicket.AttributeModifier;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.model.IModel;
Expand All @@ -27,15 +28,22 @@ class LegendGraphicAjaxUpdater implements Serializable {

private Image image;

private IModel styleInfoModel;
private IModel<StyleInfo> styleInfoModel;
private IModel<String> urlModel;

private String wmsURL;

public LegendGraphicAjaxUpdater(final String wmsURL, final Image image,
final IModel styleInfoModel) {
final IModel<StyleInfo> styleInfoModel) {
this.wmsURL = wmsURL;
this.image = image;
this.styleInfoModel = styleInfoModel;
this.urlModel = new Model<String>(wmsURL) {
public String getObject() {
return super.getObject();
}
};
this.image.add(new AttributeModifier("src", urlModel));
updateStyleImage(null);
}

Expand All @@ -46,7 +54,7 @@ public void updateStyleImage(AjaxRequestTarget target) {
if (styleInfo != null) {
String style = styleInfo.prefixedName();
url += style;
image.add(new AttributeModifier("src", new Model(url)));
urlModel.setObject(url);
if (target != null) {
target.add(image);
}
Expand Down
Expand Up @@ -67,7 +67,7 @@ public WMSLayerConfig(String id, IModel<LayerInfo> layerModel) {

// the wms url is build without qualification to allow usage of global styles,
// the style name and layer name will be ws qualified instead
String wmsURL = RequestCycle.get().getUrlRenderer().renderFullUrl(Url.parse("wms")) + "?";
String wmsURL = RequestCycle.get().getUrlRenderer().renderContextRelativeUrl("wms") + "?";

final LegendGraphicAjaxUpdater defaultStyleUpdater;
defaultStyleUpdater = new LegendGraphicAjaxUpdater(wmsURL, defStyleImg, defaultStyleModel);
Expand Down

0 comments on commit 2fce040

Please sign in to comment.