Skip to content

Commit

Permalink
ensure all resources have an id.
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Jul 15, 2024
1 parent 0ba5f83 commit 9f776b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public class BaseFormComponent extends BaseComponent {
@PostConstruct
protected void init() {

super.init();

// set default parent field id
this.parentFieldId = this.id;

Expand Down Expand Up @@ -119,7 +121,7 @@ protected void init() {
}
}
}
super.init();

if (StringUtils.isBlank(this.name)) {
this.name = resource.getName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.sling.models.annotations.Model;

import ai.typerefinery.websight.models.components.BaseFormComponent;
import ai.typerefinery.websight.utils.ComponentUtil;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
Expand Down Expand Up @@ -99,10 +100,18 @@ protected void init() {
String name = child.getName();
if (name.equals("label")) {
String id = child.getValueMap().get("id", "");
//ensure child has an id
if (StringUtils.isEmpty(id)) {
id = ComponentUtil.getComponentId(child);
}
this.labelId = this.resource.getName() + (StringUtils.isNotEmpty(id) ? "-" + id : "");
this.labelHidden = false;
} else if (name.equals("field")) {
String id = child.getValueMap().get("id", "");
//ensure child has an id
if (StringUtils.isEmpty(id)) {
id = ComponentUtil.getComponentId(child);
}
this.fieldId = this.resource.getName() + (StringUtils.isNotEmpty(id) ? "-" + id : "");
this.fieldHidden = false;
}
Expand Down

0 comments on commit 9f776b9

Please sign in to comment.