Principais mudanças nessa versão:
:arrow: IoC e DI foram reimplementados para serem totalmente automáticos e transparentes. Basicamente agora vc seta os filtros globais IoCFilter e DIFilter e o auto-wiring acontece por mágica.
Mais info sobre isso aqui:
http://www.mentaframework.org/depinj.jsp
http://www.mentaframework.org/ioc.jsp
:arrow: ClassActionConfig para que vc não precise criar uma URL para sua action, a URL assume o nome da action sem o pacote.
Ex:
action("/HelloAction", HelloAction.class);
tem o mesmo efeito de
action(HelloAction.class);
:arrow: Integração com o Spring através do SpringActionConfig e/ou SpringFilter.
:arrow: Algumas tags dinâmicas (javascript based) como inputDate, inputMoney, inputMask, etc.
Para a lista completa de alterações acesse o link: http://www.mentaframework.org/changes/changes_1.3.txt
Notem tb que a configuração está sendo reduzida cada vez mais através de melhorias na classe ApplicationManager.java:
Configuração do MyBooks:
package org.mybooks;
// imports here...
public class ApplicationManager extends org.mentawai.core.ApplicationManager {
private ConnectionHandler connHandler;
public void init(Context application) {
// turn-on debug mode (this can also be done in the web.xml file)
// remember to include the servlet filter definition in the web.xml file !
setDebugMode(true);
// IoC components (DAOs)
ioc("userDAO", MySQLUserDAO.class);
ioc("bookDAO", MySQLBookDAO.class);
ioc("userBooksDAO", MySQLUserBooksDAO.class);
ioc("transaction", JdbcTransaction.class);
// ConnectionPool (ConnectionHandler)
this.connHandler = new C3P0ConnectionHandler("com.mysql.jdbc.Driver",
"jdbc:mysql://localhost/mentafra_mybooks?autoReconnect=true",
"mentafra_mybooks",
"mybooks");
C3P0ConnectionHandler c3p0 = (C3P0ConnectionHandler) connHandler;
ComboPooledDataSource pool = (ComboPooledDataSource) c3p0.getComboPooledDataSource();
pool.setMaxIdleTime(5); // 5 min before it is closed... (avoid Communication Link Failure!)
}
public void loadLists() throws IOException {
// Of course this can also be internationalized in an i18n file...
SimpleListData languages = new SimpleListData("languages");
languages.add(1, "Português");
languages.add(2, "Inglês");
languages.add(3, "Francês");
languages.add(4, "Espanhol");
languages.add(99, "Outras");
ListManager.addList(languages);
SimpleListData editions = new SimpleListData("editions");
editions.add(1, "Primeira");
editions.add(2, "Segunda");
editions.add(3, "Terceira");
editions.add(4, "Quarta");
editions.add(5, "Quinta");
editions.add(6, "Sexta");
editions.add(7, "Sétima");
editions.add(8, "Oitava");
editions.add(9, "Nona");
ListManager.addList(editions);
}
public void loadActions() {
//
// GLOBAL FILTERS
//
// Authentication for all actions (except for the ones that implement AuthenticationFree)
filter(new AuthenticationFilter());
on(LOGIN, redir("/login.jsp")); // global consequence
// Validation for all actions that implement Validatable
filter(new ValidatorFilter());
// IoC (Autowiring)
filter(new IoCFilter());
// Connection Pooling
filter(new ConnectionFilter("connection", connHandler));
// DI (anything that needs a connection will receive a connection !!!!)
filter(new DIFilter("connection", java.sql.Connection.class));
// Injection for actions (or models if action implements ModelDriven)
filterLast(new InjectionFilter());
// LoginAction
action(LoginAction.class)
.on(SUCCESS, redir("/welcome.jsp"))
.on(ERROR, fwd("/login.jsp"));
// RegistrationAction
action(RegistrationAction.class)
.on(SUCCESS, redir("/welcome.jsp"))
.on(ERROR, fwd("/register/registration.jsp"))
// An User object will be created and populated with the values of the action input
.filter(new VOFilter("user", User.class));
// BookManagerAction.searchToAdd
action(BookManagerAction.class, "searchToAdd")
.on(SUCCESS, fwd("/bookmanager/showbooks.jsp"))
.on(BookManagerAction.NOBOOKS, fwd("/bookmanager/createbook.jsp"))
.on(ERROR, fwd("/welcome.jsp"));
// BookManagerAction.search
action(BookManagerAction.class, "search")
.on(SUCCESS, fwd("/bookmanager/search.jsp"))
.on(ERROR, fwd("/welcome.jsp"));
// BookManagerAction.addToUser
action(BookManagerAction.class, "addToUser")
.on(SUCCESS, fwd("/welcome.jsp"))
.on(BookManagerAction.ERROR, fwd("/bookmanager/showbooks.jsp"))
.on(BookManagerAction.ERROR2, fwd("/welcome.jsp"));
// BookManagerAction.create
action(BookManagerAction.class, "create")
.on(SUCCESS, fwd("/bookmanager/createbook.jsp"))
.on(ERROR, redir("/welcome.jsp"));
// BookManagerAction.createAndAddToUser
action(BookManagerAction.class, "createAndAddToUser")
.on(SUCCESS, fwd("/welcome.jsp"))
.on(BookManagerAction.ERROR, fwd("/bookmanager/createbook.jsp"))
.on(BookManagerAction.ERROR2, fwd("/welcome.jsp"))
// Book object will be created and populated with the values in the action input
.filter(new VOFilter("book", Book.class))
// This action will be made atomic by this filter
.filter(new TransactionFilter("transaction"));
// BookManagerAction.show
action(BookManagerAction.class, "show")
.on(SUCCESS, fwd("/bookmanager/show.jsp"))
.on(ERROR, redir("/"));
// BookManagerAction.remove
action(BookManagerAction.class, "remove")
.on(ERROR, redir("/welcome.jsp"))
.on(SUCCESS, fwd("/welcome.jsp"));
// UserManagerAction.search
action(UserManagerAction.class, "search")
.on(SUCCESS, fwd("/usermanager/search.jsp"));
// UserManagerAction.show
action(UserManagerAction.class, "show")
.on(SUCCESS, fwd("/usermanager/show.jsp"))
.on(ERROR, redir("/"));
// LogoutAction
action(LogoutAction.class);
on(SUCCESS, redir("/"));
}
}