2.1.2 Writing handlers
The JET Actions have to be extended by jet.servlet.JetAction or a child of it.
Given Parameters:
JetMessages messages - contains messages, specially from validations.
JetData data - contains hashmaps of the request and session data. Contains also the messages provided by the localizer files.
JetForm form - the form for the action to encode parameters - null if no form is specified in configuration.
JetContext jetContext - Context object providing all necessary objects like the HttpRequest object etc.
Example Action:
public class HelloWorldAction extends JetAction{
public void execute( JetMessages messages, JetData data, JetForm form, JetContext jetContext )
throws JetActionException, IOException{
if(form != null){ //test2.jet called
data.add( "newform", form.decodeForm(jetContext) );
}else{ //test.jet called
data.add( "newform", jetContext.getFormByUrl("/test2.jet").decodeForm(jetContext) );
}
render( data, "jet.ftl.pages.helloworld" );
}
}
2.2.2 Writing handlers
On the new behave the JET Actions have NOT to be extended by jet.servlet.JetAction or a child of it. Just define a method and specify one of the below listed parameter types as you wish/need.:
Given Parameters:
JetMessages messages - contains messages, specially from validations.
JetData data - contains hashmaps of the request and session data. Contains also the messages provided by the localizer files.
JetForm form - the form for the action to encode parameters - null if no form is specified in configuration.
JetConverer converter - holds an instance of the form - you can directly get converted field values.
JetContext jetContext - Context object providing all necessary objects like the HttpRequest object etc.
HttpServletRequest request - the servlet request object like on servlets exists
HttpServletResponse reponse - the servlet response object like on servlets exists
Example Action:
public class NewBehaveAction {
public void myexecute( JetData data, JetForm form, JetContext jetContext )
throws JetActionException, IOException{
if(form != null){ //test2.jet called
data.add( "newform", form.decodeForm(jetContext) );
}else{ //test.jet called
data.add( "newform", jetContext.getFormByUrl("/test2.jet").decodeForm(jetContext) );
}
context.render( data, "jet.ftl.pages.helloworld" );
}
}
NOTE: The new behave supports no special 'validate' method. Form validation is the same.