JXMLPad - Tutorial

Creating a JSP 1.2 editor

STEP 2/5: Overriding the new document action

Previous step | Next Step

 
class NewAction extends XMLAction {
    public NewAction() {
        // Get the same icon than the default New action
        super( ActionModel.NEW_ACTION );
    }
    public boolean notifyAction() {
        String def = "<?xml version=\"1.0\"?>\n\n<jsp:root xmlns:jsp=\"http://java.sun.com/JSP/Page\"        version=\"1.2\">\n\n<html>\n</html>\n</jsp:root>";
        container.setText( def );
        return true;
    }
    public String getName() {
        return ActionModel.NEW_ACTION;
    }
 }

  
Inside the JSPEditor constructor after the previous add-on :

// Replace the default New action by this one
ActionModel.replaceActionByName( ActionModel.NEW_ACTION, new NewAction() );