Details
-
Improvement
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.4-M2
-
None
Description
Use case:
class MyPanel extends AjaxLazyLoadPanel {
private boolean bool;
public MyPanel(String id, boolean bool)
{ super(id); <-- bool is used in this call this.bool = bool; <-- but not assigned until this call } public getLoadingComponent(String id) {
if (bool)
else
{ return componentB; } }
}
Since getLoadingComponent(String) is called as part of the super constructor then the actual value of 'bool' can never be used. Furthur, if bool were an object instead of a primitive could potentially cause an NPE. Instead the loading component can be created in onBeforeRender():
protected void onBeforeRender() {
if (!renderedOnce)
super.onBeforeRender();
}
... this also requires a change to the ajax behavior:
public boolean isEnabled(Component<?> component) {
return get("content") == loadingComponent || loadingComponent == null;
}