Results 1 to 4 of 4

Thread: Pagination for Key/Value Pair

  1. #1

    Default Pagination for Key/Value Pair

    Hi,

    I'm trying to paginate the content of OneToMany Relationship, so for a given Collection e.g. Map<Object, List<Object>>, contents of key and value pair need to be paged. At the moment, I'm only able to paginate the key using Spring's Pageable Interface. I'm not sure if it is possible to use Pageable in the above scenario.

    if anyone has any suggestions I'd like to hear it.

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    Hello

    so for a given Collection e.g. Map<Object, List<Object>>
    Why you are such bold style, perhaps exists other way simplier. What requirement you want to solve?

    Lets start by there.
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3

    Default

    Perhaps an analogy will help.

    Consider a database with 2 tables that holds "Questions" and a table that has a "OneToMany" Relationship called "Answers". For any given "Question" there can be in theory hundreds of "Answers". I'd like to paginate the number of Questions retrieved from database and if number "Answers" exceeds a given limit the "Answers" will also be paginated,

    At the moment I'm using Spring's Pageable interface to paginate the contents of first table, I'm looking for a method to paginate both tables.

    I hope this is a little clear.

  4. #4
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    Hello

    Consider a database with 2 tables that holds "Questions" and a table that has a "OneToMany" Relationship called "Answers". For any given "Question" there can be in theory hundreds of "Answers".
    I could do the follow (I am assuming that each Answer is only used how a possible candidate for only one Question)

    Code:
    public class Question{
    
    ...
    private String questionToShow; ans
    private Set<Answer> answers = new HashSet<Answer>();
    
    }
    
    public class Answer{
    
    ...
    private Boolean isTheCorrectAnswer;
    private String answerToShow;
    private Question question
    
    }
    I'd like to paginate the number of Questions retrieved from database
    It has sense, because you would generate many exams, but to avoid repetitions of the questions you would use a random control to select the questions. Lets say you have 250 Questions and the exam only consists in 20 Questions.

    and if number "Answers" exceeds a given limit the "Answers" will also be paginated,
    I would suggest create 10 possibles answers for each question, of course one is only the correct, here I dont see need to add Pagination.

    At the moment I'm using Spring's Pageable interface to paginate the contents of first table, I'm looking for a method to paginate both tables.
    I dont see a reason for the bold part.

    You would have a pagination for the questions and when you do click for any of them you should show its 10 possibles answers and the unique which is valid. Now if you have 50 possibles answers then now has sense use pagination for such answers, but anyway you are in a new page showing a Question with its answer

    Let me know your thoughts

    I hope that I understood your case
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •