Sending query parameter in url link is not working

I have 2 parameters sent from menu followed by from List Screen to the detail screen which is working fine. However, it is not working in the following use case -

I am sending url in generated email for the detail screen for the user to open it directly. It is working for other screens but not this one.

Here is the controller code of list screen from where it is working smoothly:

   protected String userType;
    protected String waType;
    @Autowired
    private Dialogs dialogs;

    @Override
    public void beforeEnter(BeforeEnterEvent event) {
        Map<String, List<String>> parameters = event.getLocation().getQueryParameters().getParameters();
        if (parameters.containsKey("userType")) {
            parameters.get("userType").stream()
                    .findAny()
                    .ifPresent(this::setUserType);
        }
        if (parameters.containsKey("waType")) {
            parameters.get("waType").stream()
                    .findAny()
                    .ifPresent(this::setWaType);
        }
        super.beforeEnter(event);
    }

    public void setUserType(String uType) {
        this.userType = uType;
    }
    public void setWaType(String wType) {
        this.waType = wType;
    }


    @Subscribe
    public void onQueryParametersChange(QueryParametersChangeEvent event) {
        QueryParameters queryParameters = event.getQueryParameters();

        // Extract userType from query parameters
        String newUserType = queryParameters.getParameters().getOrDefault("userType", List.of()).stream()
                .findFirst()
                .orElse(null);

        if (newUserType != null) {
            userType = newUserType;
        }

        workAwayOfficesDl.setQuery(null);

        // Reload data with the updated userType
        loadListData();
    }



    private void loadListData() {
        if ("hr".equals(userType)) {

            workAwayOfficesDl.removeParameter("employeeProfileId");

            List<UUID> companyIdList = inteaccMDGGeneralBean.getCompanyIdListAuthorized();
            List<UUID> operatingLocationIdList = inteaccMDGGeneralBean.getOperatingLocIdListAuthorized();
            List<UUID> funcAreaIdList = inteaccMDGGeneralBean.getFunctionalAreaIdListAuthorized();

            Map<String, Object> queryParams = new HashMap<>();
            queryParams.put("companyIdList", companyIdList);
            queryParams.put("workAwayType", waType.equalsIgnoreCase("wfa")? WorkAwayType.WORK_FROM_ANYWHERE : WorkAwayType.VISIT);
            queryParams.put("operatingLocationIdList", operatingLocationIdList);

            // Only include `functionalAreaList` if it's not empty
            if (!funcAreaIdList.isEmpty()) {
                queryParams.put("functionalAreaList", funcAreaIdList);
            }

            // Ensure the query dynamically handles `functionalAreaList`
            workAwayOfficesDl.setQuery("select e from hr_WorkAwayOffice e " +
                    "where e.employeeProfile.company.id in :companyIdList " +
                    "and e.employeeProfile.operatingLocation.id in :operatingLocationIdList " +
                    "and e.workAwayType = :workAwayType " +
                    "and (:functionalAreaList is null or e.employeeProfile.functionalArea.id in :functionalAreaList)");

            workAwayOfficesDl.setParameters(queryParams);
            workAwayOfficesDl.load();

        } else if ("employee".equals(userType)) {
            workAwayOfficesDl.removeParameter("functionalAreaList");
            workAwayOfficesDl.removeParameter("companyIdList");
            workAwayOfficesDl.removeParameter("operatingLocationIdList");

            UUID emplId = (UUID) sessionData.getAttribute("emplProfileId");

            if (emplId == null) {
                throw new IllegalStateException("Employee Profile ID is missing from session data");
            }

            workAwayOfficesDl.setQuery("select e from hr_WorkAwayOffice e " +
                    "where e.employeeProfile.id = :employeeProfileId and e.workAwayType = :workAwayType");

            workAwayOfficesDl.setParameters(ParamsMap.of("employeeProfileId", emplId, "workAwayType", waType.equalsIgnoreCase("wfa") ? WorkAwayType.WORK_FROM_ANYWHERE : WorkAwayType.VISIT));
            workAwayOfficesDl.load();
        }
    }

Here is what I have in email sending method:
(…MainServiceBean)

 } else if (workflowStatus.equals(WorkflowStatus.RETURNED_FOR_CORRECTION)) {
                subject = messages.getMessage("ApplicationReturnedSubject") + workflowTask.getWorkflow().getName();
               // bodyText = "Your application no. " + workflowTask.getDocNumber() + " has been returned for correction ";

                //Email link
                String screenName = this.getScreenNameFromEntityName(workflowTask.getEntityName());
                String fullurl = "";
                String waType="";
                if(workflow.getWfCategory().equals(WfCategory.WORK_FROM_ANYWHERE)){
                    fullurl = inteaccWorkflowServiceBean.getBaseUrl() + "/" + screenName + "/" + workflowTask.getEntityId() + "?&userType=employee&waType=wfa";
                }else if(workflow.getWfCategory().equals(WfCategory.VISIT)){
                    fullurl = inteaccWorkflowServiceBean.getBaseUrl() + "/" + screenName + "/" + workflowTask.getEntityId() + "?&userType=employee&waType=visit";

                }else {
                    fullurl = inteaccWorkflowServiceBean.getBaseUrl() + "/" + screenName + "/" + workflowTask.getEntityId() + "?&userType=employee";
                }

                String linkText = "Please click on the link below to display the application:\n\n" + fullurl +"\n\n\nThank you.";

log.info("fullurl " +fullurl);

                bodyText = messages.getMessage("ApplicationReturned") + workflow.getName() +", Application no. "+ workflowTask.getDocNumber() +"\n\n"+linkText;
            }

            emailServiceBean.sendEmailToEmployee(subject, bodyText, workflowTask.getEmplProfile().getId());

This is the url generated:

http://localhost:8081/workAwayOffices/01961dec-16e5-7e2b-a58f-a9dabc04ecc3?&userType=employee&waType=wfa

When I click on the generated url, I get the following error:

image

