Skip to content

Commit

Permalink
stringResourceModel -> BasePanel, do not use component so the model c…
Browse files Browse the repository at this point in the history
…an be detached. and do not detach what should not be detached
  • Loading branch information
katkav committed Feb 1, 2022
1 parent 6596c1a commit adbf00c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public String getString(Enum<?> e) {
}

public StringResourceModel createStringResource(String resourceKey, IModel<?> model, Object... objects) {
return new StringResourceModel(resourceKey, this).setModel(model)
return new StringResourceModel(resourceKey).setModel(model)
.setDefaultValue(resourceKey)
.setParameters(objects);
}

public StringResourceModel createStringResource(String resourceKey, Object... objects) {
return new StringResourceModel(resourceKey, this).setModel(null)
return new StringResourceModel(resourceKey).setModel(null)
.setDefaultValue(resourceKey)
.setParameters(objects);
}
Expand All @@ -84,7 +84,7 @@ public StringResourceModel createStringResource(PolyString polystringKey, Object
// TODO later: use polystringKey.getKey()
resourceKey = polystringKey.getOrig();
}
return new StringResourceModel(resourceKey, this).setModel(null)
return new StringResourceModel(resourceKey).setModel(null)
.setDefaultValue(resourceKey)
.setParameters(objects);
}
Expand All @@ -95,7 +95,7 @@ public StringResourceModel createStringResource(PolyStringType polystringKey, Ob
// TODO later: use polystringKey.getKey()
resourceKey = polystringKey.getOrig();
}
return new StringResourceModel(resourceKey, this).setModel(null)
return new StringResourceModel(resourceKey).setModel(null)
.setDefaultValue(resourceKey)
.setParameters(objects);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,27 +683,7 @@ public String getObject() {
pageTitleReal.setRenderBodyOnly(true);
pageTitle.add(pageTitleReal);

LoadableDetachableModel<List<Breadcrumb>> breadcrumbsModel = new LoadableDetachableModel<List<Breadcrumb>>() {

private static final long serialVersionUID = 1L;

@Override
protected List<Breadcrumb> load() {
return getBreadcrumbs();
}

@Override
protected void onDetach() {
for (Breadcrumb b : getObject()) {
b.detach();
}
}

// @Override
// public List<Breadcrumb> getObject() {
// return getBreadcrumbs();
// }
};
IModel<List<Breadcrumb>> breadcrumbsModel = () -> getBreadcrumbs();

ListView<Breadcrumb> breadcrumbs = new ListView<>(ID_BREADCRUMB, breadcrumbsModel) {

Expand Down Expand Up @@ -746,14 +726,14 @@ public boolean isVisible() {
Label bcName = new Label(ID_BC_NAME, item.getModelObject().getLabel());
bcLink.add(bcName);

// item.add(new VisibleEnableBehaviour() {
// private static final long serialVersionUID = 1L;
//
// @Override
// public boolean isVisible() {
// return item.getModelObject().isVisible();
// }
// });
item.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;

@Override
public boolean isVisible() {
return item.getModelObject().isVisible();
}
});
}
};
breadcrumbs.add(new VisibleBehaviour(() -> !isErrorPage()));
Expand Down

0 comments on commit adbf00c

Please sign in to comment.