0

I have the following code in my scala.html file

@(supports: List[Champion])

<div id="supports" class="champWrap">
@supports.map { champion =>
    <a href="@routes.Application.champion(champion.getStringId)">
        <div class="icon-wrap">
            <img src="@routes.Assets.at(champion.getIcon)" alt="@champion.getName" title="@champion.getName"/>
            <p>@champion.getWinm%</p>
        </div>
    </a>
}
</div>

So at the moment I am gathering a List from the Database in the Controller and sending it to the template when it is rendered.

What I want to change:

I want to have a control option within the page which changes the parameters which are used to gather the list. So after changing the control option, the list has to be gathered with different paramters and the part of the page, which iterates through the list has to be reloaded, also this setting has to be stored, f.ex. if the page is reloaded.

I know that I have to do this with AJAX also have I read in the documentation that something like this is possible in Play:

GET     /hotels/list        Hotels.list

but I can't quite figure out how I should do this, since I havn`t used Ajax with play before, also could I need some tips on how I should store the setting. I am thinking about doing it with a cookie, is this the right approach?

I would appreciate if somebody could give me some help

Jakob Abfalter
  • 4,980
  • 17
  • 54
  • 94
  • [PLAY WITH AJAX](http://stackoverflow.com/questions/11133059/play-2-x-how-to-make-an-ajax-request-with-a-common-button) – singhakash Feb 28 '15 at 18:38
  • There are a lot of sample projects in [Typesafe Activator](https://typesafe.com/get-started). For example [this one](https://typesafe.com/activator/template/signalj-chat-scala) which hase some client side code using `jquery` as well. – Nader Ghanbari Feb 28 '15 at 23:03
  • Briefly it depends on your request (content type, parameters, ...). By the way the decision of where to store the settings is up to you (cookies, backend, session, ...), but if you opt to use cookies, play provides a simple way to get and set them. In that case the route file will remain intact. All you need to do is to read cookies from request and set them in response[This blog post](http://blog.knoldus.com/2014/04/05/using-cookies-in-play-framework/) might help you in this sense. – Nader Ghanbari Feb 28 '15 at 23:05

0 Answers0