Here is detail screen controller code:

    protected String userType;
    protected String waType;

    public void setUserType(String uType) {
        userType = uType;
    }
    public void setWaType(String wType) {
        waType = wType;
    }
    protected boolean recallAppl;
    public void setRecallAppl(boolean recallAppl1) {
        recallAppl = recallAppl1;
    }

    EmployeeProfile employeeProfileApplicant = null;
    @ViewComponent("tabSheet.tabDoc")
    private Tab tabSheetTabDoc;


    @Subscribe
    public void onInit(final InitEvent event) {

        workAwayOfficeLineDataGrid.addClassName("styling");
        workAwayOfficeLineDataGrid.setPartNameGenerator(person -> {
            if (person.getWeekendOrHoliday()==true) {
                return "low-rating";
            }
            return null;
        });

    }



    @Subscribe
    public void onBeforeShow(final BeforeShowEvent event) {
        if (entityStates.isNew(getEditedEntity())) {
            getEditedEntity().setProcessState(ProcessState.DRAFT);
            getEditedEntity().setDocDate(LocalDate.now());
            getEditedEntity().setDestinationType(DestinationType.DOMESTIC);

            final LeaveYear leaveYear = unconstrainedDataManager.load(LeaveYear.class)
                    .query("select l from mdg_LeaveYear l where l.currentLeaveYear = true")
                    .optional().orElse(null);
            if (leaveYear != null) {
                getEditedEntity().setLeaveYear(leaveYear);
            } else {
                notifications.create("You don't have access to leave year, please consult your admin")
                        .withDuration(3000)
                        .withCloseable(false)
                        .withType(Notifications.Type.ERROR)
                        .show();
            }


            if (userType==null || userType.equalsIgnoreCase("employee")) {
                UUID emplId = (UUID) sessionData.getAttribute("emplProfileId");
                if (emplId != null) {
                    loadEmployeeData();
                }

            } else { //hr
                loadEmployeeList();

                //If the transaction is created by HR user, approve it automatically and hide the workflow button
                getEditedEntity().setProcessState(ProcessState.APPROVED);

                initWorkflowBtn.setVisible(false);
            }


        } else {

            if(recallAppl==false) {
                employeeProfileField.setReadOnly(true);
                if (getEditedEntity().getProcessState().equals(ProcessState.APPROVED) || getEditedEntity().getProcessState().equals(ProcessState.APPROVAL_IN_PROGRESS)
                        || getEditedEntity().getProcessState().equals(ProcessState.REJECTED)  || getEditedEntity().getProcessState().equals(ProcessState.CANCELLED))
                    this.setReadOnly(true);
            }else{
                if(recallAppl){
                    getEditedEntity().setProcessState(ProcessState.DRAFT);
                }else{
                    if (getEditedEntity().getProcessState().equals(ProcessState.APPROVED) || getEditedEntity().getProcessState().equals(ProcessState.APPROVAL_IN_PROGRESS)
                            || getEditedEntity().getProcessState().equals(ProcessState.REJECTED)  || getEditedEntity().getProcessState().equals(ProcessState.CANCELLED))
                        this.setReadOnly(true);
                }
            }

            this.displayFile();
        }


        if (userType==null || userType.equalsIgnoreCase("employee")) {
            companyField.setReadOnly(true);
            operatingLocationField.setReadOnly(true);
            employeeProfileField.setReadOnly(true);
            if (getEditedEntity().getProcessState().equals(ProcessState.APPROVED))
                this.setReadOnly(true);

        }

        initWorkflowBtn.setVisible(true);
        //For Workflow
        if (inteaccWorkflowServiceBean.findWorkflowProfileByWfCategory(WfCategory.WORK_FROM_ANYWHERE, null) == null) {
            initWorkflowBtn.setVisible(false);
        } else {
            if (getEditedEntity().getProcessState() == ProcessState.APPROVAL_IN_PROGRESS) {
                saveAndCloseBtn.setVisible(false);
                closeBtn.setText("CLOSE");
                initWorkflowBtn.setVisible(false);

            } else if (getEditedEntity().getProcessState() == ProcessState.APPROVED) {
                if (entityStates.isNew(getEditedEntity())) {
                    //saveAndCloseBtn.setEnabled(false);
                    saveAndCloseBtn.setText("APPROVE");
                    initWorkflowBtn.setVisible(false);
                } else {
                    saveAndCloseBtn.setEnabled(false);
                    saveAndCloseBtn.setText("APPROVED");
                    initWorkflowBtn.setVisible(false);
                }
            } else if (getEditedEntity().getProcessState() == ProcessState.REJECTED) {
                saveAndCloseBtn.setEnabled(false);
                saveAndCloseBtn.setText("REJECTED");
                initWorkflowBtn.setVisible(false);

            } else {
                saveAndCloseBtn.setVisible(false);
                if (userType != null && userType.equalsIgnoreCase("employee")) {

                    initWorkflowBtn.setText("SUBMIT");

                }
                if (getEditedEntity().getProcessState() == ProcessState.RETURNED_FOR_CORRECTION ||
                        getEditedEntity().getProcessState() == ProcessState.RECALLED_FOR_CORRECTION) {
                    initWorkflowBtn.setText("RE-SUBMIT");
                    this.setReadOnly(false);
                }
            }

            //Show or hide workflow Task status
            //----------------------------------
            if (!entityStates.isNew(getEditedEntity())) {
                tabSheetTabApproval.setVisible(true);
                workflowTaskLinesDl.setParameters(ParamsMap.of("entityName", metadata.getClass(getEditedEntity()).getName(), "entityId", getEditedEntity().getId()));
                workflowTaskLinesDl.load();
            } else {
                tabSheetTabApproval.setVisible(false);
            }

        }

        if (getEditedEntity().getWorkAwayType()!=null && getEditedEntity().getWorkAwayType().equals(WorkAwayType.VISIT)) {
            DataGrid.Column<?> column = workAwayOfficeLineDataGrid.getColumnByKey("visitLocation");
            if (column != null) {
                column.setHeader("Visit Location");
            }
            deliverablesField.setLabel("Visit Purpose");
           // workAddressField.setLabel("Visit Address");
        }else{
            DataGrid.Column<?> column = workAwayOfficeLineDataGrid.getColumnByKey("visitLocation");
            if (column != null) {
                column.setHeader("Location");
            }

        }

        if (this.isReadOnly()) {
            addDatesBtn.setVisible(false);
            Action addDatesAction = workflowTaskLinesDataGrid.getAction("addDates");
            if (addDatesAction != null) {
                addDatesAction.setEnabled(false);
            }
        }

    }

    @Subscribe
    public void onReady(final ReadyEvent event) {
        if(entityStates.isNew(getEditedEntity())){
            if(waType!=null) {
                if (waType.equalsIgnoreCase("wfa")) {
                    getEditedEntity().setWorkAwayType(WorkAwayType.WORK_FROM_ANYWHERE);
                    deliverablesField.setLabel("Deliverables");

                    visitStartTimeField.setVisible(false);
                    visitEndTimeField.setVisible(false);

                } else {
                    getEditedEntity().setWorkAwayType(WorkAwayType.VISIT);
                    deliverablesField.setLabel("Visit Purpose");
                    workAddressField.setLabel("Visit Address");

        //            log.info("WorkAwayType.VISIT ");

                }
            }else{
                notifications.create("waType is null")
                        .show();
            }
        }else{
            if (waType.equalsIgnoreCase("wfa")) {
                deliverablesField.setLabel("Deliverables");
                visitStartTimeField.setVisible(false);
                visitEndTimeField.setVisible(false);

            } else {
                deliverablesField.setLabel("Visit Purpose");
                workAddressField.setLabel("Visit Address");
            }
        }

        this.showHideFields();
    }

How can I solve the problem related to null query parameter value?

Hi, @mortoza_khan

