You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by joinow <jo...@yahoo.com.cn> on 2010/08/23 23:54:53 UTC

How to show error msg from ResourLink and abort processing?

I am using wicket for our portlets now. I use a ResourceLink for downloading
CSV file. I used the code as shown below. But some exception may be thrown
from the method getCsvData(). How can I catch the exception and display some
error message by FeedbackPanel? 

         final WebResource csvsrc = new WebResource() { 

                        /** 
                         * 
                         */ 
                        private static final long serialVersionUID = 1L; 

                        @Override 
                        public IResourceStream getResourceStream() { 
                                // TODO Auto-generated method stub 
                                IStringResourceStream srs = null; 
                                if (true) { 
                                        CharSequence cs = getCsvData(); 
                                        srs = new StringResourceStream(cs, 
                                                        "text/csv"); 
                                       
srs.setCharset(Charset.forName("UTF-8")); 
                                } else { 
                                        
                                } 
                                return srs; 
                        } 
                        
                }; 
                
                ResourceLink rlink = new ResourceLink("myresource", csvsrc)
{ 
                        @Override 
                        public void onClick() { 
                        
                        } 
                }; 
                this.add(rlink); 

I tried to rewrite the onResourceRequest() method of ResourceLink, but 
1) the code error("blablabla"); does not take effect. 
2) when I remove "resource.onResourceRequested();" from the if branch,
server interal exception will appear on the web page.(JBoss Portal said the
response is empty which it is not implemented for.) Here is my changed code
to onResourceRequested(): 

     /** 
         * @see org.apache.wicket.IResourceListener#onResourceRequested() 
         */ 
        public final void onResourceRequested() 
        { 
        
                Random random = new Random(); 
                if (random.nextBoolean()) { 

                        this.error("blablabla"); 
                        
                } else { 
                        resource.onResourceRequested(); 
                } 
                onClick(); 
        } 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-show-error-msg-from-ResourLink-and-abort-processing-tp2335870p2335870.html
Sent from the Wicket - User 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: How to show error msg from ResourLink and abort processing?

Posted by joinow <jo...@yahoo.com.cn>.
If I remove resource.onResourceRequest(), Jboss said
javax.servlet.ServletException: org.jboss.portal.common.NotYetImplemented:
Feature: handling of empty ContentResponse is not yet implemented
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/How-to-show-error-msg-from-ResourLink-and-abort-processing-tp2335870p2335984.html
Sent from the Wicket - User 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