Is there a way to make the struts2 convention plugin use results from a super class?
I'm trying to create a general CRUD, and use general results if there is no implementation in the child class. Is this possible?
Yes, you can.
For an example :
General CRUD
@Results({
@Result(name = "input", location = "input.jsp"),
@Result(location = "input.jsp")
})
public abstract class CrudActionSupport extends ActionSupport {
@Action("update/{entityId}") // wildcard mapping
public String actionUpdate() {
return SUCCESS;
}
}
Action
public class PersonAction extends CrudActionSupport {
}
The annotation at CrudActionSupport will always in effect, except it is overridden in subclass.
e.g.
@Results({
@Result(name = "input", location = "person.jsp"),
@Result(location = "person.jsp")
})
public class PersonAction extends CrudActionSupport {
@Override
public String actionUpdate() {
return SUCCESS;
}
// or
/*
@Action("update/{id}")
@Override
public String actionUpdate() {
return SUCCESS;
}
*/
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With