Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nono Carballo
Using a slider in a vaadin form
June 28, 2013 1:07 PM
Answer

Nono Carballo

Rank: New Member

Posts: 16

Join Date: June 25, 2012

Recent Posts

Hi!

I want to use a slider in a form on a vaadin portlet. I'm using a custom form field factory to create the form fields. The console doesn't show any errors, but I get an Internal Error message in the browser.

I'm using vaadin 6.8.11

Any Idea?

Nono
David H Nebinger
RE: Using a slider in a vaadin form
June 30, 2013 5:48 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6439

Join Date: September 1, 2006

Recent Posts

Yeah, Vaadin is funny like that. Errors that are generated in the code will normally only appear in the browser and don't get dumped to the log...

You can get around this in your Application class by setting a custom error handler. Usually I do this in the init() method, something like:

1setErrorHandler(new LoggingErrorHandler(this));


Then you just create your logging error handler:

 1public class LoggingErrorHandler implements ErrorListener {
 2  private static final Log logger = LogFactoryUtil.getLog(LoggingErrorHandler.class);
 3  private final Application app;
 4
 5  public LoggingErrorHandler(final Application app) {
 6    this.app = app;
 7  }
 8
 9  public void terminalError(final com.vaadin.terminal.Terminal.ErrorEvent event) {
10    logger.error("Error encountered: " + event.getClass.getName());
11    if (event.getThrowable() != null) {
12      logger.error(event.getThrowable());
13    }
14
15    app.terminalError(event);
16  }
17}


Anyway, depending upon where you define your class (i.e. an external class, or an inner class of your Application class) will change your implementation, but the end result is that you'll dump all errors to the log file so you have them for analysis.

Typically you'll find that your code is generating an exception that is being caught by Vaadin and is being returned to the browser for display, but having the log entry will make it very easy to track down and eliminate.
Nono Carballo
RE: Using a slider in a vaadin form
July 1, 2013 1:13 PM
Answer

Nono Carballo

Rank: New Member

Posts: 16

Join Date: June 25, 2012

Recent Posts

Thanks David, with your solution I realized the slider only accept double values and the field it was bound to was of type Integer.
David H Nebinger
RE: Using a slider in a vaadin form
July 2, 2013 7:31 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6439

Join Date: September 1, 2006

Recent Posts

Yep, dumping the Vaadin exceptions to the log will really help you diagnose issues w/ your Vaadin code.

Typically I take it a step farther - the default thing is to show the stack trace in a big error window in the browser, but that certainly is not user friendly. You can trace through the Application code to identify where it is sending the stack trace to the browser and tweak it to just send an informative failure message, then leave the stack trace in the log for analysis and resolution...
Nono Carballo
RE: Using a slider in a vaadin form
July 2, 2013 10:12 AM
Answer

Nono Carballo

Rank: New Member

Posts: 16

Join Date: June 25, 2012

Recent Posts

Thanks David, now I have finished my demo, a little CRUD application as a proof of concept to show to my coworkers.
David H Nebinger
RE: Using a slider in a vaadin form
July 3, 2013 5:47 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 6439

Join Date: September 1, 2006

Recent Posts

Great! Vaadin is pretty darn cool, as long as you're not looking for eye candy. Generating new portlets in Vaadin is generally pretty quick...