我已经找到了一些资源:
但是我的开发环境有点不同。
- JSF 2.0
- Primefaces 4.0
- 春天 3.1.1
- Jboss缝2.3
- JBoss AS 7.1.1 最终版
如果我不使用JBoss Seam
,没关系。我无法删除JBoss Seam
,因为我的项目中有很多类。我们的团队将不得不在这些环境中继续发展。
example_2.xhtml
<h:form id="attachmentForm" enctype="multipart/form-data">
<p:dataTable var="attachment" value="#{ImageActionBean.proposalAttachmentList}" rows="1" paginator="true">
<p:column style="width:50px;">
<h:outputText value="#{attachment.id}" />
</p:column>
<p:column style="width:150px;">
<h:outputText value="#{attachment.contextType}" />
</p:column>
<p:column>
<p:graphicImage value="#{ImageActionBean.streamedImage}">
<f:param name="attachmentId" value="#{attachment.id}"/>
</p:graphicImage>
</p:column>
</p:dataTable>
</h:form>
ImageActionBean.java
@Scope(ScopeType.CONVERSATION)
@Name("ImageActionBean")
public class ImageActionBean {
private boolean initFlag = true;
@In("#{ProposalItemService}")
private IProposalItemService proposalItemService;
@In("#{AttachmentFilter}")
private AttachmentFilter attachmentFilter;
private List<ProposalAttachment> proposalAttachmentList;
@Begin(join = true)
public void init() {
initFlag = false;
proposalAttachmentList = proposalItemService.findProposalAttachById("PIT00000000000010116012014");
}
public boolean getInitFlag() {
return initFlag;
}
public List<ProposalAttachment> getProposalAttachmentList() {
return proposalAttachmentList;
}
public StreamedContent getStreamedImage() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
String attachmentId = context.getExternalContext().getRequestParameterMap().get("attachmentId");
System.out.println("Attachment ID : " + attachmentId);
IAttachment attachment = attachmentFilter.findAttachment("ProposalAttachment", attachmentId);
return new DefaultStreamedContent(new ByteArrayInputStream(attachment.getData()), attachment.getContextType());
}
}
}
日期表:
堆栈跟踪 :
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.core.manager
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: attachment
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.transaction.synchronizations
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.web.servletContexts
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.web.requestContextPath
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.core.events
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.Contexts] destroying: org.jboss.seam.web.requestServletPath
17:16:18,257 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,257 DEBUG [org.jboss.seam.contexts.FacesLifecycle] <<< End JSF request for /insudemo/view/example_2.se
am
17:16:18,277 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,277 DEBUG [org.jboss.seam.init.Initialization] Using Java hot deploy
17:16:18,280 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,280 DEBUG [org.jboss.seam.util.Resources] Loaded resource from servlet context: jndi:/default-host/ins
udemo/view/login.page.xml
17:16:18,280 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,280 DEBUG [org.jboss.seam.util.Resources] Loaded resource from servlet context: jndi:/default-host/ins
udemo/WEB-INF/pages.xml
17:16:18,280 SEVERE [org.primefaces.application.PrimeResourceHandler] (http-localhost-127.0.0.1-8080-1) Error in streaming dynamic resource. null
17:16:18,365 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,365 DEBUG [org.jboss.seam.init.Initialization] Using Java hot deploy
17:16:18,368 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,368 DEBUG [org.jboss.seam.util.Resources] Loaded resource from servlet context: jndi:/default-host/ins
udemo/view/login.page.xml
17:16:18,369 INFO [stdout] (http-localhost-127.0.0.1-8080-1) 17:16:18,369 DEBUG [org.jboss.seam.util.Resources] Loaded resource from servlet context: jndi:/default-host/ins
udemo/WEB-INF/pages.xml
17:16:18,369 SEVERE [org.primefaces.application.PrimeResourceHandler] (http-localhost-127.0.0.1-8080-1) Error in streaming dynamic resource. Expression cannot be null
顺便说一句,我没有System.out.println("Attachment ID : " + attachmentId);
在堆栈跟踪中看到我打印的消息()