小编Gat*_*het的帖子

有状态会话bean应该实现Serializable

我有一个简单的问题,但我找不到Java EE 6的答案!

有状态会话bean是否应该实现Serializable?

我测试了有没有实现java.io.Serializable,没有不同的错误.

我的感觉告诉我,有状态会话bean必须实现Serializable,因为它可以在长期会话中持久化......

java serialization stateful-session-bean java-ee-6

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

如何使用git将本地更改从一台PC复制到另一台PC

我正在使用Git,有时我会在本地桌面上开始工作,我想将这些开放作品复制到我的笔记本电脑上以在家完成它。

为了保持我的存储库整洁,我不想将这些更改推送到某个分支,因为我的工作可能尚未完成,未经测试等等。

git

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

将Singleton会话Bean注入无状态会话Bean

通过在无状态会话Bean中使用Singleton会话Bean,是否允许(和良好实践)在我们的应用程序中保存一些共享信息?

SSB将被注入SLSB.

@Stateless
public class MySLSB {

    @Inject
    MySSB mySSB;
Run Code Online (Sandbox Code Playgroud)

-

@Singleton
@Lock(READ)
public class MySSB implements Serializable {

    private static final long serialVersionUID = 1L;
Run Code Online (Sandbox Code Playgroud)

java stateful-session-bean java-ee-6

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

在Java中使用Joda-Time DateTime失败了一个月

我尝试使用java DateTime和方法从给定的开始日期添加完整的月份plusMonths().

当我的开始时间是在一个月的开始时,一切都像预期的那样工作:

DateTime startOfMonth = new DateTime(2013, 1, 1, 00, 00, 00);
    System.out.println(startOfMonth.toString());
    for (int i = 0; i < 12; i++) {
        startOfMonth = startOfMonth.plusMonths(1);
        System.out.println(startOfMonth.toString());
}
Run Code Online (Sandbox Code Playgroud)

输出是每个月的第一天,就像预期的一样,一切都很棒!

2013-01-01T00:00:00.000+01:00
2013-02-01T00:00:00.000+01:00
2013-03-01T00:00:00.000+01:00
2013-04-01T00:00:00.000+02:00
2013-05-01T00:00:00.000+02:00
2013-06-01T00:00:00.000+02:00
2013-07-01T00:00:00.000+02:00
2013-08-01T00:00:00.000+02:00
2013-09-01T00:00:00.000+02:00
2013-10-01T00:00:00.000+02:00
2013-11-01T00:00:00.000+01:00
2013-12-01T00:00:00.000+01:00
2014-01-01T00:00:00.000+01:00
Run Code Online (Sandbox Code Playgroud)

但是,当我将我的例子改为月末时,它不会返回我想要的东西!

System.out.println("");
DateTime endOfMonth = new DateTime(2012, 12, 31, 23, 59, 59);
System.out.println(endOfMonth.toString());
for (int i = 0; i < 12; i++) {
    endOfMonth = endOfMonth.plusMonths(1);
    System.out.println(endOfMonth.toString());
}
Run Code Online (Sandbox Code Playgroud)

返回:

2012-12-31T23:59:59.000+01:00
2013-01-31T23:59:59.000+01:00
2013-02-28T23:59:59.000+01:00
2013-03-28T23:59:59.000+01:00
2013-04-28T23:59:59.000+02:00 …
Run Code Online (Sandbox Code Playgroud)

java datetime jodatime

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

浏览器错误:未定义PrimeFacesExt

我使用PrimeFaces 3.5与PrimeFaces Extensions 0.7.0和OmniFaces 1.4版

我有一个带有ui的accordionPanel:片段女巫看起来像那样:

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
    xmlns:pe="http://primefaces.org/ui/extensions"> 
<ui:fragment>

    <f:metadata>
        <f:event type="javax.faces.event.PreRenderViewEvent" listener="#{fleet.preRenderView()}" />
    </f:metadata>

    <!-- Other things.... -->

    <!-- Dialogs -->
    <p:dialog id="createSubFleetDialog" widgetVar="createSubFleet"
        header="#{msg.administration_fleet_createFleetDialog_title}">
        <h:panelGrid id="createSubFleetPanel" columns="2">

