Spring Boot Changing Values From a Controller To Another












0















I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:



@RequestMapping(value = "/search1" , method = RequestMethod.POST)
public List search1(){
List<?> list1 = scrapper1.search1():
return list1;
}


The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:



@RequestMapping(value = "/search2", method = RequestMethod.POST)
public List search2(){
List<?> list2 = scrapper2.search2();
return list2;
}


My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?










share|improve this question



























    0















    I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
    I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
    Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:



    @RequestMapping(value = "/search1" , method = RequestMethod.POST)
    public List search1(){
    List<?> list1 = scrapper1.search1():
    return list1;
    }


    The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:



    @RequestMapping(value = "/search2", method = RequestMethod.POST)
    public List search2(){
    List<?> list2 = scrapper2.search2();
    return list2;
    }


    My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?










    share|improve this question

























      0












      0








      0








      I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
      I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
      Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:



      @RequestMapping(value = "/search1" , method = RequestMethod.POST)
      public List search1(){
      List<?> list1 = scrapper1.search1():
      return list1;
      }


      The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:



      @RequestMapping(value = "/search2", method = RequestMethod.POST)
      public List search2(){
      List<?> list2 = scrapper2.search2();
      return list2;
      }


      My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?










      share|improve this question














      I'm having an issue with 2 controllers and i'm not sure if there is a solution for this.
      I extract some ads from the internet(thousands of ads) and i can't extract all of them at once because it will take too long to load all those ads on the page.
      Basically the first controller is a POST controller which returns always let's say the first 5 elements from that list and it looks like this:



      @RequestMapping(value = "/search1" , method = RequestMethod.POST)
      public List search1(){
      List<?> list1 = scrapper1.search1():
      return list1;
      }


      The second controller returns the next 5 elements per execution(until the end of the list and then it starts from the first 5 elements) from the same list but it's a different method, let's say this controller looks like this:



      @RequestMapping(value = "/search2", method = RequestMethod.POST)
      public List search2(){
      List<?> list2 = scrapper2.search2();
      return list2;
      }


      My problem is that if the second method is executed let's say 3 times the page will contain elements from that list which are from 10-15 and if the first method gets executed again the page will contain elements from 0-5 but now if the second method gets executed it will jump to elements from 15-20.I need those 2 controllers because i have 2 buttons on the page and there are multiple lists..I need somehow to reset the second method whenever the first method from the first controller gets executed.Are there any ways to do this?







      java algorithm controller






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 19:14









      Truica SorinTruica Sorin

      737




      737
























          1 Answer
          1






          active

          oldest

          votes


















          1














          For this type of problem we can use PagingAndSortingRepository from spring data.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419075%2fspring-boot-changing-values-from-a-controller-to-another%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            For this type of problem we can use PagingAndSortingRepository from spring data.






            share|improve this answer




























              1














              For this type of problem we can use PagingAndSortingRepository from spring data.






              share|improve this answer


























                1












                1








                1







                For this type of problem we can use PagingAndSortingRepository from spring data.






                share|improve this answer













                For this type of problem we can use PagingAndSortingRepository from spring data.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 21 '18 at 19:52









                jogendrajogendra

                945




                945
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53419075%2fspring-boot-changing-values-from-a-controller-to-another%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith