小编Vac*_*dik的帖子

EJB 3.1 @LocalBean与没有注释

我理解本地视图,远程视图和无界面视图之间的区别.我只是不明白"无视图"(无注释)和无界面视图之间的区别.还有为什么我要用我的界面注释@Local?如果我根本不对界面进行注释会有什么不同呢?

java ejb java-ee

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

Java swing弹出菜单和jlist

这是我的问题:我有一个jList和一个弹出菜单.当我右键单击jList时,弹出菜单显示.问题是鼠标指向的jList项目不会选择.我希望它能做到这一点.当我将光标指向列表中的某个项目并按下右键时,我想要发生两件事.选择我单击的项目并显示弹出菜单.

我试过这个:

jLists.addMouseListener(new MouseAdapter() {

     @Override
     public void mousePressed(MouseEvent e) {
            jList.setSelectedIndex(jList.locationToIndex(e.getPoint()));
     }
});

jList.setComponentPopupMenu(jPopupMenu);
Run Code Online (Sandbox Code Playgroud)

但它只显示弹出菜单.如果我删除这一行:

jList.setComponentPopupMenu(jPopupMenu);
Run Code Online (Sandbox Code Playgroud)

然后右键单击选择工作(但弹出菜单不显示).

那么,您认为使这两个功能(两者)都起作用的最佳方法是什么?

谢谢,抱歉我的英语.

java swing menu popup jlist

21
推荐指数
2
解决办法
2万
查看次数

Spring Security和LDAP身份验证

我正在尝试设置LDAP身份验证,这是我的spring-security.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
       http://www.springframework.org/schema/security
       http://www.springframework.org/schema/security/spring-security.xsd">

    <http auto-config="true" use-expressions="true">
        <intercept-url pattern="/**" access="permitAll()"/>

        <form-login login-processing-url="/static/j_spring_security_check"
                    login-page="/login"
                    authentication-failure-url="/login/error"/>
        <logout logout-url="/logout"/>
    </http>

    <ldap-server id="ldapServer" url="ldap://example.com:PORT/dc=example,dc=com" />

    <authentication-manager>
        <ldap-authentication-provider server-ref="ldapServer" user-dn-pattern="uid={0},ou=people"/>
    </authentication-manager>
</beans:beans>
Run Code Online (Sandbox Code Playgroud)

根据Spring安全文档,这应该可行,但它不会抛出此异常:

2012-01-24 23:05:35,843 ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.context.ApplicationContextException: No BaseLdapPathContextSource instances found. Have you added an <ldap-server /> element to your application context? If you have declared an explicit bean, do not use lazy-init
    at org.springframework.security.config.ldap.ContextSourceSettingPostProcessor.postProcessBeanFactory(ContextSourceSettingPostProcessor.java:42)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:646)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
    at …
Run Code Online (Sandbox Code Playgroud)

java spring ldap spring-security

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

使用XQuery获取XML文件的文件名

我将我的实体存储在eXist XML数据库中,并使用文件名(资源ID)作为实体的ID.

例:

String xquery = "for $movie in collection('/db/movie')//movie "
    + "return $movie";
Run Code Online (Sandbox Code Playgroud)

执行此查询后,我检索org.xmldb.api.base.Resource其内容用于创建实体的实例.当我想设置这个实体的id时,我这样做:

dvd.setId(rs.getId());
Run Code Online (Sandbox Code Playgroud)

问题是,如果我执行这样的查询:

String xquery = "for $dvd in collection('/db/dvd')//dvd "
        + "return <dvd>"
        + "{$dvd/title}"
        + "{$dvd/type}"
        + "{"
        + "<content>"
        + " {"
        + " for $movie in $dvd/content//movie"
            + "     let $movieIn := doc(concat(\"/db/movie/\", $movie/@id))/movie"
        + "     return "
            + "                    <movie id=\"{$movie/@id}\">"
            + "                          {$movieIn/name}"
            + "                          {$movieIn/director}"
            + "                          {$movieIn/year}"
            + "                          {$movieIn/country}"
            + "                          {$movieIn/actors}"
            + "                          {$movieIn/genres}" …
Run Code Online (Sandbox Code Playgroud)

java xquery exist-db

8
推荐指数
2
解决办法
6059
查看次数

创建实体规则

我想知道这个简单问题的答案.

当我创建一个实体对象并且我想限制一个属性的设置时(例如我不想让任何人设置一个小于1的整数值到属性),我应该在这个属性的setter中实现它或者我应该在处理这些对象的类中检查后者的这个限制?一般来说,只要我的getter返回并且setter设置属性,我可以实现getter和setter吗?

