Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Jethro Gillgren
    @jethrogillgren

    @roti If you can follow what seems to be the 'standard' pattern you can use constructor injection.
    We have this import
    import play.api.db.slick.DatabaseConfigProvider
    And this class definition

    class SomethingDAOImpl @Inject()(
      protected val dbConfigProvider: DatabaseConfigProvider)(implicit ec: ExecutionContext) {

    I think that's all we needed to do to 'bind it'

    nemoo
    @nemoo
    @roti see here an example how you can bind things with Guice: https://github.com/nemoo/play-slick3-example/blob/play27/app/modules/ApplicationModule.scala
    Jack Viers
    @jackcviers
    Using play-ws standalone, and though I have play.allowGlobalApplication = true in my application.conf and printing out the value as a boolean shows true I'm still getting the following error: [info] java.lang.RuntimeException: The global application reference is disabled. Play's global state is deprecated and will
    [info] be removed in a future release. You should use dependency injection instead. To enable
    Lior Liviev
    @liorl00
    Hi! I want to use twirl apart from play but there's not a lot of information about that. Does anyone know how to do that?
    Albaro Pereyra
    @AlbaroPereyra
    That is a good question, I once suggested adding the syntax to the “bat” project but, this was not an option since a sublime text template was not available. Now that we are on the subject. How can this the task of creating a sublime text language template be bootstrapped? Please advise.
    Gabriel Francisco
    @gabfssilva

    Hi!

    How can I set timeout in a cached action?

    I tried like this:

    cached(s"fetchById#$id").default(10.seconds) {
      Action.async { 
        //result here
      }
    }

    But, the value is stored forever. Is there something I'm missing?

    Albaro Pereyra
    @AlbaroPereyra

    From the docs: You can specify an expiry duration by passing a duration, by default the duration is infinite:

    import scala.concurrent.duration._

    val result: Future[Done] = cache.set("item.key", connectedUser, 5.minutes)

    Let me know if that resolves your issue.
    Gabriel Francisco
    @gabfssilva

    Okay, so, I found it:

    default implementation:

    def default(duration: Duration): CachedBuilder = compose({ case _: ResponseHeader => duration })

    and, compose implementation:

    def compose(alternative: PartialFunction[ResponseHeader, Duration]): CachedBuilder = new CachedBuilder(
        cache = cache,
        key = key,
        caching = caching.orElse(alternative)
      )

    basically, this line caching = caching.orElse(alternative) means that: if there's a caching defined before, ignores the alternative (which is the default duration value).

    The problem is that cached.apply(key: String) already sets a caching value, so, everything after is ignored.

    The workaround:

    cached((_: RequestHeader) => s"fetchById#$id", 10.seconds) {
      Action.async { 
        //result here
      }
    }
    I'm wondering if this is a bug, which makes sense since the default function has no effect whatsoever in this scenario.
    Hi, @AlbaroPereyra. Thanks for your answer, but, I'm interested in using play.api.cache.Cached in my Actions instead of setting the value manually using play.api.cache.AsyncCacheApi
    Lior Liviev
    @liorl00
    I’ll repeat my question.
    I want to use twirl apart from play but there's not a lot of information about that. Does anyone know how to do that?
    Denis
    @dnspress
    Hi there! Could you please help with running play application with overridden config file. I use IntelliJ IDEA. Project runs with success only when I "Use sbt shell". If I don't tick this checkbox and provide options from application.ini file as JVM properties (-Dhttp.port=9001 -Dconfig.resource=allmodules-dev-run.conf) it will fail with "resource not found on classpath: allmodules-dev-run.conf". This file actually exists at /conf directory :(
    VelizarHristov
    @VelizarHristov
    I'm getting this exception when many requests hit my web app at the same time:
    java.lang.IllegalStateException: Substream Source cannot be materialized more than once
    It's an exception from Akka, which Play uses under the hood.
    How do I fix it?
    VelizarHristov
    @VelizarHristov
    Hmm okay actually the error is from akka-stream.
    In StreamOfStreams.scala:796
    Tim Moore
    @TimMoore
    @VelizarHristov can you post your controller code? Likely to be a bug there. It typically means that you've tried to read a request more than once.
    gavinbaumanis
    @gavinbaumanis

    can someone help me with retrieving the path from the URI, progrmatically?
    I am trying to place the following in my MAIN (layout) template to exclude the menu of my app from the index page;
    @if(request.path !="/") { ... }
    I have tried including the Request and the RequestHeader scopes impicitly in the MAIN and/ or INDEX pages with;
    (implicit request : Request)

    I also have the following in my application controller;
    def index: Action[AnyContent] = Action {implicit request =>
    Ok(au.com.ecpr.pas.views.html.index())
    }

    but I can't seem to get it working, no matter what combination I use. : Thanks.

    gavinbaumanis
    @gavinbaumanis
    If i remove the implicit declaration from MAIN I get the following error;
    object path is not a member of package play.api.mvc.request
    VelizarHristov
    @VelizarHristov
    @TimMoore This is how the code for that endpoint looks like:
     def foo() = Action.async { implicit req =>
          makeRequest().map(result => Ok(views.html.bar(result)))
      }
    It looks like the controller doesn't have any interesting config, I think.
    Denis
    @dnspress
    hello! I have a twirl template with this code: @controllers.admin.routes.Admin.ws.webSocketURL(request)
    how to force using wss protocol instead of ws? Play app behind nginx and works without sll at all
    montrivo
    @montrivo
    Hello,
    I saw that the scala.concurrent.blocking { ... } method is not documented in play's thread pool documentation. Should it be avoided?
    VelizarHristov
    @VelizarHristov
    So it looks like my problem is because of sttp? I have sttp using Akka http backend.
    Tim Moore
    @TimMoore
    @VelizarHristov I guess the interesting code would be in makeRequest()
    VelizarHristov
    @VelizarHristov
    Hmm, adding a dependency on akka-http 10.1.10 fixed it.
    Christian Kaps
    @akkie
    Is it possible to use Play 2.7.3 with HTTP/2 and HTTP/1 at the same time. I need to implement an app with gRPC and WebSockets. gRPC needs HTTP/2 but WebSockets do not work over HTTP/2. Is Play able to serve both protocols?
    Christian Kaps
    @akkie
    To answer my own question. Yes it works. I've created a small POC and it works like a charm.
    Renato Cavalcanti
    @renatocaval
    @akkie, have you checked play-grpc?
    oh yes, sorry
    now I recognised your avatar
    Jamal Bouhssine
    @jamalBH
    hello
    I need some help please
    is there any one here
    ?
    Albaro Pereyra
    @AlbaroPereyra
    State your issue @jamalBH
    Piyush
    @piyushpatel2005_gitlab
    how to cast JsString to java.lang.String? I have scenario where I want to convert """[{"groupName":"Capacity Management","attributeName":"Mbps Used","doubleAttributeValue":1000},{"stringAttributeValue":"80 Mbps","groupName":"CIRCUIT ATTRIBUTE","attributeName":"Bandwidth"}]""" into "[{"Capacity Management": 1000},{"CIRCUIT ATTRIBUTE" : "80Mbps"}]"
    Piyush
    @piyushpatel2005_gitlab
    ok found it.
    Christian
    @bakku
    a small question: I want to show the name of the application in a navbar, the name of the application is configurable in the application.conf
    the navbar is a separate layout
    Since the play application is not global anymore I have to pass in the configuration via DI right ?
    what would be the most elegant solution to not have to pass the configuration into every controller and from the controller into the view
    deepaknagadi
    @deepaknagadi
    Hi I am trying to build a Kafka Consumer using PLay + Java
    Currently I am manually triggering my consumer using a route mentioned in my routes file
    Is there an example wherein once I have my application running it will be automatically listening to Kafka topics ?