1 20 package org.enhydra.barracuda.contrib.dbroggisch.examples.controller.handlers; 21 22 import java.io.IOException ; 23 import java.util.Iterator ; 24 import java.util.Map ; 25 import javax.servlet.ServletException ; 26 import javax.servlet.http.HttpServletRequest ; 27 import org.enhydra.barracuda.core.event.ControlEventContext; 28 import org.enhydra.barracuda.core.event.EventException; 29 import org.enhydra.barracuda.core.forms.FormElement; 30 import org.enhydra.barracuda.core.forms.ValidationException; 31 import org.enhydra.barracuda.contrib.dbroggisch.page.Page; 32 import org.enhydra.barracuda.contrib.dbroggisch.page.PageEventListener; 33 import org.apache.log4j.Logger; 34 35 import org.enhydra.barracuda.contrib.dbroggisch.examples.model.forms.*; 36 import org.enhydra.barracuda.contrib.dbroggisch.examples.view.pages.*; 37 38 39 public class RepopulationHandler extends PageEventListener { 40 41 private static final Logger logger = Logger.getLogger(RepopulationHandler.class.getName()); 42 43 public void handleControlEvent(ControlEventContext context, Page p) 44 throws EventException, ServletException , IOException { 45 HttpServletRequest request = context.getRequest(); 46 ExampleFormMap cfm = new ExampleFormMap(); 47 RepopulationPage rPage = (RepopulationPage)p; 48 rPage.setState(ExampleBasePage.REPOPULATION); 49 50 rPage.setRFM(cfm); 54 55 if (ExampleFormMap.MODEL_NAME.equals(request.getParameter("visited"))) { 60 try { 61 cfm.map(request).validate(true); 63 64 if (logger.isDebugEnabled()) { 66 Map els = cfm.getElements(); 67 68 for (Iterator it = els.entrySet().iterator(); it.hasNext();) { 69 Map.Entry entry = (Map.Entry )it.next(); 70 String name = (String )entry.getKey(); 71 FormElement fel = (FormElement)entry.getValue(); 72 logger.debug("Element " + name + ":"); 73 Object val = fel.getVal(); 74 75 if (val != null) { 76 logger.debug("Value class: " + val.getClass().getName()); 77 logger.debug("Value: " + val); 78 } else { 79 logger.debug("Has a null-value"); 80 } 81 } 82 } 83 } catch (ValidationException ex) { 84 logger.error("Form Validation Exception", ex); 85 } 86 } 87 context.getEvent().setHandled(true); 88 } 90 91 } 92 | Popular Tags |