小编pau*_*aul的帖子

在模态对话框上显示引导框

我有这样的模态对话框

<div id="tenantDialog" class="modal fade" tabindex="-1" data-backdrop="static">
<div class="modal-dialog modal-lg">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h4 class="modal-title">
                <i class="fa fa-users"></i>
                <spring:message code="label.tenant.person.title"/>
            </h4>
        </div>
        <div class="modal-body">
            <%--We load here the persons table here to be reloaded in any moment--%>
            <div id="personTableDiv">
                <c:set var="preferredCollaborators" value="${preferredCollaborators}" scope="request"/>
                <jsp:include page="personsTable.jsp"/>
            </div>
        </div>
        <div class="modal-footer">
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

然后在personsTable.js 关联到包含页面我有逻辑打开一个引导框确认。但我的问题是,这个引导框显示在模态对话框下,所以它并不难处理。

这是我的引导箱创建

bootbox.confirm(customText, function (confirmed) {
    if (confirmed) {
        var regularityDocumentsIds = [];
        var i;
        for (i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

javascript jquery twitter-bootstrap

2
推荐指数
1
解决办法
5578
查看次数

Couchbase使用Rest API删除文档

我一直在检查Rest API,但我找不到用于删除特定文档或某个特定视图的所有文档的API.只需删除存储桶或视图.任何人都知道这是否可能?

couchbase

2
推荐指数
1
解决办法
388
查看次数

构造函数中的调用方法

我有一个带有构造函数的Controller,我在其中注入了一个缓存,但是我想在创建实例时在构造函数中调用一个方法.我知道我们可以创建一些辅助构造函数

def this(foo:Foo){}
Run Code Online (Sandbox Code Playgroud)

但在我的情况下,因为是play框架实例我的bootstrap有点复杂.

在这里我的代码

class SteamController @Inject()(cache: CacheApi) extends BaseController {

  private val GAME_IDS_LIST_API: String = "api.steampowered.com/ISteamApps/GetAppList/v2"

  private val GAME_API: String = "store.steampowered.com/api/appdetails?appids="

  private val GAME_KEY: String = "games"

  def games = Action { implicit request =>
    var fromRequest = request.getQueryString("from")
    if (fromRequest.isEmpty) {
      fromRequest = Option("0")
    }
    val from = Integer.parseInt(fromRequest.get) * 10
    val to = from + 10
    loadGameIds()
    Ok(html.games(SteamStore.gamesIds(cache.getVal[JSONArray](GAME_KEY), from, to), cache.jsonArraySize(GAME_KEY)/10))
  }


  private def loadGameIds(): Unit = {
    val games = cache.get(GAME_KEY)
    if (games.isEmpty) { …
Run Code Online (Sandbox Code Playgroud)

scala playframework playframework-2.0

2
推荐指数
1
解决办法
668
查看次数

如果不使用会话

我正在尝试使用Gatling,我只想在第一个场景迭代中执行一些步骤,这里是我的代码

def create(): ScenarioBuilder = {
    scenario(name)
      .exec(session => session.set("DEBUG", debug_set))
      .exec(session => session.set("client_id", session.userId))
      .doIf(session => session("initialized").asOption[String].isEmpty) {
        exec(Identity.getIdentityToken)
        exec(session => session.set("initialized", "true"))
      }
      .exitHereIfFailed
      .during(Duration(15, MINUTES)) {
        exec(X.setupVars)
          .exec(X.create)
          .pause(Duration(1, SECONDS))
          .exec(X.get)
      }
  }
}
Run Code Online (Sandbox Code Playgroud)

不知怎的,第一次迭代初始化它没有定义它没有到达那里,因为我没有看到日志执行其中一个步骤.

知道我做错了吗?

scala gatling

2
推荐指数
1
解决办法
3234
查看次数

Stream 中的 Bigdecimals 求和

我正在使用 Java 8 Stream,在其中迭代两个集合,在通过过滤器后,我想将流中的 bigdecimal 变量之一与外部 bigDecimal 变量“restrictionsNumber”相加

这是我的代码:

     final BigDecimal restrictionsNumber = cmd.amount.getNumberOfUnits();
        order.products()
             .stream()
             .flatMap(product -> product.getRestrictions()
                                    .stream()
                                    .filter(restriction -> restriction.equals(newProductRestriction))
                                    .map(restriction -> restrictionsNumber.add(product.getAmount()
                                                                            .getNumberOfUnits())));
Run Code Online (Sandbox Code Playgroud)

最后一张地图是我试图将两个 bigdecimals 相加的地图。我知道我做错了什么。谁能给我一个关于如何使用 Stream.js 做这件事的建议。

我正在尝试重构这个旧的时尚代码

 final BigDecimal restrictionsNumber = cmd.amount.getNumberOfUnits();
 for (Product product : order.products()) {
     for (String oldProductRestriction : product.getRestrictions()) {
         if (oldProductRestriction.equals(newProductRestriction)) {
            restrictionsNumber = restrictionsNumber.add(product.getAmount()
                                                                       .getNumberOfUnits());
          }
      }
  }
Run Code Online (Sandbox Code Playgroud)

问候。

java lambda java-8 java-stream

1
推荐指数
1
解决办法
926
查看次数

Scalatest中的方案大纲

我正在使用scalatest实现我的测试框架,我认为使用该框架而不是Cucumber犯了一个错误

我正在尝试使用一些类似Scenario outline黄瓜的功能,以免造成DRY断裂

这是我的问题

  feature("Features of mus client") {
    scenario("GET message with mus client") {
      Given("a Musin message")
      val config: Properties = new Properties
      config.put("method", "POST")
      config.put("encoding", "UTF-8")
      config.put("uri", "http://localhost:9083/musClient")
      When("I make a request to f2e")
      val response = HttpClientTest.request(config, createJSON(READ))
      Then("The message it´s returned successfully")
      assert(response != null)
    }

    scenario("POST message with mus client") {
      Given("a Musin message")
      val config: Properties = new Properties
      config.put("method", "POST")
      config.put("encoding", "UTF-8")
      config.put("uri", "http://localhost:9083/musClient")
      When("I make a request to f2e")
      val …
Run Code Online (Sandbox Code Playgroud)

scala cucumber scalatest

1
推荐指数
1
解决办法
377
查看次数

将Scala Future转换为CompletableFuture

我在我的项目中有一个返回a的Akka层Scala Future,接收Future的部分是Java味道.

团队中的人不了解Scala,他们宁愿使用,CompletableFuture因为他们更了解Java 8 API.

有没有什么好方法可以将a变换Scala futureCompletableFuture

显然是以非阻塞的方式.

问候.

java scala java-8

1
推荐指数
1
解决办法
1304
查看次数

返回多个monad

我正在读Haskell中的一些代码,我无法理解并找到一个解释,如果一个函数返回一个IO(无论如何)它之前可以有其他类型.

这个功能很明显一个也许会返回一个IO

也许用户 - > IO(也许是用户)

但是scotty库中的下一个返回了IO的文本Monad ActionT ??? 我的思绪即将爆发!

也许User - > ActionT Text IO(也许是用户)

haskell

1
推荐指数
1
解决办法
103
查看次数

新文物Maven例外

我在Maven集成测试中使用New relic,有时当我运行集成测试时,我的代理程序与VM -javaagent上的确认程序:/path/to/newrelic.jar正在运行时,我收到此异常

     ERROR: Aborted Maven execution for InterruptedIOException
     java.net.SocketTimeoutException: Accept timed out
at java.net.PlainSocketImpl.socketAccept(Native Method)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:398)
at java.net.ServerSocket.implAccept(ServerSocket.java:530)
at java.net.ServerSocket.accept(ServerSocket.java:498)
at hudson.maven.AbstractMavenProcessFactory$SocketHandler$AcceptorImpl.accept(AbstractMavenProcessFactory.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.perform(RemoteInvocationHandler.java:299)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:280)
at hudson.remoting.RemoteInvocationHandler$RPCRequest.call(RemoteInvocationHandler.java:239)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:328)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Run Code Online (Sandbox Code Playgroud)

有谁知道这个问题?

问候.

java maven newrelic

0
推荐指数
1
解决办法
430
查看次数

FindFirst 和 orElse 运算符返回不同的类类型

I\xc2\xb4m 使用 Stream 并findFirst()返回Optional,但也有 \xc2\xb4s 有可能我的StreamMaybe 不会发出任何东西,所以我添加了orElse在底部添加了运算符。

\n

问题是orElse不返回可选值,而是返回可选值的类类型findFirst

\n
        def optional = categories.categories.stream()\n                .filter { category -> category.name == selCategory }\n                .map { category -> loadUniqueIds.call(category) }\n                .map { UUIDs -> new JsonArray(UUIDs) }\n                .findFirst().orElse{Optional.of(new JsonArray())}\n        optional.get()\n
Run Code Online (Sandbox Code Playgroud)\n

所以我最终无法使用findFirst并且orElse

\n

我\xc2\xb4m在这里做错了什么?

\n

谢谢

\n

更新:

\n

我最终删除了orElse之后findFirst并稍后检查可选的

\n
        optional.isPresent() ? optional.get(): new JsonArray()\n
Run Code Online (Sandbox Code Playgroud)\n

无论如何,如果有人有更好/优雅的解决方案,请告诉我。

\n

问候。

\n

groovy java-8 java-stream

0
推荐指数
1
解决办法
6626
查看次数