In the list screen example, the waType variable is initialized in the beforeEnter method. But there is no such logic in the provided detail view controller. Is it a full code snippet or the variable initialization is missing?

Regards,
Maria.

Hi Maria
Yes, it is declared. Pls find below the full code from the detail screen controller:

@Route(value = "workAwayOffices/:id", layout = DefaultMainViewParent.class)
@ViewController("hr_WorkAwayOffice.detail")
@ViewDescriptor("work-away-office-detail-view.xml")
@EditedEntityContainer("workAwayOfficeDc")
public class WorkAwayOfficeDetailView extends StandardDetailView<WorkAwayOffice> {
    private static final Logger log = LoggerFactory.getLogger(WorkAwayOfficeDetailView.class);
    @ViewComponent
    private FormLayout form;
    @Autowired
    private EntityStates entityStates;

    @Autowired
    private SessionData sessionData;
    @Autowired
    private DialogWindows dialogWindows;

    @ViewComponent
    private DataContext dataContext;
    @Autowired
    private InteaccMDGGeneralBean inteaccMDGGeneralBean;
    @ViewComponent
    private CollectionLoader<EmployeeProfile> employeeProfilesDl;
    @Autowired
    private InteaccLeaveServiceBean inteaccLeaveServiceBean;
    @Autowired
    private Notifications notifications;
    @ViewComponent
    private JmixButton saveAndCloseBtn;
    @ViewComponent
    private EntityComboBox<Company> companyField;
    @ViewComponent
    private EntityComboBox<OperatingLocation> operatingLocationField;
    @ViewComponent
    private EntityComboBox<EmployeeProfile> employeeProfileField;
    @ViewComponent
    private JmixButton initWorkflowBtn;
    @Autowired
    private InteaccWorkflowServiceBean inteaccWorkflowServiceBean;
    @ViewComponent
    private JmixButton closeBtn;
    @Autowired
    private Dialogs dialogs;
    @ViewComponent
    private CollectionPropertyContainer<WorkAwayOfficeLine> workAwayOfficeLineDc;
    @ViewComponent
    private DataGrid<WorkflowTaskLine> workflowTaskLinesDataGrid;
    @ViewComponent
    private CollectionLoader<WorkflowTaskLine> workflowTaskLinesDl;
    @Autowired
    private Metadata metadata;
    @Autowired
    private InteaccHrServiceBean inteaccHrServiceBean;
    @ViewComponent
    private JmixButton addDatesBtn;
    @Autowired
    private UnconstrainedDataManager unconstrainedDataManager;

    @ViewComponent
    private TypedTextField<LeaveYear> leaveYearField;
    @ViewComponent
    private TypedTextField<Double> totalDaysField;
    @Autowired
    private UiComponents uiComponents;
    @ViewComponent
    private DataGrid<WorkAwayOfficeLine> workAwayOfficeLineDataGrid;
    @Autowired
    private TemporaryStorage temporaryStorage;
    @Autowired
    private FileStorageLocator fileStorageLocator;
    @ViewComponent
    private VerticalLayout filedisplay;
    @ViewComponent("tabSheet.tabApproval")
    private Tab tabSheetTabApproval;
    @ViewComponent
    private JmixTextArea deliverablesField;
    @ViewComponent
    private FileStorageUploadField fileRefItineraryField;
    @ViewComponent
    private DetailSaveCloseAction<Object> saveAction;
    @ViewComponent
    private TypedTimePicker<Date> visitStartTimeField;
    @ViewComponent
    private TypedTimePicker<Date> visitEndTimeField;
    @ViewComponent
    private JmixTextArea workAddressField;
    protected String userType;
    protected String waType;

    public void setUserType(String uType) {
        userType = uType;
    }
    public void setWaType(String wType) {
        waType = wType;
    }
    protected boolean recallAppl;
    public void setRecallAppl(boolean recallAppl1) {
        recallAppl = recallAppl1;
    }

    EmployeeProfile employeeProfileApplicant = null;
    @ViewComponent("tabSheet.tabDoc")
    private Tab tabSheetTabDoc;


    @Subscribe
    public void onInit(final InitEvent event) {

        workAwayOfficeLineDataGrid.addClassName("styling");
        workAwayOfficeLineDataGrid.setPartNameGenerator(person -> {
            if (person.getWeekendOrHoliday()!=null && person.getWeekendOrHoliday()==true) {
                return "low-rating";
            }
            return null;
        });

    }