            <!-- Here im using primefaces extensions -->

            <h:outputLabel for="newFleetName" value="#{msg.administration_fleet_fleetName}" />
            <p:inputText id="newFleetName" value="#{fleet.fleetName}">
                <pe:keyFilter mask="alphanum"></pe:keyFilter>
            </p:inputText>

        </h:panelGrid>
    </p:dialog>


</ui:fragment>
</html>
Run Code Online (Sandbox Code Playgroud)

eclipse中没有警告或错误,但在运行我的应用程序时出现浏览器错误: 未捕获的ReferenceError:未定义PrimeFacesExt

有谁知道如何解决这个问题?

java jsf primefaces primefaces-extensions

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

Primefaces 3.5如何使用dataExporter导出不可见的dataTable行

我使用primefaces 3.5,我有ap:dataTable与一些行和数据,我想将这些数据导出到xls文件或其他东西.

我用过代码:

<p:commandButton id="exportBtn" icon="ui-icon-extlink" styleClass="statisticsMenuButton" ajax="false" title="#{msg.general_export_as_xls}">
    <p:dataExporter type="xls" target="cc-eventListTable-eventList" fileName="statistics"/>
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)

这很好用!

我的问题是,我想在导出的文件和浏览器dataTable中有不同的单元格文本.

例如,在导出的xls文件中,我需要在浏览器数据表中进行其他日期格式化.否则浏览器单元格中的文本太长了!

我尝试仅为导出的表添加一个render ="false"和exportable ="true"的附加列.但不幸的是它不起作用!

有人知道怎么做吗?

java jsf primefaces

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

未捕获自定义RuntimeException

我有自己的ApplicationException女巫,扩展了RuntimeException:

package com.haslerrail.aura.common.exception;

public class ApplicationException extends RuntimeException {

    private static final long serialVersionUID = 1L;

    private final ErrorCode errorCode;

    private final Object[] arguments;

    public ApplicationException(final ErrorCode errorCode, final Object... arguments) {
        super();
        this.errorCode = errorCode;
        this.arguments = arguments;
    }

    public ErrorCode getErrorCode() {
        return errorCode;
    }

    public Object[] getArguments() {
        return arguments;
    }

}
Run Code Online (Sandbox Code Playgroud)

此异常将由我的无状态bean引发:

public void doSomething()
        throws IOException, ApplicationException, InternalException {
    if (true) {
        throw new ApplicationException(ErrorCode.FILE_TYPE_NOT_SUPPORTED, "test");
    }
}
Run Code Online (Sandbox Code Playgroud)

我想通过我的sessionScoped bean捕获此runtimeException:

public void doXXX(final FileUploadEvent event) …
Run Code Online (Sandbox Code Playgroud)

java exception-handling java-ee runtimeexception

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

Primefaces 5.1中包含多个文件的文件上传失败

我尝试使用PF 5.1和OmniFaces 1.7版在primefaces上进行文件上传.

我的.xhtml代码:

<h:form id="fileImportForm" styleClass="prepend-top"
    prependId="false">

    <div style='margin-bottom:10px'>
        <h:outputLabel value="#{msg.file_import_msg}"/>
    </div>
    <p:fileUpload id="fileImport" fileUploadListener="#{fileImport.handleFileUpload}"   
        mode="advanced"  
        update="messages"   
        multiple="true"
        label="#{msg.file_import_choose_label}" 
        uploadLabel="#{msg.file_import_upload_label}" 
        cancelLabel="#{msg.file_import_cancel_label}"       
    />  
    <p:growl id="messages" showDetail="true"/>  

</h:form>
Run Code Online (Sandbox Code Playgroud)

我的支持豆:

package test.boundary;

import javax.inject.Named;
import org.primefaces.event.FileUploadEvent;
import com.haslerrail.aura.common.exception.SystemException;

/**
 * BackingBean for <code>fileImport.xhtml</code> page.
 *
 */
@Named
public class FileImport implements java.io.Serializable {

    private static final long serialVersionUID = 1L;

