You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by fachhoch <fa...@gmail.com> on 2010/11/12 21:43:25 UTC

download link in abstractTab

I have a link in a AbstractTab , on click I start download a file ,
any time I click on this  link whole tab is reloaded , please tell me is
this normal? , is there any way I can control this ?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/download-link-in-abstractTab-tp3040311p3040311.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: download link in abstractTab

Posted by fachhoch <fa...@gmail.com>.
this error is happening in all instances not just production ,I tried
commenting response.close()  , no  difference I still get the error.

Also I tried   wicket way of download still the same 

here the code for wicket download

<code>
new Link<Void>("downloadHelp"){
			@Override
			public void onClick() {
				try{
					
										IResourceStream resourceStream = new ByteArrayResourceStream(
manualService.getManualBytes(UserContextHolder.getOrgAbbrev(),"user_guide")); 
					      getRequestCycle().setRequestTarget( new
ResourceStreamRequestTarget( resourceStream ) { 
					        public String getFileName( ) { 
					          return("User Guide.pdf"); 
					        } 
					     }); 

				}catch (Exception e) {
					throw new RuntimeException(e);
				}	
			}
		})

</code>

and ByteArrayResourceStream
<code>
public class ByteArrayResourceStream implements IResourceStream {
	
	
	private byte[] content = null; 

	public ByteArrayResourceStream( byte[] content) { 
	    this.content = content; 
	  } 
	
	
	@Override
	public void close() throws IOException {
		// TODO Auto-generated method stub

	}

	@Override
	public String getContentType() {
		// TODO Auto-generated method stub
		return "application/octet-stream";
	}

	@Override
	public InputStream getInputStream() throws ResourceStreamNotFoundException
{
		// TODO Auto-generated method stub
		return(new ByteArrayInputStream( content ));
	}

	@Override
	public Locale getLocale() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long length() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void setLocale(Locale locale) {
		// TODO Auto-generated method stub

	}

	@Override
	public Time lastModifiedTime() {
		// TODO Auto-generated method stub
		return null;
	}

}

</code>
please help us resolve this.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/download-link-in-abstractTab-tp3040311p3043049.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: download link in abstractTab

Posted by Frank van Lankvelt <f....@onehippo.com>.
not sure why you would get it in production and not in development.
But you should drop the WebResponse#close call; that will be invoked
by Wicket later when it's flushing everything to the servlet response.
 (in fact, that's when the exception is thrown, glancing over the
stacktrace)

cheers, Frank

On Mon, Nov 15, 2010 at 4:36 AM, fachhoch <fa...@gmail.com> wrote:
>
> we are in production and we are getting this error , please somebody help me,
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/download-link-in-abstractTab-tp3040311p3042472.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



-- 
Hippo
Europe  •  Amsterdam  Oosteinde 11  •  1017 WT Amsterdam  •  +31 (0)20 522 4466
USA  • San Francisco  185 H Street Suite B  •  Petaluma CA 94952-5100
•  +1 (707) 773 4646
Canada    •   Montréal  5369 Boulevard St-Laurent #430 •  Montréal QC
H2T 1S5  •  +1 (514) 316 8966
www.onehippo.com  •  www.onehippo.org  •  info@onehippo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: download link in abstractTab

Posted by fachhoch <fa...@gmail.com>.
we are in production and we are getting this error , please somebody help me, 


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/download-link-in-abstractTab-tp3040311p3042472.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: download link in abstractTab

Posted by fachhoch <fa...@gmail.com>.
<code>


        setRedirect(false);
        WebResponse response = (WebResponse) getResponse();
        response.setAttachmentHeader(filename);
        response.setLastModifiedTime(Time.now());
        response.setContentType("application/octet-stream");
        response.write(
        		new ByteArrayInputStream(filedata));
        response.close();

</code>

does this download code has any issues ?
I noticed whenever this code is called the whole page is reloaded 

also I get this eception

<code>
java.lang.IllegalStateException: STREAM
	at org.eclipse.jetty.server.Response.getWriter(Response.java:640)
	at
javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:122)
	at org.apache.wicket.protocol.http.WebResponse.write(WebResponse.java:392)
	at
org.apache.wicket.protocol.http.BufferedWebResponse.close(BufferedWebResponse.java:74)
	at
org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:500)
	at
org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:317)
	at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
	at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:265)
	at
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
	at
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:275)
	at
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:149)
	at
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
	at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
	at
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:198)
	at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
	at
org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1187)
	at
org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:421)
	at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at
org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:493)
	at
org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:226)
	at
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:924)
	at
org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:358)
	at
org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
	at
org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:860)
	at
org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at
org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:245)
	at
org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
	at
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:113)
	at org.eclipse.jetty.server.Server.handle(Server.java:335)
	at
org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:588)
	at
org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:1029)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:549)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:211)
	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:418)
	at
org.eclipse.jetty.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:476)
	at
org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)
	at java.lang.Thread.run(Thread.java:619)

</code>


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/download-link-in-abstractTab-tp3040311p3041120.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org