    @Subscribe
    public void onBeforeShow(final BeforeShowEvent event) {
        if (entityStates.isNew(getEditedEntity())) {
            getEditedEntity().setProcessState(ProcessState.DRAFT);
            getEditedEntity().setDocDate(LocalDate.now());
            getEditedEntity().setDestinationType(DestinationType.DOMESTIC);

            final LeaveYear leaveYear = unconstrainedDataManager.load(LeaveYear.class)
                    .query("select l from mdg_LeaveYear l where l.currentLeaveYear = true")
                    .optional().orElse(null);
            if (leaveYear != null) {
                getEditedEntity().setLeaveYear(leaveYear);
            } else {
                notifications.create("You don't have access to leave year, please consult your admin")
                        .withDuration(3000)
                        .withCloseable(false)
                        .withType(Notifications.Type.ERROR)
                        .show();
            }


            if (userType==null || userType.equalsIgnoreCase("employee")) {
                UUID emplId = (UUID) sessionData.getAttribute("emplProfileId");
                if (emplId != null) {
                    loadEmployeeData();
                }

            } else { //hr
                loadEmployeeList();

                //If the transaction is created by HR user, approve it automatically and hide the workflow button
                getEditedEntity().setProcessState(ProcessState.APPROVED);

                initWorkflowBtn.setVisible(false);
            }


        } else {

            if(recallAppl==false) {
                employeeProfileField.setReadOnly(true);
                if (getEditedEntity().getProcessState().equals(ProcessState.APPROVED) || getEditedEntity().getProcessState().equals(ProcessState.APPROVAL_IN_PROGRESS)
                        || getEditedEntity().getProcessState().equals(ProcessState.REJECTED)  || getEditedEntity().getProcessState().equals(ProcessState.CANCELLED))
                    this.setReadOnly(true);
            }else{
                if(recallAppl){
                    getEditedEntity().setProcessState(ProcessState.DRAFT);
                }else{
                    if (getEditedEntity().getProcessState().equals(ProcessState.APPROVED) || getEditedEntity().getProcessState().equals(ProcessState.APPROVAL_IN_PROGRESS)
                            || getEditedEntity().getProcessState().equals(ProcessState.REJECTED)  || getEditedEntity().getProcessState().equals(ProcessState.CANCELLED))
                        this.setReadOnly(true);
                }
            }

            this.displayFile();
        }


        if (userType==null || userType.equalsIgnoreCase("employee")) {
            companyField.setReadOnly(true);
            operatingLocationField.setReadOnly(true);
            employeeProfileField.setReadOnly(true);
            if (getEditedEntity().getProcessState().equals(ProcessState.APPROVED))
                this.setReadOnly(true);

        }

        //from onReady
        if(entityStates.isNew(getEditedEntity())){
            if(waType!=null) {
                if (waType.equalsIgnoreCase("wfa")) {
                    getEditedEntity().setWorkAwayType(WorkAwayType.WORK_FROM_ANYWHERE);
                    deliverablesField.setLabel("Deliverables");

                    visitStartTimeField.setVisible(false);
                    visitEndTimeField.setVisible(false);

                } else {
                    getEditedEntity().setWorkAwayType(WorkAwayType.VISIT);
                    deliverablesField.setLabel("Visit Purpose");
                    workAddressField.setLabel("Visit Address");

                    //            log.info("WorkAwayType.VISIT ");

                }
            }else{
                notifications.create("waType is null")
                        .show();
            }
        }else{
            if(waType!=null) {
                if (waType.equalsIgnoreCase("wfa")) {
                    deliverablesField.setLabel("Deliverables");
                    visitStartTimeField.setVisible(false);
                    visitEndTimeField.setVisible(false);

                } else {
                    deliverablesField.setLabel("Visit Purpose");
                    workAddressField.setLabel("Visit Address");
                }
            }else{
                notifications.create("waType is null")
                        .show();
            }
        }



        initWorkflowBtn.setVisible(true);
        //For Workflow
        if (inteaccWorkflowServiceBean.findWorkflowProfileByWfCategory(WfCategory.WORK_FROM_ANYWHERE, null) == null) {
            initWorkflowBtn.setVisible(false);
        } else {
            if (getEditedEntity().getProcessState() == ProcessState.APPROVAL_IN_PROGRESS) {
                saveAndCloseBtn.setVisible(false);
                closeBtn.setText("CLOSE");
                initWorkflowBtn.setVisible(false);

            } else if (getEditedEntity().getProcessState() == ProcessState.APPROVED) {
                if (entityStates.isNew(getEditedEntity())) {
                    //saveAndCloseBtn.setEnabled(false);
                    saveAndCloseBtn.setText("APPROVE");
                    initWorkflowBtn.setVisible(false);
                } else {
                    saveAndCloseBtn.setEnabled(false);
                    saveAndCloseBtn.setText("APPROVED");
                    initWorkflowBtn.setVisible(false);
                }
            } else if (getEditedEntity().getProcessState() == ProcessState.REJECTED) {
                saveAndCloseBtn.setEnabled(false);
                saveAndCloseBtn.setText("REJECTED");
                initWorkflowBtn.setVisible(false);

            } else {
                saveAndCloseBtn.setVisible(false);
                if (userType != null && userType.equalsIgnoreCase("employee")) {

                    initWorkflowBtn.setText("SUBMIT");

                }
                if (getEditedEntity().getProcessState() == ProcessState.RETURNED_FOR_CORRECTION ||
                        getEditedEntity().getProcessState() == ProcessState.RECALLED_FOR_CORRECTION) {
                    initWorkflowBtn.setText("RE-SUBMIT");
                    this.setReadOnly(false);
                }
            }

            //Show or hide workflow Task status
            //----------------------------------
            if (!entityStates.isNew(getEditedEntity())) {
                tabSheetTabApproval.setVisible(true);
                workflowTaskLinesDl.setParameters(ParamsMap.of("entityName", metadata.getClass(getEditedEntity()).getName(), "entityId", getEditedEntity().getId()));
                workflowTaskLinesDl.load();
            } else {
                tabSheetTabApproval.setVisible(false);
            }

        }

        if (getEditedEntity().getWorkAwayType()!=null && getEditedEntity().getWorkAwayType().equals(WorkAwayType.VISIT)) {
            DataGrid.Column<?> column = workAwayOfficeLineDataGrid.getColumnByKey("visitLocation");
            if (column != null) {
                column.setHeader("Visit Location");
            }
            deliverablesField.setLabel("Visit Purpose");
           // workAddressField.setLabel("Visit Address");
        }else{
            DataGrid.Column<?> column = workAwayOfficeLineDataGrid.getColumnByKey("visitLocation");
            if (column != null) {
                column.setHeader("Location");
            }

        }

        if (this.isReadOnly()) {
            addDatesBtn.setVisible(false);
            Action addDatesAction = workflowTaskLinesDataGrid.getAction("addDates");
            if (addDatesAction != null) {
                addDatesAction.setEnabled(false);
            }
        }

    }

    @Subscribe
    public void onReady(final ReadyEvent event) {
        /*
        if(entityStates.isNew(getEditedEntity())){
            if(waType!=null) {
                if (waType.equalsIgnoreCase("wfa")) {
                    getEditedEntity().setWorkAwayType(WorkAwayType.WORK_FROM_ANYWHERE);
                    deliverablesField.setLabel("Deliverables");

                    visitStartTimeField.setVisible(false);
                    visitEndTimeField.setVisible(false);

                } else {
                    getEditedEntity().setWorkAwayType(WorkAwayType.VISIT);
                    deliverablesField.setLabel("Visit Purpose");
                    workAddressField.setLabel("Visit Address");

        //            log.info("WorkAwayType.VISIT ");

                }
            }else{
                notifications.create("waType is null")
                        .show();
            }
        }else{
            if (waType.equalsIgnoreCase("wfa")) {
                deliverablesField.setLabel("Deliverables");
                visitStartTimeField.setVisible(false);
                visitEndTimeField.setVisible(false);

            } else {
                deliverablesField.setLabel("Visit Purpose");
                workAddressField.setLabel("Visit Address");
            }
        }
    */

        this.showHideFields();
    }

