Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public void setSelected(Object object) {
}
}

public final void setEntityClass(String entityClass) {
public void setEntityClass(String entityClass) {
try {
Class clazz = Class.forName(entityClass);
setEntityClass(clazz);
Expand All @@ -336,11 +336,11 @@ public final void setEntityClass(String entityClass) {
}
}

public final void setEntityClassName(String entityClassName) {
public void setEntityClassName(String entityClassName) {
setEntityClass(entityClassName);
}

public final void setEntityClass(Class entityClass) {
public void setEntityClass(Class entityClass) {
this.entityClass = entityClass;
if (entityClass != null) {
entityName = StringUtils.addSpaceBetweenWords(entityClass.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,20 @@ public void customize(String viewTypeName, Field field) {
} else if (field.getFieldClass() == Boolean.class || field.getFieldClass() == boolean.class) {
field.setComponentClass(Checkbox.class);
field.set("disabled", true);
} else {
field.setComponentClass(Label.class);
}

if (field.getComponent() != null && !field.getComponent().isBlank() && field.getComponentClass() == null) {
field.setComponentClass(ComponentAliasIndex.getInstance().get(field.getComponent()));
}

Comment on lines +120 to 123
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant component alias resolution: The ComponentAliasIndex lookup at line 121 is redundant with an earlier lookup performed outside this conditional block (at line 103-105, before the field.isVisible() check).

If field.getComponent() was set and the alias exists, componentClass would already be set at line 104, preventing entry into this block. If the alias lookup at line 104 returned null (unrecognized alias), repeating the same lookup here at line 121 will also return null.

This redundancy doesn't cause incorrect behavior but adds unnecessary processing. Consider either: (1) removing lines 103-105 and keeping only this more thorough check that uses isBlank(), or (2) removing lines 120-122 since the alias resolution already happened earlier.

Suggested change
if (field.getComponent() != null && !field.getComponent().isBlank() && field.getComponentClass() == null) {
field.setComponentClass(ComponentAliasIndex.getInstance().get(field.getComponent()));
}

Copilot uses AI. Check for mistakes.
if (field.getComponentClass() != null && field.getComponent() == null) {
field.setComponent(ComponentAliasIndex.getInstance().getAlias(field.getComponentClass()));
}

if (field.getComponentClass() == null && field.getComponent() == null) {
field.setComponentClass(Label.class);
field.setComponent("label");
}
Comment on lines +128 to +131
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new behavior at lines 128-131 sets field.setComponent("label") in addition to setting field.setComponentClass(Label.class). This represents a change in behavior - previously, only componentClass was set to Label.class as a default.

While this change appears correct and maintains consistency between componentClass and component fields (as verified by test testDateboxLocalDate at line 111), there's no explicit test coverage for this specific code path. Consider adding a test that verifies when both componentClass and component are null for a non-form, non-boolean field, both get set to Label.class and "label" respectively.

Copilot uses AI. Check for mistakes.
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import tools.dynamia.viewers.util.ComponentCustomizerUtil;
import tools.dynamia.viewers.util.ViewRendererUtil;
import tools.dynamia.viewers.util.Viewers;
import tools.dynamia.zk.ComponentAliasIndex;
import tools.dynamia.zk.actions.BootstrapButtonActionRenderer;
import tools.dynamia.zk.converters.Util;
import tools.dynamia.zk.ui.Import;
Expand Down Expand Up @@ -288,7 +289,17 @@ protected void renderFieldCell(Binder binder, Listitem item, Object data,
}

protected Component createFieldComponent(Object data, Object cellValue, Field field, Listcell cell) {
Class<?> componentClass = field.getComponentClass() != null ? field.getComponentClass() : Label.class;
Class<?> componentClass = null;
if (field.getComponentClass() != null) {
componentClass = field.getComponentClass();
} else if (field.getComponent() != null && !field.getComponent().isEmpty()) {
componentClass = ComponentAliasIndex.getInstance().get(field.getComponent());
}

if (componentClass == null) {
componentClass = Label.class;
}

Component component = (Component) ObjectOperations.newInstance(componentClass);
if (component != null) {
ZKUtil.changeReadOnly(component, tableView.isReadonly());
Expand Down