1 20 package org.enhydra.barracuda.contrib.dbroggisch.examples.view.pages; 21 22 import java.io.IOException ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 import java.util.Locale ; 26 import javax.servlet.ServletException ; 27 import org.w3c.dom.Document ; 28 import org.enhydra.barracuda.core.comp.BAction; 30 import org.enhydra.barracuda.core.comp.BComponent; 31 import org.enhydra.barracuda.core.comp.BTemplate; 32 import org.enhydra.barracuda.core.comp.DefaultTemplateView; 33 import org.enhydra.barracuda.core.comp.TemplateModel; 34 import org.enhydra.barracuda.core.comp.ViewContext; 35 import org.enhydra.barracuda.core.event.EventException; 36 import org.enhydra.barracuda.core.util.dom.DefaultDOMLoader; 37 import org.enhydra.barracuda.contrib.dbroggisch.display.HashMapModel; 38 import org.enhydra.barracuda.contrib.dbroggisch.repopulation.RepopulationFormMap; 39 import org.apache.log4j.Logger; 40 41 import org.enhydra.barracuda.contrib.dbroggisch.examples.controller.events.*; 42 import org.enhydra.barracuda.contrib.dbroggisch.examples.model.forms.*; 43 import org.enhydra.barracuda.contrib.dbroggisch.examples.view.xmlc.*; 44 45 46 public class RepopulationPage extends ExampleBasePage { 47 48 private static final Logger logger = Logger.getLogger(RepopulationPage.class.getName()); 49 50 RepopulationFormMap _rfm; 51 52 public void setRFM(RepopulationFormMap rfm) { 53 _rfm = rfm; 54 } 55 56 public void render(BComponent root, ViewContext vec, Document pDoc) 57 throws EventException, ServletException , IOException { 58 super.render(root, vec, pDoc); 59 RepopulationHTML doc = (RepopulationHTML) pDoc; 60 61 ExampleFormMap cfm = (ExampleFormMap)_rfm; 63 BTemplate loginComp = new BTemplate(); 64 65 loginComp.setView(new DefaultTemplateView(doc.getElementTestHook())); 66 67 loginComp.addModel(cfm); 69 70 List cModels = cfm.getChildModels(); 74 for(Iterator it = cModels.iterator(); it.hasNext();) { 75 loginComp.addModel((TemplateModel)it.next()); 76 } 77 78 HashMapModel hmm = new HashMapModel(); 80 hmm.setName("ControlModel"); 81 hmm.setItem("SUBMIT", new BAction(new Repopulation())); 82 loginComp.addModel(hmm); 83 root.addChild(loginComp); 84 } 85 86 public Document getDocument(Locale iLocale) { 87 89 Document doc = null; 90 try {doc = DefaultDOMLoader.getGlobalInstance().getDOM(RepopulationHTML.class, iLocale);} 92 catch (IOException ioe) {logger.fatal ("Fatal Error loading DOM template:", ioe);} 93 return doc; 94 } 95 96 } 97 | Popular Tags |