小编Rom*_*n C的帖子

在谷歌地图信息窗口angular2中显示自定义标签

map.component.ts 代码:

......
infoWindow = new google.maps.InfoWindow(
{
    content: `<custom-tag></custom-tag>`    //***not displaying anything***
});
infoWindow.open(map, marker);
......
Run Code Online (Sandbox Code Playgroud)

map.component.html 代码:

<custom-tag></custom-tag>      <!--***displays hi***-->
<div class="google-maps"></div>
Run Code Online (Sandbox Code Playgroud)

custom-tag.component.html 代码:

<h2>hi</h2>
Run Code Online (Sandbox Code Playgroud)

module.ts、routing.ts 文件肯定没有错误。信息窗口只是打开并没有显示任何内容,请帮助我弄清楚为什么信息窗口没有显示任何内容。

google-maps angular

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

检查 .NET 远程处理服务器是否存在 - 我的方法正确吗?

无法在 .NET 远程调用上设置连接超时。文档偶尔会提到据称可以执行此操作的TcpChannel属性,但讨论和我发现的最新文档表明这是不可能的。人们可以对远程调用本身设置超时,但不能对初始连接尝试设置超时。您被默认的 45 秒超时所困扰。

由于各种原因我无法使用WCF。

当远程服务器消失时,这会导致问题。如果我尝试进行远程调用,我就会被困在这 45 秒内。这不好。我想检查远程服务器是否存在。使用 a 对其执行 ping 操作PingTimeout是最简单的方法,但我想专门检查远程服务器,而不是仅检查正在运行的计算机。

经过一些实验,我想出了这种方法:

  1. 异步开始与远程端口的 TCP 套接字连接。
  2. 等待连接完成或超时到期(使用 ManualResetEvent)。
  3. 如果连接异步回调成功,则返回成功。否则返回失败。

这可行,但我不确定我对 myWaitHandle和套接字的使用。我还想确保线程安全 WRT 并发检查,我想我已经做到了。我的代码如下。您认为我的方法有什么问题吗?

private static bool IsChannelOpen(string ip, int port, int timeout)
{
    IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(ip), port);
    Socket client = new Socket(endpoint.AddressFamily,
              SocketType.Stream, ProtocolType.Tcp);
    SocketTestData data = new SocketTestData()
              { Socket = client, ConnectDone = new ManualResetEvent(false) };
    IAsyncResult ar = client.BeginConnect
              (endpoint, new AsyncCallback(TestConnectionCallback), data);

    // …
Run Code Online (Sandbox Code Playgroud)

.net sockets remoting

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

我为什么要两次提交表格?jQuery submit()带单选按钮

我正在使用jQuery在MVC应用程序中提交表单.我在控制器内部有一个断点,我看到它被击中了两次.我究竟做错了什么?

这是我的jQuery

 (function ($) {

    $(document).ready(function () {

        $(':radio').change(function () {

            $('#frmMDR').submit();
        });

    });
})(jQuery);
Run Code Online (Sandbox Code Playgroud)

这是表格html

<form action="/Module/ModuleIndex" id="frmMDR" method="get">
  <input id="rdoMaintenance" name="module" type="radio" value="Maintenance" /><label for="rdoMaintenance">M</label>
   <input id="rdoDiagnostics" name="module" type="radio" value="Diagnostics" /><label for="rdoDiagnostics">D</label>
   <input id="rdoRepair" name="module" type="radio" value="Repair" /><label for="rdoRepair">R</label>
 <input id="hdnVehicle" name="hdnVehicle" type="hidden" value="" />
</form>
Run Code Online (Sandbox Code Playgroud)

我猜我不应该使用change事件.如果有人知道如何解决问题,我很乐意听到任何想法.非常感谢任何提示.

干杯,
〜在圣地亚哥

html javascript jquery radio-button double-submit-problem

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

jQuery提交事件发生两次

我的jQuery submit()事件发射两次,我不知道为什么.

我正在使用模板引擎动态构建我的HTML,所以我最终$(document).ready()多次调用,如下所示......

<script>
$(document).ready(function() {
    $("form.search input[type='image']").click(function() { $(this).closest('form.search').submit() })
})
</script>
Run Code Online (Sandbox Code Playgroud)

...后来...

</script>
$(document).ready(function() {
    # I have put an `unbind('submit')` in here to be sure I have nothing else but this particular function bound to `submit`
    $('form.search').unbind('submit').bind('submit',function(event) {
        event.stopPropagation();
        search_term = $(this).find('input[type=text]').val()
        $new_keyword = $('<li class="filter keyword selected" name="'+search_term+'">'+search_term+'</li>')
        alert('event fired!')
        $("#keywords ul").append($new_keyword)
        do_search_selected()
        return false; // Stop the form from actually submitting
    })
})
</script>
Run Code Online (Sandbox Code Playgroud)

表格HTML:

<form class="search" method="get" action="/search/">

    <div>
        <input id="searchfield"type="text" …
Run Code Online (Sandbox Code Playgroud)

javascript jquery dom double-submit-problem

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

如何避免内部类名称冲突?

如果我有一个类A和一个类B是A内部类.我还有另一堂课B.它不在A.

class A {
    ...
    class B {
        ...
    }
    ...
}

class B {
    ...
}
Run Code Online (Sandbox Code Playgroud)

如何使外部的实例B中A?