    private void showHideFields(){
        if(getEditedEntity().getWorkAwayType()!=null){
            //   destinationTypeField.setVisible(getEditedEntity().getWorkAwayType().equals(WorkAwayType.VISIT));
            if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)){
                leaveYearField.setLabel("WFA Year");
                totalDaysField.setHelperText("Updated after adding the WFA Dates");
                waType ="wfa";
                tabSheetTabDoc.setVisible(false);
                fileRefItineraryField.setVisible(false);
            }else{
                leaveYearField.setLabel("Visit Year");
                totalDaysField.setHelperText("Updated after adding the Visit Dates");
                waType ="visit";
               // deliverablesField.setLabel("Visit Purpose");
                tabSheetTabDoc.setVisible(true);
                fileRefItineraryField.setVisible(true);
            }
        }
    }

    @Subscribe(id = "workAwayOfficeDc", target = Target.DATA_CONTAINER)
    public void onWorkAwayOfficeDcItemPropertyChange(final InstanceContainer.ItemPropertyChangeEvent<WorkAwayOffice> event) {
        if ("company".equals(event.getProperty()) || "operatingLocation".equals(event.getProperty())) {
            if (event.getItem().getCompany() != null && event.getItem().getOperatingLocation() != null) {

                loadEmployeeList();
            }
        }else if("workAwayType".equals(event.getProperty()) && event.getItem().getWorkAwayType()!=null){
        //    destinationTypeField.setVisible(getEditedEntity().getWorkAwayType().equals(WorkAwayType.VISIT));

            loadEmployeeData();
        }
    }


    private void loadEmployeeData(){
        if (userType.equalsIgnoreCase("employee")) {
            UUID emplId = (UUID) sessionData.getAttribute("emplProfileId");
            if (emplId != null) {

                employeeProfileApplicant = unconstrainedDataManager.load(EmployeeProfile.class).id(emplId)
                        .fetchPlanProperties("emplNumber", "employeeCode", "name", "firstName", "middleName", "lastName", "company", "company.compId", "operatingLocation", "operatingLocation.operLocCode", "operatingLocation.name", "leaveProfile", "scheduleWorkCalendar", "joinDateActual", "emplCategory", "employeeGroup")
                        .one();
                if(getEditedEntity().getWorkAwayType()!=null) {
                    if (getEditedEntity().getWorkAwayType().equals(WorkAwayType.VISIT)) {
                        getEditedEntity().setEmployeeProfile(employeeProfileApplicant);
                        getEditedEntity().setCompany(employeeProfileApplicant.getCompany());
                        getEditedEntity().setOperatingLocation(employeeProfileApplicant.getOperatingLocation());
                        deliverablesField.setLabel("Visit purpose");
                    } else {
                        deliverablesField.setLabel("Deliverables");
                        final EmplCatWorkAwayRule emplCatWorkAwayRule = unconstrainedDataManager.load(EmplCatWorkAwayRule.class)
                                .query("select e from hmd_EmplCatWorkAwayRule e " +
                                        "where e.company = :company1 " +
                                        "and e.emplCategory = :emplCategory1 " +
                                        "and e.employeeGroup = :employeeGroup1")
                                .parameter("company1", employeeProfileApplicant.getCompany())
                                .parameter("emplCategory1", employeeProfileApplicant.getEmplCategory())
                                .parameter("employeeGroup1", employeeProfileApplicant.getEmployeeGroup())
                                .optional().orElse(null);

                        if (emplCatWorkAwayRule != null && emplCatWorkAwayRule.getWorkAwayOfficeAllowed()) {
                            getEditedEntity().setEmployeeProfile(employeeProfileApplicant);
                            getEditedEntity().setCompany(employeeProfileApplicant.getCompany());
                            getEditedEntity().setOperatingLocation(employeeProfileApplicant.getOperatingLocation());

                        } else {
                            getEditedEntity().setEmployeeProfile(null);
                            getEditedEntity().setCompany(employeeProfileApplicant.getCompany());
                            getEditedEntity().setOperatingLocation(employeeProfileApplicant.getOperatingLocation());

                            notifications.create("Your're not entitled to availd Work From Anywhere option")
                                    .withType(Notifications.Type.WARNING)
                                    .withDuration(5000)
                                    .withCloseable(false)
                                    .show();
                            saveAndCloseBtn.setVisible(false);
                        }
                    }
                }
            }
        }
    }

    private void loadEmployeeList() {
        if (getEditedEntity().getCompany() != null && getEditedEntity().getOperatingLocation() != null) {
            if (waType.equalsIgnoreCase("wfa")) {
                final List<EmplCatWorkAwayRule> emplCatWorkAwayRulesList = unconstrainedDataManager.load(EmplCatWorkAwayRule.class)
                        .query("select e from hmd_EmplCatWorkAwayRule e " +
                                "where e.workAwayOfficeAllowed = true " +
                                "and e.company = :companyIdList " +
                                "and e.operatingLocation = :operatingLocationIdList")
                        .parameter("companyIdList", getEditedEntity().getCompany())
                        .parameter("operatingLocationIdList", getEditedEntity().getOperatingLocation())
                        .list();
                List<UUID> employeeGroupIdList = emplCatWorkAwayRulesList.stream().map(e -> e.getEmployeeGroup().getId()).toList();
                List<UUID> employeeCategoryIdList = emplCatWorkAwayRulesList.stream().map(e -> e.getEmplCategory().getId()).toList();
                List<EmploymentStatus> employmentStatusList = new ArrayList<>();
                employmentStatusList.add(EmploymentStatus.ACTIVE_EMPLOYMENT);
                employmentStatusList.add(EmploymentStatus.LONG_TERM_LEAVE);
                employmentStatusList.add(EmploymentStatus.SEPARATION_IN_PROCESS);

                employeeProfilesDl.setParameters(ParamsMap.of("companyId", getEditedEntity().getCompany().getId(), "employmentStatusList", employmentStatusList, "operatingLocationId", getEditedEntity().getOperatingLocation().getId(), "employeeGroupIdList", employeeGroupIdList, "employeeCategoryIdList", employeeCategoryIdList));
                employeeProfilesDl.load();
            }else{
                //Visit
                List<EmploymentStatus> employmentStatusList = new ArrayList<>();
                employmentStatusList.add(EmploymentStatus.ACTIVE_EMPLOYMENT);
                employmentStatusList.add(EmploymentStatus.LONG_TERM_LEAVE);
                employmentStatusList.add(EmploymentStatus.SEPARATION_IN_PROCESS);
               employeeProfilesDl.setQuery("select e from hr_EmployeeProfile e \n" +
                        "                    join e.company c\n" +
                        "                    join e.operatingLocation o\n" +
                        "                    where c.id = :companyId  and e.employmentStatus in :employmentStatusList and e.joinDateActual is not null\n" +
                        "                    and o.id = :operatingLocationId");
                employeeProfilesDl.setParameters(ParamsMap.of("companyId", getEditedEntity().getCompany().getId(), "operatingLocationId", getEditedEntity().getOperatingLocation().getId(), "employmentStatusList", employmentStatusList));
                employeeProfilesDl.load();
            }
        }
    }

