Closed mlouah closed 2 weeks ago
Le composant doc-author.component.ts n'a rien avoir avec le nombre d'item dans le combo d'update !!! La variable suite fixe combien d'item seront afficher dans la page doc.vue comme son nom l'indique!
public itemsPerPage = 50;
pour logguer depuis Java script:
console.log('My texte:', variable.data);
Link:"http://localhost:8080/api/doc-authors?sort=id%2Casc&page=0&size=50 au niveau de la console !
Jhipster community has already reported this issue :
This has to be fixed from a backend side:spring.data.web.pageable.maxPageSize=2147483647
Final solution: 1) DocAuthorResource.java contains the following code
Finalement la solution est simple :( https://chatgpt.com/c/671fbfea-d32c-800d-ad07-f8d726c9f420
Since you're using JHipster 7.9.3, all the methods I mentioned previously are still applicable, but let’s focus specifically on the version you’re using and its standard practices.
application.yml
This method works well for JHipster 7.9.3. You can configure the default Pageable
properties globally:
src/main/resources/config/application.yml
or application-dev.yml
.Add or update the following settings:
spring:
data:
web:
pageable:
default-page-size: 50 # Set your desired default size
max-page-size: 200 # (Optional) Set a maximum limit if needed
This will set the default page size globally for all pageable requests handled by Spring Data.
@PageableDefault
in ControllerYou can modify specific controller methods to set a default page size. In JHipster, the controllers are typically in src/main/java/com/yourproject/web/rest/
.
Example for a specific REST method:
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ExampleResource {
@GetMapping("/api/examples")
public ResponseEntity<List<ExampleDTO>> getAllExamples(
@PageableDefault(size = 50) Pageable pageable) {
Page<ExampleDTO> page = exampleService.findAll(pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/examples");
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
}
This will change the default page size for this specific endpoint without impacting other parts of your application.
If you want to set a default page size in your frontend code, specifically in the API calls made by Vue.js, you can modify the parameters passed to the backend. In your Vue component, typically located in src/main/webapp/app/entities
, locate the retrieve
method and update it to include a default page size:
this.docAuthorService()
.retrieve({ page: 0, size: 50 }) // Set the size to 50 or your desired default
.then(response => {
this.docAuthors = response.data;
})
.catch(error => {
console.error('Error fetching doc authors:', error);
});
You can create a custom configuration class in your JHipster project under src/main/java/com/yourproject/config
:
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.web.config.PageableHandlerMethodArgumentResolverCustomizer;
@Configuration
public class PageableConfig {
@Bean
public PageableHandlerMethodArgumentResolverCustomizer pageableCustomizer() {
return pageableResolver -> {
pageableResolver.setFallbackPageable(PageRequest.of(0, 50)); // Default size of 50
pageableResolver.setMaxPageSize(200); // Optional: limit maximum size
};
}
}
This solution applies globally and ensures a default page size if none is specified in a request.
If you want a global solution that applies across all controllers and pageable requests, I suggest using Method 1 (updating application.yml
) or Method 4 (custom configuration class). If you want more fine-grained control over page sizes, Method 2 (using @PageableDefault
) would be more appropriate.
If you need further assistance specific to JHipster or the version you're using, feel free to ask!
Even if the default size was 100, the dropdown list does not contains empty line 👍 Ne marche pas pour le profile Dev !!!
involved files
// doc doc-update.vue
doc-update.component.ts
doc-update.vue : combo
// doc author
doc-author.service.ts
public retrieve(paginationQuery?: any): Promise<any>
axios.get(baseApiUrl +
?${buildPaginationQueryOpts(paginationQuery)})
sorts.ts: buildPaginationQueryOpts()