class A {
    B name = new B();
}
Run Code Online (Sandbox Code Playgroud)

将得到一个内在的实例B.

java inner-classes

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

使用hibernate和JPA获取惰性对象

我怎么能得到一个懒惰的对象?

例如,我有一个"客户"表和"请求"表,然后我使用hibernate和JPA构建一个项目.

在客户表中有一个像这样的代码

@OneToMany(cascade = CascadeType.ALL, fetch =FetchType.LAZY , mappedBy = "customer")
public Set<Request> getRequests() {
    return this.requests;
}
Run Code Online (Sandbox Code Playgroud)

所以,如果从客户对象调用getRequests()方法,它返回一个空对象,因为它是懒惰的.

如何在不使用EAGER注释的情况下获取完整的惰性对象?

我已经看到我的问题取决于会话,因为它很接近.因此,在服务器端,我需要通过JPA保持开放会话.我该怎么做?

这是我的applicationContext.xml的一部分,但它不起作用:

<bean class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean" id="entityManagerFactory">
       <property name="persistenceUnitName" value="gestazPU"/>
   </bean>

   <bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
       <property name="entityManagerFactory" ref="entityManagerFactory"/>
   </bean>

   <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

   <bean id="ebOpenEMinView" class="org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor">
       <property name="entityManagerFactory" ref="entityManagerFactory"/>
   </bean>

   <tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager"/>

   <bean id="TipoTicketDAO" class="it.stasbranger.gestaz.server.dao.impl.TipoTicketDAOImpl">
       <property name="entityManagerFactory" ref="entityManagerFactory" />
   </bean>
Run Code Online (Sandbox Code Playgroud)

hibernate jpa

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

从套接字读取失败:由对等方重置连接

当我第一次尝试通过ssh连接我的新ubuntu时,我遇到了这个异常.我试图从谷歌搜索,但直到现在没有运气.以前是否有人遇到过同样的问题?

linux ssh networking

3
推荐指数
1
解决办法
4万
查看次数

说明volatile:这段代码是线程安全的吗?

我试图说明volatile一个例子的用法和重要性,如果volatile省略的话,这个例子真的不会给出好的结果.

但我并不习惯使用volatile.如果volatile省略,则以下代码的想法是导致无限循环,并且如果volatile存在则完全是线程安全的.以下代码是否是线程安全的?你有没有其他现实和简短的代码示例使用volatile,如果没有它会给出明显不正确的结果吗?

这是代码:

public class VolatileTest implements Runnable {

    private int count;
    private volatile boolean stopped;

    @Override
    public void run() {
        while (!stopped) {
            count++;
        }
        System.out.println("Count 1 = " + count);
    }

    public void stopCounting() {
        stopped = true;
    }

    public int getCount() {
        if (!stopped) {
            throw new IllegalStateException("not stopped yet.");
        }
        return count;
    }

    public static void main(String[] args) throws InterruptedException {
        VolatileTest vt = …
Run Code Online (Sandbox Code Playgroud)

java multithreading volatile

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

pdf生成后如何打开打印对话框?

我写了一些生成动态PDF文件的动作.类似于:reports/reportGenerator.action

当我调用reports/reportGenerator?param=dialy它时会在弹出窗口中打开生成的pdf,然后我可以按打印按钮打开打印机对话框并打印它.

我现在要做的是直接打开打印机对话框.所以当我打电话reports/reportGenerator?param=dialy和完全生成pdf文件后,打开打印机对话框.那可能吗?(我知道不能跳过打印机对话框)

更多信息:动作是这样的:

sout = response.getOutputStream();
response.setContentType("application/pdf");
response.setHeader("Content-disposition","inline; filename=\"myReport.pdf\"");
sout.write(pdfBytes);
sout.flush();
sout.close();
Run Code Online (Sandbox Code Playgroud)

javascript pdf jasper-reports

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

表单在keyup上使用submit()提交两次

我有一个与此类似的jQuery/HTML代码:

<form action="/SomeAction" method="post">
  <input id="my-textbox" type="text" placeholder="Write something and press enter to continue..." />
</form>

<script type="text/javascript">
 $(function() {
     $('#my-textbox').keyup(function(e) {
        var $textbox = $(this);
        if ($textbox.val().length > 0 && e.keyCode == 13) {
           $textbox.parent('form').submit();
        }
     });
 });
</script>
Run Code Online (Sandbox Code Playgroud)

目的是在用户按下"Enter"键时自动提交表单.我经常使用Firefox,所以在我使用谷歌浏览器和Internet Explorer进行测试之前,一切都还可以.

当我在后面的浏览器中按下Enter键时,有时我会提交两次表单.这很容易被注意到,因为我会在我的数据库中获得重复的条目,并且我会看到两个POST使用Fiddler.

经过一些测试,我发现我的问题是jQuery代码,因为文本框会在没有它的情况下自动提交,并且POST在某些浏览器中使用此代码会产生第二个代码.

我的问题是:

为什么浏览器不能巧妙地阻止第二个表单发布(就像Firefox在我的测试中所做的那样)?

我是否应该在所有平台的所有主流浏览器中都期待此行为?

有没有办法改进这个代码所以我使用JavaScript执行提交,但是没有提交两次提交的表单?

javascript forms jquery javascript-events double-submit-problem

3
推荐指数
2
解决办法
5275
查看次数