    public void handleFileUpload(final FileUploadEvent event) throws SystemException, InterruptedException {

        if (event == null || event.getFile() == null || event.getFile().getSize() == 0) { …
Run Code Online (Sandbox Code Playgroud)

jsf file-upload primefaces

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

在角度为 5 的 *ngFor 循环中使用 angular i18n

我想在模板中的 ngFor-Loop 中使用动态翻译,如下所示:

<mat-card *ngFor="let user of usersList">
    <mat-card-title>
        <span>{{user.name}}</span>
    </mat-card-title>
    <mat-card-content>
        <!--This is the enum i would like to translate dynamic -->
        <span i18n="Role@@role">{{user.role}}</span>
    </mat-card-content>
</mat-card>
Run Code Online (Sandbox Code Playgroud)

angular 5 i18e(国际化)的当前板载工具有没有办法动态转换这个枚举值?

正如我所读到的,在 Angular 6.1 或更高版本中,将有一种方法可以转换 .ts 中的值。但是,如果我现在想使用它呢?任何解决方法?

使用替代文本消息可能不是一个好方法,因为如果枚举中有数百个值怎么办。我不会在 html 代码中重复我的枚举。

internationalization angular

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

使用带有saltstack的公式

我是saltstack的新手,我想使用saltstack公式安装postgres或apache或其他任何东西.

我从git下载了repo

git clone https://github.com/saltstack-formulas/apache-formula.git

git clone https://github.com/saltstack-formulas/postgres.git

到我的/ srv/salt目录.

之后,我添加了线条

file_roots:
base:
      - /srv/salt
      - /srv/formulas/apache-formula
      - /srv/formulas/postgres
Run Code Online (Sandbox Code Playgroud)

在/ etc/salt/master文件中.

然后我在文件夹/ srv/salt中创建了一个文件top.sls,其中包含以下内容:

include:
   - apache
Run Code Online (Sandbox Code Playgroud)

要运行此即时通讯使用

salt '*' state.highstate

我得到的只是错误信息:

xxx.yyyyyyy.com:
----------
      ID: states
Function: no.None
  Result: False
 Comment: No Top file or external nodes data matches found
 Changes:   

Summary
------------
Succeeded: 0
Failed:    1
------------
Total:     1
Run Code Online (Sandbox Code Playgroud)

我错了什么?我阅读了http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html上的手册,但本手册完全没有帮助!

salt-stack

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

在文件更改时获取JAX-RS java.lang.NullPointerException

每次我在eclipse中的java项目中更改代码行时都会收到错误:

Failed to build or refresh the JAX-RS metamodel while processing a change in the Java Model
java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)

我不在我的java项目中使用JAX-RS!我在我的偏好中禁用了JAX-RS验证器,但错误仍然存​​在!

我的eclipse版本是:

面向Web开发人员的Eclipse Java EE IDE.

版本:Luna Service Release 1(4.4.1)

构建ID:20140925-1800

有什么想法吗?

java eclipse jax-rs

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

在wildfly中注入EJB时的安全性异常

我尝试从JBoss AS 7迁移到Wildfly 8.2.从Java 1.6到Java 1.7.在将ejb bean注入我的批处理作业时,我得到了一些安全性异常.

这是我的调度程序:(每分钟运行一次)

@Startup
@Singleton
public class MyBatchScheduler {

    @Inject
    MyBatch myBatch;

    @Schedule(second = "30", minute = "*/1", hour = "*", persistent = false)
    public void runBackgroundTasks() {
        myBatch.runBackgroundTasksAsync();
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的批次:(每分钟由调度程序调用)

 @Stateless
 public class MyBatch {

    @Inject
    MyTestbean myTestbean;

    @Asynchronous
    public void runBackgroundTasksAsync() {
        myTestbean.doSomething();
        System.out.println("Batch");
    }
 }
Run Code Online (Sandbox Code Playgroud)

这是我的无状态bean产生问题:(只是一个空的方法)

public class MyTestbean implements Serializable {

    private static final long serialVersionUID = 1L;

    public void doSomething() {

    }
}
Run Code Online (Sandbox Code Playgroud)

我的jboss-ejb3.xml与security-domain:

<?xml version="1.1" encoding="UTF-8"?>
<jboss:ejb-jar
    xmlns:jboss="http://www.jboss.com/xml/ns/javaee" …
Run Code Online (Sandbox Code Playgroud)

java jboss java-ee wildfly

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