#4-Registrar-empleado #15

Merged
alex merged 3 commits from #4-Registrar-empleado into main 2024-09-06 00:59:20 +00:00
2 changed files with 5 additions and 5 deletions
Showing only changes of commit b88b680e4e - Show all commits

View File

@ -27,7 +27,7 @@ import java.util.UUID;
@PermitAll @PermitAll
@Scope("prototype") @Scope("prototype")
@PageTitle("Employee") @PageTitle("Employee")
@Route(value = "/employees/:action?/:employeeId?", layout = MainLayout.class) @Route(value = "/employees/:employeeId?/:action?", layout = MainLayout.class)
Outdated
Review

el formato de la ruta deberia ser al reves:

/employees/:employeeId/view (para ver y)
/employees/:employeeId/edit (para editar).

el formato de la ruta deberia ser al reves: /employees/:employeeId/view (para ver y) /employees/:employeeId/edit (para editar).
public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> { public class EmployeeView extends BeanValidationForm<Employee> implements HasUrlParameter<String> {
private static final String SAVE_BUTTON_TEXT = "Save"; private static final String SAVE_BUTTON_TEXT = "Save";
@ -163,9 +163,9 @@ public class EmployeeView extends BeanValidationForm<Employee> implements HasUrl
} }
@Override @Override
public void setParameter(final BeforeEvent beforeEvent, final String s) { public void setParameter(final BeforeEvent beforeEvent, final String action) {
RouteParameters params = beforeEvent.getRouteParameters(); RouteParameters params = beforeEvent.getRouteParameters();
String action = params.get("action").orElse("new"); String s = params.get("employeeId").orElse(null);
if ("new".equals(action)) { if ("new".equals(action)) {
setEntityWithEnabledSave(new Employee()); setEntityWithEnabledSave(new Employee());

View File

@ -68,11 +68,11 @@ public class EmployeesListView extends Main {
} }
private void navigateToEditView(final Employee employee) { private void navigateToEditView(final Employee employee) {
getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, "edit/" + employee.getId().toString())); getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, employee.getId().toString() + "/edit"));
} }
private void navigateToEmployeeView(final Employee employee) { private void navigateToEmployeeView(final Employee employee) {
getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, "view/" + employee.getId().toString())); getUI().ifPresent(ui -> ui.navigate(EmployeeView.class, employee.getId().toString() + "/view"));
} }
private void navigateToAddEmployeeView() { private void navigateToAddEmployeeView() {