嘗試顯示項目列表時出現以下問題。對於每個項目,我必須顯示通過Wicket WebResource
動態加載的圖像。在用戶滾動時,使用Ajax滾動在—時間步驟— 50加載項目。未找到Wicket圖像組件
[ERROR] 2011-04-19 09:58:18000 btpool0-1 org.apache.wicket.RequestCycle.logRuntimeException(主機=,=請求,現場=): org.apache.wicket.WicketRuntimeException :組件documentList:scroller:batchElem:666:content:item:3:batchItemContent:linkToPreview:image在第com.webapp.document.pages.DocumentListPage頁面找不到的縮略圖 listener interface = [RequestListenerInterface name = IResourceListener,method = public abstract void org.apache.wicket.IResourceListener.onResourceRequested()]
org.apache.wicket.protocol.http.request.InvalidUrlException:org.apache.wicket.WicketRuntimeException:component documentList:scroller:batch Elem:666:content:item:3:batchItemContent:linkToPreview:imageThumbnail not found on page com.webapp.document.pages.DocumentListPage [id = 1] listener interface = [RequestListenerInterface name = IResourceListener,method = public abstract void org。 apache.wicket.IResourceListener.onResourceRequested()] at org.apache.wicket.protocol.http.WebRequestCycleProcessor.resolve(WebRequestCycleProcessor.java:262) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1310) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter。 doGet(WicketFilter.java:479) at org.apache.wicket.protocol.http.WicketFilter $$ EnhancerByGuice $$ 51619816.CGLIB $ doGet $ 6() at org.apache.wicket.protocol.http.WicketFilter $$ EnhancerByGuice $$ 51619816 $$ FastClassByGuice $$ 6d42bf5d.invoke() com.google.inject.internal.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java: 228) 在com.google.inject.internal.InterceptorStackCallback $ InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64) 在com.freiheit.monitoring.PerformanceMonitoringMethodInterceptor.invoke(PerformanceMonitoringMethodInterceptor.java:115) 在com.google.inject。 internal.InterceptorStackCallback $ InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:64) at com.google.inject.internal.InterceptorStackCallback.intercept(InterceptorStackCallback.java:44) at org.apache.wicket.protocol.http.WicketFilter $$ EnhancerByGuice $$ 51619816.doGet() 在org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312) 在org.apache.wicket.protocol.http.WicketFilter $$ EnhancerByGuice $$ 51619816.CGLIB $ $的doFilter 4()
這個問題怎麼解決?
下面是代碼的負責添加圖像的一部分:
previewLink.add(createThumbnailSmall("imageThumbnail", documentModel));
在
createThumbnailSmall(final String id, final IModel<BaseDocument> documentModel) {
// thumbnailResource is an object that contains the path of the image
if (thumbnailResource != null) {
final WebResource resource = getWebResource(thumbnailResource);
final Image image = new Image(id, resource);
return image;
}
return new InvisibleContainer(id);
}
WebResource getWebResource(final DocumentResource documentResource) {
return new WebResource() {
private static final long serialVersionUID = 1L;
@Override
public IResourceStream getResourceStream() {
return new BaseStreamResource(documentResource);
}
};
}
其中BaseStreamResource
如下:
public class BaseStreamResource extends AbstractResourceStream {
private InputStream _fileInputStream = null;
private DocumentResource _resource = null;
public BaseStreamResource(final DocumentResource documentResource) {
_resource = documentResource;
}
@Override
public InputStream getInputStream() throws ResourceStreamNotFoundException {
if (_fileInputStream == null) {
try {
if (_resource == null) {
throw new ResourceStreamNotFoundException("Resource was null");
}
_fileInputStream = _resource.getFileInputStream();
} catch (final ResourceNotAvailableException ex) {
throw new ResourceStreamNotFoundException(ex);
}
}
return _fileInputStream;
}
在HTML:
<a wicket:id="linkToPreview" href="#">
<img wicket:id="imageThumbnail" alt="Attachment"></img></a>
它會如果顯示加載圖像時涉及的一些代碼,則可以提供幫助。 – 2011-04-19 09:35:58
哪個URL用於ImageUrl? – 2011-04-19 09:38:22
我已將代碼附加到最初的帖子 – Flori 2011-04-19 10:32:38