New in java ... Trying to get a sample application to run. I am including a section of code that seems to be relevant to the problem. I can publish the entire test application if necessary. I
I am trying to implement an error handler to handle css alerts that are generated when an application parses target sites using the htmlunit lib / test that runs in the application.
I'm not sure exactly how the MycssErrorHandler class should be implemented to call ErrorHandler. I'm also not quite sure how to instantiate the object in the main body of the code / test class.
Thoughts / comments / code snippets would be helpful.
Thank!
When compiling, I get the following error:
[root@toshiba parseapp2]
warning: [path] bad path element "/opt/htmlunit/lib/xml-apis.jar": no such file or directory
warning: [path] bad path element "/opt/htmlunit/lib/xercesImpl.jar": no such file or directory
warning: [path] bad path element "/opt/htmlunit/lib/serializer.jar": no such file or directory
sjsu_classes.java:92: sjsu_classes.MycssErrorHandler is abstract; cannot be instantiated
ErrorHandler ierr = new MycssErrorHandler();
^
1 error
3 warnings
====================================
Test code block:
import org.w3c.css.sac.ErrorHandler;
import com.gargoylesoftware.htmlunit.DefaultCssErrorHandler;
import org.xml.sax.SAXParseException;
public class sjsu_classes {
public static class MyIncorrectnessListener implements IncorrectnessListener
{
@Override
public void notify(String arg0, Object arg1)
{
}
}
public abstract class MycssErrorHandler implements ErrorHandler
// protected class MycssErrorHandler implements ErrorHandler
{
public void notify(String arg0, Object arg1)
{
}
public void fatalError(SAXParseException ex)
{
}
}
public void main(String[] args) throws Exception {
WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3);
IncorrectnessListener ilisten = new MyIncorrectnessListener();
ErrorHandler ierr = new MycssErrorHandler();
webClient.setIncorrectnessListener(ilisten);
webClient.setCssErrorHandler(ierr);