我知道java中有一些规则(代码约定),所以我不想破坏它们中的任何一个.

在此先感谢,希望我的问题足够明确,并对我可能犯的任何语法错误表示抱歉:/.

java hibernate jpa

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

JIRA REST API和kerberos身份验证

我正在努力通过kerberos进行Jira REST API身份验证.基本身份验证按预期工作.

如果我使用Web浏览器访问登录页面(在我使用kinit之后),然后在我的python脚本中使用生成的JSESSIONID,我可以使用REST而不会获得401.但我没有使用我的python脚本如何做到这一点,我尝试使用requests_kerberos,但是当我请求登录页面时,它只返回基本登录表单而不是自动登录.

您知道如何将JIRA REST API与kerberos身份验证一起使用吗?

谢谢你的回答.

python authentication rest kerberos jira

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

JPA和DAO执行删除操作

我想知道remove方法的哪个实现更好:

public void remove(T t) {
   entityManager.remove(entityManager.merge(t));
}

public void remove(PK pk) {
   entityManager.remove(entityManager.getReference(entityType, pk));
}
Run Code Online (Sandbox Code Playgroud)

我已经阅读了很多关于这方面的文章,几乎每一篇文章都与第一种方法类似,在我看来这是非常不必要的,因为它可以在不需要从数据库中检索整个实体的情况下完成(如果是不存在于持久化上下文中)然后将其删除.有什么我想念的东西,第一种方法真的更好吗?

java dao jpa

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

如何使用PrettyFaces重定向回同一页面?

我想知道如何在动作调用中重定向到同一页面.

我有这个命令按钮:

<h:commandButton action="#{someBean.edit}" value="Edit" />
Run Code Online (Sandbox Code Playgroud)

这是行动:

@Named
@RequestScoped
public class SomeBean {

    public String edit() {
        // some logic
        return "theSamePage?faces-redirect=true";
    }

}
Run Code Online (Sandbox Code Playgroud)

但它不会重定向到同一页面,只是刷新它,所以当我尝试通过按F5键刷新页面时,会发生重复提交.在正常情况下,这可以通过post/redirect/get来解决.但是当action方法返回与发送请求的页面的viewId相同的viewId时,faces将不会发送重定向.

我使用prettyfaces.

java jsf prettyfaces

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

使用 Micronaut HTTP 客户端时,Cloud Run 应用程序响应“503 服务不可用”

我的应用程序基于 Micronaut 和 GraalVM (java 11),并对以下内容进行简单调用http://httpbin.org/get

@Controller("/api")
class HelloWorld(
    @Client("http://httpbin.org")
    private val httpClient: RxHttpClient
) {
    private val logger = LoggerFactory.getLogger(javaClass)

    @Get("/hello")
    fun hello(): String {
        return "Hello World!"
    }

    @Get("/fb")
    fun fb(): Flowable<String> {
        logger.info("Trying to call FB")
        logger.info("Using url http://httpbin.org/get")
        try {
            return httpClient.retrieve("/get")
                .doOnError { logger.error("Error calling fb api flowable", it) }
                .doFinally { logger.info("Finished calling FB api flowable") }
        } catch (ex: Exception) {
            logger.error("Error calling fb api", ex)
            throw ex
        } finally { …
Run Code Online (Sandbox Code Playgroud)

kotlin graalvm micronaut google-cloud-run micronaut-client

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

twitter-bootstrap模态确认对话框

我无法弄清楚如何使用bootstrap模式实现确认对话框,这是我的代码不起作用:

<div id="id" class="modal hide">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h3>title</h3>
    </div>
    <div class="modal-body">
        <p>confirm message</p>
    </div>
    <div class="modal-footer">
        <button data-dismiss="modal" class="btn">No</button>
        <button id="id-confirm" class="btn btn-primary">Yes</button>
    </div>
</div>
<a id="a" href="http://example.com">link</a>
<script type="text/javascript">
    var confirmed = false;
    var modal = $('#id');
    var clickee = $('#a');

    clickee.click(function() {
        if (!confirmed) {
            modal.modal('show');
            return false;
        }
    });
    $('#id-confirm').click(function() {
        confirmed = true;
        clickee.click();
        modal.modal('hide');
    });
</script>
Run Code Online (Sandbox Code Playgroud)

当我点击链接时link,弹出对话框,但是当我确认它时,没有重定向,当我link再次点击链接时,我被重定向.

我可以重定向到链接的href,我知道,但我想让它可重用,而不是链接(a元素)我也可以使用按钮或在按钮上定义onclick事件.

谢谢你的回答.

javascript jquery twitter-bootstrap

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