# 1.2.3 Asignar el search en el init()

Cuando deseamos que el busque automáticamente en el move() desde una configuración en el init.

```java
// <editor-fold defaultstate="collapsed" desc="init">
    @PostConstruct
    public void init() {
        try {
            fechaDesde = DateUtil.primerDiaDelMesEnFecha(DateUtil.anioActual(),DateUtil.mesActual());
            fechaHasta= DateUtil.ultimoDiaDelMesEnFecha(DateUtil.anioActual(),DateUtil.mesActual());
            /*
            configurar el ambiente del controller
             */
            HashMap parameters = new HashMap();
            Usuario jmoordb_user = (Usuario) JmoordbContext.get("jmoordb_user");
            //    parameters.put("P_EMPRESA", jmoordb_user.getEmpresa().getDescripcion());

            JmoordbControllerEnvironment jmc = new JmoordbControllerEnvironment.Builder()
                    .withController(this)
                    .withRepository(viajeRepository)
                    .withEntity(viaje)
                    .withService(viajeServices)
                    .withNameFieldOfPage("page")
                    .withNameFieldOfRowPage("rowPage")
                    .withTypeKey("primary")
                    .withSearchLowerCase(false)
                    .withPathReportDetail("/resources/reportes/viaje/details.jasper")
                    .withPathReportAll("/resources/reportes/viaje/all.jasper")
                    .withparameters(parameters)
                    .withResetInSave(true)
                    .withAction("golist")
                    .build();

            start();

//            String action = "gonew";
//            if (getAction() != null) {
//                action = getAction();
//            }
//
//            if (action == null || action.equals("gonew") || action.equals("new") || action.equals("golist")) {
//                //inicializar
//
//            }
//            if (action.equals("view")) {
//                //view
//            }
            setSearchAndValue("searchProgramacionVehicularController", "_betweendates");
        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
        }
    }// </editor-fold>

```

Asi en el move invocamos el \_betweendate

```java
 @Override
    public void move(Integer page) {
        try {
            programacionVehicular = new ArrayList<>();

            this.page = page;
            viajeDataModel = new ViajeDataModel(viajeList);
            Document doc;

            switch (getSearch()) {
                case "_init":
                case "_autocomplete":
                    viajeList = viajeRepository.findPagination(page, rowPage);
                    break;

                case "activo":
                    if (getValueSearch() != null) {
                        viajeSearch.setActivo(getValueSearch().toString());
                        doc = new Document("activo", viajeSearch.getActivo());
                        viajeList = viajeRepository.findPagination(doc, page, rowPage, new Document("idviaje", -1));
                    } else {
                        viajeList = viajeRepository.findPagination(page, rowPage);
                    }
                    break;

                case "_betweendates":

                    viajeList = viajeRepository.filterBetweenDatePaginationWithoutHours("activo", "si",
                            "fechahorainicioreserva", fechaDesde,
                            "fechahorafinreserva", fechaHasta,
                            page, rowPage, new Document("idviaje", -1));
                    break;

                default:
                    viajeList = viajeRepository.findPagination(page, rowPage);
                    break;
            }
            if (viajeList == null || viajeList.isEmpty()) {

            } else {
                for (Viaje v : viajeList) {
                    ProgramacionVehicular pv = new ProgramacionVehicular();
                    pv.setConductor(v.getConductor().getNombre());
                    pv.setFechahoraregreso(v.getFechahorainicioreserva());
                    pv.setFechahorasalida(v.getFechahorainicioreserva());
                    pv.setIdviaje(v.getIdviaje());
                    pv.setMarca(v.getVehiculo().getMarca());
                    pv.setModelo(v.getVehiculo().getModelo());
                    pv.setPlaca(v.getVehiculo().getPlaca());
                    pv.setNombredia(DateUtil.nameOfDay(pv.getFechahorasalida()));
                    pv.setResponsable(v.getRealizado());
                    pv.setActivo(v.getActivo());
                      pv.setMision(v.getMision());
                    //Datos de la solicitud
                    pv.setFechasolicitud(v.getFechahorainicioreserva());
                    pv.setNumerosolicitudes("");
                  
                    pv.setUnidad("");
                    pv.setResponsable("");
                    pv.setSolicita("");
                    Solicitud solicitud = new Solicitud();

                    Document search = new Document("viaje.idviaje", v.getIdviaje());
                    List<Solicitud> list = solicitudRepository.findBy(search);
                    if (list == null || list.isEmpty()) {

                    } else {
                        String unidad = "";
        
                        String numeroSolicitudes = "";
                        String responsable = "";
                        String solicita = "";
                        //Se recorren todas las solicitudes que tengan ese viaje asignado.
                        for (Solicitud s : list) {
                            pv.setFechasolicitud(s.getFecha());
                            for (Unidad u : s.getUnidad()) {
                                unidad += " " + u.getIdunidad();
                            }
                          
                            numeroSolicitudes += " " + String.valueOf(s.getIdsolicitud());
                            solicita += " " + s.getUsuario().get(0).getNombre();
                            responsable += " " + s.getUsuario().get(1).getNombre();
                        }
                        pv.setUnidad(unidad.trim());
              
                        pv.setNumerosolicitudes(numeroSolicitudes.trim());
                        pv.setResponsable(responsable.trim());
                        pv.setSolicita(solicita.trim());
                       
                    }
 programacionVehicular.add(pv);
                }
            }
            viajeDataModel = new ViajeDataModel(viajeList);

        } catch (Exception e) {
            errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());

        }

    }// </editor-fold>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/trucosjakartaee/jmoordbjsf/controller/init/1.2.3-asignar-el-search-en-el-init.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
