JXMLPad - Tutorial

Creating a JSP 1.1 editor

STEP 2: Overriding the new document action

Version 1.0
http://www.japisoft.com



        // Class for the new document action
    class NewAction extends XMLAction {
        public NewAction() {
            // Get the same icon than the default New action
            super( ActionModel.NEW_ACTION );
        }
   
        // Action resetting the current editor content
        public boolean notifyAction() {
            editor.setText( "<%@page language=\"java\"%>\n" +
                "<html>\n" +
                "<body>\n" +
                "</body>\n" +
                "</html>" );
            return true;
        }

        // Needed for replacing the default new action
        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() );

Previous step | Next Step