小编Ami*_*ira的帖子

singleton和prototype bean有什么区别?

我是春天的新手,我读到了这个:

基本上bean有一个范围,用于定义它们在应用程序中的存在

Singleton:表示每个Spring IOC容器的单个bean定义到单个对象实例.

原型:表示对任意数量的对象实例的单个bean定义.

什么是"对象实例".

spring dependency-injection

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

启用选择时,DataModel必须实现org.primefaces.model.SelectableDataModel.

我正在尝试使用多行选择创建一个DataTable,但是我在这里得到一个错误是http://www.primefaces.org/showcase/ui/datatableRowSelectionMultiple.jsf教程的链接:

这是我的xhtml:

    <p:dataTable border="1" value="#{projectAdminisrationMB.projectNoUsersList}" 
                     var="userObj"
                     selection="#  
         {projectAdminisrationMB.selectedUsers}"
 selectionMode="multiple" rowIndexVar="rowIndex"binding="#{table2}">
<p:column id="column3">
<f:facet name="header">
<h:outputText value=" user "></h:outputText>
</f:facet>

      <h:outputText value="#{userObj.name}"/>  

                            /
  <h:outputText value="#{userObj.lastName}"></h:outputText>

  &nbsp;
   <h:outputText value="#{userObj.firstName}"></h:outputText>
  </p:column>

    <f:facet name="footer">  
     <p:commandButton id="addProjectUser" value=" Add " onclick="dlg1.show()" />  
      <p:commandButton id="deleteProjectUser" value=" Delete " />  

    </f:facet> 

</p:dataTable>
Run Code Online (Sandbox Code Playgroud)

托管Bean:

 @ManagedBean
 @SessionScoped
 public class ProjectAdminisrationMB implements Serializable {

private static final long serialVersionUID = 1L;

private String projectName;
private List <User> projectUsersList;
private List<User> projectNoUsersList;
private List<User> selectedUsers;

private String projectAdmin;


public …
Run Code Online (Sandbox Code Playgroud)

jsf facelets primefaces

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

用java替换word文档模板中的变量

我想加载一个模板word文档来添加内容并保存为新文档.我正在研究.doc文件.

经过长时间的研究,我只找到了docx的解决方案:

http://www.smartjava.org/content/create-complex-word-docx-documents-programatically-docx4j

http://www.sambhashanam.com/mail-merge-in-java-for-microsoft-word-document-part-i/

所以我想替换以这种格式编写的任何变量:$VAR它的值.我可以用velocity或Apache-poi来做,它的最佳解决方案是什么.任何帮助将不胜感激.

java velocity apache-poi

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

java.lang.ClassNotFoundException:org.springframework.orm.hibernate4.LocalSessionFactoryBean

我是Spring的新手,这是我的第一个例子(JSF 2,PrimeFaces 3,Spring和Hibernate Integration),这里是pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-  
v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MVNO.ONP.project</groupId>
<artifactId>MVNOONPProject</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MVNOONPProject Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>3.8.1</version>
  <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring</artifactId>
    <version>2.5.6.SEC03</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-api</artifactId>
  <version>2.1.0-b03</version>
</dependency>
<dependency>
  <groupId>com.sun.faces</groupId>
  <artifactId>jsf-impl</artifactId>
  <version>2.1.0-b03</version>
</dependency>
 <dependency>
  <groupId>javax.servlet</groupId>
  <artifactId>jstl</artifactId>
  <version>1.2</version>
</dependency>
 <dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-core</artifactId>
    <version>4.1.9.Final</version>
 </dependency>

 <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.22</version>
 </dependency>
 </dependencies>
 <build>
  <finalName>MVNOONPProject</finalName>
 </build>
 </project>
Run Code Online (Sandbox Code Playgroud)

当我运行该项目时,我收到此错误:

Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate4.LocalSessionFactoryBean] for bean with name 'SessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]; …
Run Code Online (Sandbox Code Playgroud)

spring maven spring-orm

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

启用选择时,DataModel必须实现org.primefaces.model.SelectableDataModel,但我已经定义了rowKey

我有一个可选的PrimeFaces 3.4.1数据表:

<p:dataTable value="#{projectAdminisrationMB.selectedUserMemberOfGroups}" var="group1" 
    rowKey="#{group1.name}" selectionMode="single" selection="#{projectAdminisrationMB.selectedBelongToGroup}">
    ...
</p:dataTable>
Run Code Online (Sandbox Code Playgroud)

我收到这个错误:

com.sun.faces.context.PartialViewContextImpl $ PhaseAwareVisitCallback访问Grave:javax.faces.FacesException:当启用选择时,DataModel必须实现org.primefaces.model.SelectableDataModel.

