Primefaces动态资源总是为空?

时间:2014-01-28 04:48:03

标签: jsf primefaces

我的示例看起来像Primefaces showcase的{​​{3}}。在展示中,没有问题 当我尝试像这样开发时,动态资源总是null
根据我的堆栈跟踪,附件字节内容不能是null 我需要做什么,配置什么?

ImageActionBean.java

@ManagedBean(name = "ImageActionBean")
@SessionScoped
public class ImageActionBean {
    private List<StreamedContent> attachmentList;

    //ManagedProperty

    @PostConstruct
    public void init() {
        attachmentList = new ArrayList<StreamedContent>();

        ProposalItem proposalItem = proposalItemService.findProposalItemById("PIT00000000000022122012014");

        for(IAttachment attachment : proposalItem.getProposalAttachmentList()) {

            System.out.println("Attachment : " + attachment.getName() + " : " + attachment.getData().length);

            attachmentList.add(new DefaultStreamedContent(new ByteArrayInputStream(attachment.getData()), attachment.getContextType()));
        }
    }

    public List<StreamedContent> getAttachmentList() {
        return attachmentList;
    }
}

attachment.xhml

<h:form id="attachmentForm">
    <p:dataTable var="file" value="#{ImageActionBean.attachmentList}" rows="1" paginator="true">
        <p:column>
            <p:graphicImage value="#{file}" />
        </p:column>
    </p:dataTable>
</h:form>

堆栈跟踪:

11:06:33,340 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Hydrangeas.jpg : 595284

11:06:33,340 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Chrysanthemum.jpg : 879394

11:06:33,341 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Desert.jpg : 845941

11:06:33,341 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Tulips.jpg : 620888

11:06:33,341 INFO  [stdout] (http-localhost-127.0.0.1-8080-1) Attachment : Penguins.jpg : 777835

11:06:33,478 SEVERE [org.primefaces.application.PrimeResourceHandler] (http-localhost-127.0.0.1-8080-1) Error in streaming dynamic resource. null
11:06:33,478 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/tds-insu].[Faces Servlet]] (http-localhost-127.0.0.1-8080-1) Servlet.ser
vice() for servlet Faces Servlet threw exception: java.io.IOException: java.lang.NullPointerException
    at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:109) [primefaces-4.0-20130910.075046-7.jar:4.0-SNAPSHOT]
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:591) [jboss-jsf-api_2.1_spec-2.0.5.Final.jar:2.0.5.Final]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.omnifaces.filter.FacesExceptionFilter.doFilter(FacesExceptionFilter.java:56) [omnifaces-1.7.jar:1.7]
    at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:77) [omnifaces-1.7.jar:1.7]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98) [primefaces-4.0-20130910.075046-7.jar:4.0-SNAPSHOT]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.AS71.Final.jar:2012-02-10 15:31]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]
    at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]
    at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_23]
Caused by: java.lang.NullPointerException
    at org.primefaces.application.PrimeResourceHandler.handleResourceRequest(PrimeResourceHandler.java:83) [primefaces-4.0-20130910.075046-7.jar:4.0-SNAPSHOT]
    ... 25 more     

0 个答案:

没有答案