And remaining codes:


    @Subscribe
    public void onValidation(final ValidationEvent event) {
        ValidationErrors errors = new ValidationErrors();

        final List<WorkAwayOfficeLine> workAwayOfficeLines = getEditedEntity().getWorkAwayOfficeLine();
        if (workAwayOfficeLines == null || workAwayOfficeLines.isEmpty()) {
            errors.add("Sorry, you haven’t added any date(s).");
        }

        if (getEditedEntity().getWorkAwayOfficeLine() != null) {
            if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                final EmplCatWorkAwayRule emplCatWorkAwayRule = unconstrainedDataManager.load(EmplCatWorkAwayRule.class)
                        .query("select e from hmd_EmplCatWorkAwayRule e where e.company = :company1 and e.emplCategory = :emplCategory1 and e.employeeGroup = :employeeGroup1 and e.operatingLocation = :operatingLocation1")
                        .parameter("company1", getEditedEntity().getCompany())
                        .parameter("emplCategory1", getEditedEntity().getEmployeeProfile().getEmplCategory())
                        .parameter("employeeGroup1", getEditedEntity().getEmployeeProfile().getEmployeeGroup())
                        .parameter("operatingLocation1", getEditedEntity().getOperatingLocation())
                        .optional().orElse(null);
                //Check if exceeding the limit

                if (emplCatWorkAwayRule != null) {
                    List<ProcessState> processStateList = new ArrayList<>();
                    processStateList.add(ProcessState.APPROVED);
                    processStateList.add(ProcessState.APPROVAL_IN_PROGRESS);
                    final long daysCount = unconstrainedDataManager.loadValue(
                                    "select COUNT(w) " +
                                            "from hr_WorkAwayOfficeLine w " +
                                            "where w.workAwayOffice.employeeProfile = :workAwayOfficeEmployeeProfile1 " +
                                            "and w.workAwayOffice <> :currentLeaveApplication " +
                                            "and w.workAwayOffice.processState IN :processStateList " +
                                            "and (w.attendDate between :attendDate1 and :attendDate2 " +
                                            "or w.attendDate > :currentToDate)",
                                    Long.class) // Use Long.class for COUNT queries
                            .parameter("attendDate1", getEditedEntity().getLeaveYear().getStartDate())
                            .parameter("attendDate2", getEditedEntity().getLeaveYear().getEndDate())
                            .parameter("processStateList", processStateList)
                            .parameter("currentLeaveApplication", getEditedEntity())
                            .parameter("currentToDate", this.getMaxDate())
                            .parameter("workAwayOfficeEmployeeProfile1", getEditedEntity().getEmployeeProfile())
                            .optional()
                            .orElse(0L);


                    double daysApplied = getEditedEntity().getWorkAwayOfficeLine().stream().count();
                    if (daysCount + daysApplied > emplCatWorkAwayRule.getWorkAwayMaxYearly())
                        errors.add("Sorry, you're exceeding the yearly limit. Can not proceed");
                } else {
                    errors.add("Sorry, the employee is not entitled for Work from anywhere");
                }
            }
        } else {
            errors.add("There is no new records added to the table, please add dates..");
        }

        //validation of work address
        if(getEditedEntity().getWorkAddress()!=null){
            if(getEditedEntity().getWorkAddress().trim().length()==0) {
                if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                    errors.add("Please Update the Work Address");
                }else{
                    errors.add("Please Update the Visit Address");
                }
            }
        }else{
            if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                errors.add("Please Update the Work Address");
            }else{
                errors.add("Please Update the Visit Address");
            }
        }

        //validation of Deliverables
        if(getEditedEntity().getDeliverables()!=null){
            if(getEditedEntity().getDeliverables().trim().length()==0) {
                if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                    errors.add("Please Update the Deliverables");
                }else{
                    errors.add("Please Update the Visit Purpose");
                }
            }
        }else{
            if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                errors.add("Please Update the Deliverables");
            }else{
                errors.add("Please Update the Visit Purpose");
            }
        }
        event.addErrors(errors);
    }

    private LocalDate getMinDate() {
        return getEditedEntity().getWorkAwayOfficeLine().stream()
                .filter(Objects::nonNull) // Ensure no null elements
                .map(WorkAwayOfficeLine::getAttendDate) // Replace with the actual getter for the date field
                .filter(Objects::nonNull) // Ensure no null dates
                .min(Comparator.naturalOrder()) // Find the minimum date
                .orElse(null); // Return null if no minimum date is found
    }

    private LocalDate getMaxDate() {
        return getEditedEntity().getWorkAwayOfficeLine() == null ? null : getEditedEntity().getWorkAwayOfficeLine().stream()
                .filter(Objects::nonNull) // Ensure no null elements
                .map(WorkAwayOfficeLine::getAttendDate) // Replace with the actual getter for the date field
                .filter(Objects::nonNull) // Ensure no null dates
                .max(Comparator.naturalOrder()) // Find the minimum date
                .orElse(null); // Return null if no minimum date is found
    }


    @Subscribe("workAwayOfficeLineDataGrid.addDates")
    public void onWorkAwayOfficeLineDataGridAddDates(final ActionPerformedEvent event) {
        if(entityStates.isNew(getEditedEntity()) || getEditedEntity().getProcessState().equals(ProcessState.DRAFT) || getEditedEntity().getProcessState().equals(ProcessState.RETURNED_FOR_CORRECTION)  || getEditedEntity().getProcessState().equals(ProcessState.RECALLED_FOR_CORRECTION)
                || getEditedEntity().getProcessState().equals(ProcessState.NOT_STARTED)) {
            if(getEditedEntity().getEmployeeProfile()!=null){
                if(getEditedEntity().getWorkAwayType()!=null){
            dialogs.createInputDialog(this)
                    .withHeader("Add Dates")
                    .withParameters(
                            InputParameter.booleanParameter("includeWeekend").withLabel("Include Weekend/Holidays").withDefaultValue(false),
                            InputParameter.localDateParameter("dateFrom").withLabel("From Date"),
                            InputParameter.localDateParameter("dateTo").withLabel("To Date"),
                            InputParameter.stringParameter("visitLocation").withLabel("Location")
                    )
                    .withValidator(validationContext -> {

                        LocalDate localDateFrom = validationContext.getValue("dateFrom");
                        LocalDate localDateTo = validationContext.getValue("dateTo");
                        String visitLocation = validationContext.getValue("visitLocation");

                        if (localDateFrom != null && localDateTo != null) {
                            if (localDateFrom.isBefore(getEditedEntity().getLeaveYear().getStartDate())) {
                                return ValidationErrors.of("Invalid date. From date is before the current leave year start date");
                            } else if (localDateTo.isAfter(getEditedEntity().getLeaveYear().getEndDate())) {
                                return ValidationErrors.of("Invalid date. To date is after the current leave year end date");
                            } else if (localDateFrom.isAfter(localDateTo)) {  // FIX: Check if From Date is after To Date
                                return ValidationErrors.of("Invalid date range. From Date cannot be after To Date");
                            }
                        }
                        if(localDateFrom!=null){
                            if(localDateTo!=null){
                                if(visitLocation!=null){
                                    if (visitLocation.trim().length()==0) {  // FIX: Check if From Date is after To Date
                                        return ValidationErrors.of("Empty Visit Location is not allowed");
                                    }
                                }else{
                                    return ValidationErrors.of("Empty Visit Location is not allowed");
                                }
                            }else{
                                return ValidationErrors.of("Please select Date To");
                            }
                        }else{
                            return ValidationErrors.of("Please select Date From");
                        }

                        return ValidationErrors.none();
                    })
                    .withActions(DialogActions.OK_CANCEL)
                    .withCloseListener(closeEvent -> {
                        if (closeEvent.closedWith(DialogOutcome.OK)) {
                            boolean includeWeekend = closeEvent.getValue("includeWeekend");
                            LocalDate localDateFrom = closeEvent.getValue("dateFrom");
                            LocalDate localDateTo = closeEvent.getValue("dateTo");
                            String visitLocation = closeEvent.getValue("visitLocation");
                            if (localDateFrom == null || localDateTo == null) {

                                notifications.create("Please select all required fields.")
                                        .show();
                                return;
                            }
                            //if(getEditedEntity().getLeaveYear().getStartDate().isAfter(localDateFrom) || getEditedEntity().getLeaveYear().getEndDate().isBefore(localDateTo)) {

                            List<LeaveApplicationLineTemp> leaveApplicationLineList = new ArrayList<>();
                           // if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                                final EmployeeProfile employeeProfile = unconstrainedDataManager.load(EmployeeProfile.class)
                                        .query("select e from hr_EmployeeProfile e where e.id = :id1")
                                        .parameter("id1", getEditedEntity().getEmployeeProfile().getId())
                                        .fetchPlan("employeeProfile-work-away-appl-fetch-plan")
                                        .one();
                                leaveApplicationLineList = inteaccLeaveServiceBean.loadLeaveAppLines(
                                        employeeProfile,
                                        employeeProfile.getLeaveProfile().getDefaultEarnedLeave(),
                                        localDateFrom,
                                        localDateTo,
                                        DurationType.FULL_DAY
                                );
                          //  }

                                // Loop between the two dates
                                boolean applExists = false;
                                LocalDate currentDate = localDateFrom;
                                while (!currentDate.isAfter(localDateTo)) {
                                    // Assign currentDate to a final or effectively final variable for use in the lambda expression
                                    LocalDate finalCurrentDate = currentDate;

                                    // Check if an item with the same attendance date exists
                                    boolean isExist = workAwayOfficeLineDc.getItems() != null &&
                                            !workAwayOfficeLineDc.getItems().isEmpty() &&
                                            workAwayOfficeLineDc.getItems().stream()
                                                    .anyMatch(e -> e.getAttendDate().equals(finalCurrentDate));

                                    // If no item with the current date exists, create a new one

                                    if (!isExist) {
                                        String applicationCategory = "workaway";
                                        String applicationExists = inteaccHrServiceBean.checkExistingApplication(applicationCategory, getEditedEntity().getId(), getEditedEntity().getEmployeeProfile(), localDateFrom, localDateTo).trim();

                                        if (applicationExists == "" || applicationExists == null) {
                                           // if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {

                                                double leaveDayValue = leaveApplicationLineList.stream()
                                                        .filter(line -> line.getLeaveDate().equals(finalCurrentDate))
                                                        .map(LeaveApplicationLineTemp::getLeaveDay) // Extracts the LeaveDay field
                                                        .findFirst()
                                                        .orElse(0.0); // Default value if no match is found

                                                if(leaveDayValue>0){
                                                    WorkAwayOfficeLine workAwayOfficeLine = dataContext.create(WorkAwayOfficeLine.class);
                                                    workAwayOfficeLine.setAttendDate(currentDate);
                                                    workAwayOfficeLine.setVisitLocation(visitLocation);
                                                    workAwayOfficeLine.setWeekendOrHoliday(leaveDayValue>0? false : true);
                                                    workAwayOfficeLine.setWorkAwayOffice(getEditedEntity());
                                                    workAwayOfficeLineDc.getMutableItems().add(workAwayOfficeLine);
                                                }else{
                                                    if(includeWeekend) {
                                                        WorkAwayOfficeLine workAwayOfficeLine = dataContext.create(WorkAwayOfficeLine.class);
                                                        workAwayOfficeLine.setAttendDate(currentDate);
                                                        workAwayOfficeLine.setVisitLocation(visitLocation);
                                                        workAwayOfficeLine.setWeekendOrHoliday(leaveDayValue > 0 ? false : true);
                                                        workAwayOfficeLine.setWorkAwayOffice(getEditedEntity());
                                                        workAwayOfficeLineDc.getMutableItems().add(workAwayOfficeLine);
                                                    }
                                                }
                                            /*
                                            }else{
                                                WorkAwayOfficeLine workAwayOfficeLine = dataContext.create(WorkAwayOfficeLine.class);
                                                workAwayOfficeLine.setAttendDate(currentDate);
                                                workAwayOfficeLine.setVisitLocation(visitLocation);
                                                workAwayOfficeLine.setWorkAwayOffice(getEditedEntity());
                                                workAwayOfficeLineDc.getMutableItems().add(workAwayOfficeLine);
                                            }
                                        */
                                        } else {
                                            applExists = true;
                                        }
                                    }

                                    // Move to the next date
                                    currentDate = currentDate.plusDays(1); // Or you can use .plus(1, ChronoUnit.DAYS);
                                }

                             if(applExists) {
                                 notifications.create("Sorry, you have one or more dates where there are existing applications which is skipped")
                                         .withPosition(Notification.Position.MIDDLE)
                                         .withDuration(5000)
                                         .withCloseable(false)
                                         .withType(Notifications.Type.WARNING)
                                         .show();
                             }
                        }
                    })
                    .open();
                }else{
                    notifications.create("Please select the Work Away Type")
                            .withPosition(Notification.Position.MIDDLE)
                            .withCloseable(false)
                            .withDuration(5000)
                            .withType(Notifications.Type.WARNING)
                            .show();
                }
            }else{
                notifications.create("Please select the employee first")
                        .withPosition(Notification.Position.MIDDLE)
                        .withCloseable(false)
                        .withDuration(5000)
                        .withType(Notifications.Type.WARNING)
                        .show();
            }
        }else{
            notifications.create("Sorry, this application is not editable anymore")
                    .withPosition(Notification.Position.MIDDLE)
                    .withCloseable(false)
                    .withDuration(5000)
                    .withType(Notifications.Type.WARNING)
                    .show();
        }
    }

    @Subscribe("workAwayOfficeLineDataGrid.remove")
    public void onWorkAwayOfficeLineDataGridRemove(final ActionPerformedEvent event) {
        dialogs.createOptionDialog()
                .withHeader("CONFIRM DELETION")
                .withText("Are you sure you want to delete selected date(s)?")
                .withActions(
                        new DialogAction(DialogAction.Type.YES).withHandler(e -> {
                            WorkAwayOfficeLine workAwayOfficeLine = workAwayOfficeLineDataGrid.getSingleSelectedItem();
                            if(workAwayOfficeLine!=null){
                                workAwayOfficeLineDc.getMutableItems().remove(workAwayOfficeLine);

                            }
                        }),
                        new DialogAction(DialogAction.Type.NO)
                )
                .open();
    }


    @Subscribe(id = "workAwayOfficeLineDc", target = Target.DATA_CONTAINER)
    public void onWorkAwayOfficeLineDcCollectionChange(final CollectionContainer.CollectionChangeEvent<WorkAwayOfficeLine> event) {
        if (getEditedEntity().getWorkAwayOfficeLine() != null) {
            double count = getEditedEntity().getWorkAwayOfficeLine().size();
            getEditedEntity().setTotalDays(count);
        }
    }


    private boolean datesNotUsedInOtherWorkAwayApp(LocalDate dateFrom, LocalDate dateTo) {

        if (getEditedEntity().getWorkAwayOfficeLine() != null) {
            LocalDate fromDate = getEditedEntity().getWorkAwayOfficeLine().stream()
                    .map(WorkAwayOfficeLine::getAttendDate)
                    .min(LocalDate::compareTo)
                    .orElse(null); // Returns null if no records exist

            LocalDate toDate = getEditedEntity().getWorkAwayOfficeLine().stream()
                    .map(WorkAwayOfficeLine::getAttendDate)
                    .max(LocalDate::compareTo)
                    .orElse(null); // Returns null if no records exist

            String applicationCategory = "workaway";
            String applicationExists = inteaccHrServiceBean.checkExistingApplication(applicationCategory, getEditedEntity().getId(), getEditedEntity().getEmployeeProfile(), fromDate, toDate).trim();
            if (applicationExists == "") {
                return false;
            } else {
                notifications.create("Sorry, you have " + applicationExists + " during the period")
                        .withPosition(Notification.Position.MIDDLE)
                        .withDuration(3000)
                        .withCloseable(false)
                        .withType(Notifications.Type.WARNING)
                        .show();
                return true;
            }

        } else {

            notifications.create("Please add the date(s) for the work away office")
                    .withPosition(Notification.Position.MIDDLE)
                    .withDuration(3000)
                    .withCloseable(false)
                    .withType(Notifications.Type.WARNING)
                    .show();
            return false;
        }
    }


    @Override
    public String getPageTitle() {
        String yourPageTitle = userType==null? null : userType.equalsIgnoreCase("hr") ?
                waType==null? null : waType.equalsIgnoreCase("wfa")? "Work From Anywhere - HR " : "Visit - HR"
                :  waType==null? null : waType.equalsIgnoreCase("wfa")? "Work From Anywhere" : "Visit";
        return Strings.isNullOrEmpty(yourPageTitle)
                ? super.getPageTitle()
                : yourPageTitle;
    }



    @Override
    public boolean hasUnsavedChanges() {
        if (isReadOnly()) {
            return false;
        }

        return super.hasUnsavedChanges();
    }


    //For Workflow
    @Subscribe("initWorkflowBtn")
    public void onInitWorkflowBtnClick (ClickEvent < Button > event) {
        dialogs.createOptionDialog()
                .withHeader("Confirm SUBMISSION")
                .withText("Do you really want to submit for approval?")
                .withActions(
                        new DialogAction(DialogAction.Type.YES)
                                .withHandler(e -> {

                                    getEditedEntity().setProcessState(ProcessState.NOT_STARTED);

                                    try {
                                        OperationResult operationResult = closeWithSave();
                                    } catch (Exception f) {
                                        log.error("Error occurred while closing with save", f);
                                    }
                                }),
                        new DialogAction(DialogAction.Type.NO)
                )
                .open();
    }

    @Supply(to = "workAwayOfficeLineDataGrid.weekendOrHoliday", subject = "renderer")
    private Renderer<WorkAwayOfficeLine> workAwayOfficeLineDataGridWeekendOrHolidayRenderer() {
        return new ComponentRenderer<>(
                () -> {
                    JmixCheckbox checkbox = uiComponents.create(JmixCheckbox.class);
                    checkbox.setReadOnly(true);
                    return checkbox;
                },
                (checkbox, customer) -> checkbox.setValue(customer.getWeekendOrHoliday())
        );
    }

    @Subscribe("fileRefItineraryField")
    public void onFileRefItineraryFieldFileUploadSucceeded(final FileUploadSucceededEvent<FileStorageUploadField> event) {
        if (event.getReceiver() instanceof FileTemporaryStorageBuffer buffer) {
            UUID fileId = buffer.getFileData().getFileInfo().getId();
            File file = temporaryStorage.getFile(fileId);

            if (file != null) {
                try {
                    String originalFileName = event.getFileName();
                    String fileExtension = "";
                    if (originalFileName.contains(".")) {
                        fileExtension = originalFileName.substring(originalFileName.lastIndexOf("."));
                    }
                    String uniqueFileName = UUID.randomUUID() + fileExtension;
                    FileStorage fileStorage = fileStorageLocator.getDefault();
                    FileRef fileRef;
                    try (FileInputStream fis = new FileInputStream(file)) {
                        fileRef = fileStorage.saveStream(uniqueFileName, fis);
                    }

                    getEditedEntity().setFileRefItinerary(fileRef);

                    temporaryStorage.deleteFile(fileId);

                    this.displayFile();

                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

  

    private void displayFile() {
        if (getEditedEntity().getFileRefItinerary() != null) {
            FileRef fileRef = getEditedEntity().getFileRefItinerary();
            String fileName = fileRef.getFileName().toLowerCase();

            StreamResource resource = new StreamResource(fileName, () -> {
                try {
                    FileStorage fileStorage = fileStorageLocator.getDefault();
                    return fileStorage.openStream(fileRef);
                } catch (Exception e) {
                    return null;
                }
            });

            filedisplay.removeAll();

            if (fileName.endsWith(".pdf")) {
                PdfViewer pdfViewer = new PdfViewer();
                pdfViewer.setSrc(resource);
                pdfViewer.setHeight("100%");
                pdfViewer.getElement().getStyle().set("margin", "0").set("padding", "0");
                filedisplay.add(pdfViewer);

            } else if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith(".png")) {
                com.vaadin.flow.component.html.Image image = new com.vaadin.flow.component.html.Image(resource, "Uploaded Image");
                image.setWidthFull(); // or setWidth("100%")
              //  image.setHeightAut();
                filedisplay.add(image);
            } else {
                notifications.create("Unsupported file type: " + fileName)
                        .withType(Notifications.Type.WARNING)
                        .show();
            }

            filedisplay.setHeight("100%");
            filedisplay.getElement().getStyle().set("margin", "0").set("padding", "0");
        }
    }


    @Subscribe("fileRefItineraryField")
    public void onFileRefItineraryFieldFileUploadFinished(final FileUploadFinishedEvent<FileStorageUploadField> event) {
        this.displayFile();
    }

    @Override
    protected String getSaveNotificationText() {
        if(getEditedEntity().getWorkAwayType()!=null) {
            if(getEditedEntity().getWorkAwayType().equals(WorkAwayType.WORK_FROM_ANYWHERE)) {
                return "Saved Work From Anywhere Successfully";
            }else{
                return "Saved Visit Successfully";
            }
        }
        return "Saved Successfully";
    }
}

I have copied your full code example of the details view and search the usage of setWaType method and the declaration of beforeEnter method and nothing found as a result.

Here is example where the passing parameter works in the UserDetailsView implenentation:

details-param-sample.zip (1.0 MB)

Regards,
Maria.