但是我已经rowKey根据FacesException设置了:当启用选择时,DataModel必须实现org.primefaces.model.SelectableDataModel.这是怎么造成的,我该如何解决?

jsf selectable primefaces row-key

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

使用itext将文本文件转换为pdf时设置编码

我正在努力让itext正确输出我的UTF-8编码文本,实际上输入文件包含像°和拉丁字符(é,è,à...)这样的符号.

但我没有找到解决方案这是我正在使用的代码:

BufferedReader input = null;
Document output = null;
System.out.println("Convert text file to pdf");
System.out.println("input  : " + args[0]);
System.out.println("output : " + args[1]);
try {
  // text file to convert to pdf as args[0]
  input = 
    new BufferedReader (new FileReader(args[0]));
  // letter 8.5x11
  //    see com.lowagie.text.PageSize for a complete list of page-size constants.
  output = new Document(PageSize.LETTER, 40, 40, 40, 40);
  // pdf file as args[1]
  PdfWriter.getInstance(output, new FileOutputStream (args[1]));

  output.open();
  output.addAuthor("RealHowTo");
  output.addSubject(args[0]);
  output.addTitle(args[0]);

  BaseFont courier = BaseFont.createFont(BaseFont.COURIER, …
Run Code Online (Sandbox Code Playgroud)

java itext

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

如何从SSL证书文件中读取信息

我是 SSL 证书的新手,我需要从本地 .crt 文件而不是 URL 中读取验证日期和到期日期,如以下打印屏幕所示:

在此输入图像描述

那么有没有一个 JAVA Api 可以帮助做到这一点。

java

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

@AfterMapping 方法在生成的类中未调用

我正在尝试自定义映射,使用字符串来确定对象属性,因此我写了以下内容:

@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public abstract class ProductMapper {

public abstract ProductInput asProductInputFromIdentifier(String identifier);

@AfterMapping
protected void determineIdentifier(String identifier, @MappingTarget ProductInput out) {
    if (StringUtils.contains(identifier, '?')) {
        out.setExternalId(identifier);
    } else {
        out.setInernalId(identifier);
    }
}
}
Run Code Online (Sandbox Code Playgroud)

生成的类不会调用确定标识符方法。我通过直接在asProductInputFromIdentifier方法上使用 Java 表达式找到了另一个解决方案,但我真的想使用@AfterMapping编写清晰的代码。

@Mapping(target = "externalId", expression = "java( org.apache.commons.lang3.StringUtils.contains(identifier, '|') ? identifier : null )")
@Mapping(target = "internalId", expression = "java( !org.apache.commons.lang3.StringUtils.contains(identifier, '|') ? identifier : null )")
public abstract ProductInput asProductDetailInputFromIdentifier(String identifier);
Run Code Online (Sandbox Code Playgroud)

我不明白为什么它不起作用是因为我在方法参数中没有对象吗?

mapstruct

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

UrlValidator类型已弃用

我正在编写一个自定义验证器来检查用户输入的URL:

package tn.talan.testFramework.validators;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;

import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

import org.apache.commons.validator.UrlValidator;





  public class URLCustomValidator implements Validator{

public void validate(FacesContext context, UIComponent component,Object value) throws ValidatorException {

    String enteredURL = (String) value;
    String[] schemes = {"http","https"};
    System.out.println(enteredURL);
    FacesMessage message = null ;
    String messageStr = null ;

            UrlValidator urlValidator = new UrlValidator(schemes);


           if (!urlValidator.isValid(enteredURL)) {
               System.out.println("url is invalid valid");
               message = new FacesMessage();
               messageStr = (String)component.getAttributes().get("message");
               if (messageStr == null) {

                    messageStr = "Inavalid URL";

                  }
                  message.setDetail(messageStr); …
Run Code Online (Sandbox Code Playgroud)

java validation jsf

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

如何在TextField中添加项目符号

我想在我的静态文本和文本字段中添加项目符号,我将样式标记添加到jrxml但是它对我不起作用:

这是一个例子:

文本域 :

<textField isBlankWhenNull="true">
    <reportElement uuid="cfd514bc-d1c5-4369-b10d-71042b046e37" x="11" y="0" width="400" height="12"/>
    <textElement/>
    <textFieldExpression><![CDATA[<style size="40">.</style>$F{LMSG}]]></textFieldExpression>
</textField>
Run Code Online (Sandbox Code Playgroud)

静态文本:

<staticText>
    <reportElement uuid="c1485aba-09a4-4c7b-9106-0893341f1368" x="44" y="107" width="309" height="15"/>
    <textElement>
        <font size="9"/>
    </textElement>
    <text><![CDATA[<style size="40">.</style>Je déduis cet avoir de ma commande]]></text>
</staticText>
Run Code Online (Sandbox Code Playgroud)

pdf jasper-reports

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