Журнал LinuxFormat - перейти на главную

LXF94:Команды и фабрики

Материал из Linuxformat
(Различия между версиями)
Перейти к: навигация, поиск
(Новая: == Команды и фабрики == ''ЧАСТЬ 6 '''Антон Черноусов''' готов познакомить вас с очередной партией паттернов...)
 
(Команды)
Строка 8: Строка 8:
  
 
<source lang="java">
 
<source lang="java">
protected void initCommand(ServletContext sc, HttpServletRequest
+
protected void initCommand(ServletContext sc, HttpServletRequestaRequest,
aRequest,
+
 
HttpServletResponse aResponse, String viewPath,
 
HttpServletResponse aResponse, String viewPath,
 
String resultPath, String errorPath) {
 
String resultPath, String errorPath) {

Версия 19:27, 16 марта 2008

Команды и фабрики

ЧАСТЬ 6 Антон Черноусов готов познакомить вас с очередной партией паттернов, которые помогут сделать ваши приложения еще более гибкими и расширяемыми.

Вместо предисловия

Команды

protected void initCommand(ServletContext sc, HttpServletRequestaRequest,
HttpServletResponse aResponse, String viewPath,
String resultPath, String errorPath) {
this.setSc(sc);
this.setARequest(aRequest);
this.setAResponse(aResponse);
this.setResultPath(resultPath);
this.setErrorPath(errorPath);
this.setViewPath(viewPath);
}
public void makeDataToView() {
Map<String, String> numbers = new HashMap<String, String>();
Map<String, String> comments = new HashMap<String, String>();
for (Map.Entry<String, Contact> entry :
_addressBook.getContacts().entrySet()) {
numbers.put(entry.getKey(), entry.getValue().getNumber());
comments.put(entry.getKey(), entry.getValue().getComment());
}
aRequest.setAttribute(“numbers”, numbers);
aRequest.setAttribute(“comments”, comments);
if (aRequest.getAttribute(“message”) == null) {
aRequest.setAttribute(“message”, “”);
}
}
Персональные инструменты
купить
подписаться
Яндекс.Метрика