1 23 24 package org.dbforms.event; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import org.dbforms.config.DbFormsConfig; 30 import org.dbforms.config.EventInfo; 31 import org.dbforms.config.Table; 32 33 import org.dbforms.event.eventtype.EventType; 34 35 import javax.servlet.http.HttpServletRequest ; 36 37 38 39 45 public class NavEventFactoryImpl extends NavEventFactory { 46 47 private static NavEventFactory instance = null; 48 private static Log logCat = LogFactory.getLog(NavEventFactoryImpl.class); 49 50 53 public NavEventFactoryImpl() { 54 } 55 56 61 public static synchronized NavEventFactory instance() { 62 if (instance == null) { 63 instance = new NavEventFactoryImpl(); 64 } 65 66 return instance; 67 } 68 69 70 79 public WebEvent createEvent(String action, 80 HttpServletRequest request, 81 DbFormsConfig config) { 82 Object [] constructorArgs = new Object [] { 83 action, 84 request, 85 config 86 }; 87 String eventId = getEventIdFromDestinationTable(request, action); 88 EventInfo einfo = getEventInfo(eventId); 89 90 logCat.info("::createEvent - got event [" + einfo + "] from action [" 92 + action + "]"); 93 94 return getEvent(einfo, constructorArgsTypes, constructorArgs); 95 } 96 97 98 109 public NavigationEvent createEvent(String action, 110 HttpServletRequest request, 111 DbFormsConfig config, 112 Table table) { 113 Object [] constructorArgs = new Object [] { 114 table, 115 request, 116 config 117 }; 118 String eventId = getEventIdFromDestinationTable(table, action); 119 EventInfo einfo = getEventInfo(eventId); 120 121 logCat.info("::createEvent - got event [" + einfo + "] from action [" 123 + action + "]"); 124 125 return (NavigationEvent) getEvent(einfo, actionConstructorArgsTypes, 126 constructorArgs); 127 } 128 129 130 141 public NavigationEvent createGotoEvent(Table table, 142 HttpServletRequest request, 143 DbFormsConfig config, 144 String positionString) { 145 String eventId = table.getTableEvents() 146 .getEventId(EventType.EVENT_NAVIGATION_GOTO); 147 EventInfo einfo = getEventInfo(eventId); 148 Object [] constructorArgs = new Object [] { 149 table, 150 request, 151 config, 152 positionString 153 }; 154 155 return (NavigationEvent) getEvent(einfo, goToConstructorArgsTypes, 156 constructorArgs); 157 } 158 159 160 172 public NavigationEvent createGotoEvent(Table table, 173 HttpServletRequest request, 174 DbFormsConfig config, 175 String whereClause, 176 String tableList) { 177 String eventId = table.getTableEvents() 178 .getEventId(EventType.EVENT_NAVIGATION_GOTO); 179 EventInfo einfo = getEventInfo(eventId); 180 Object [] constructorArgs = new Object [] { 181 table, 182 request, 183 config, 184 whereClause, 185 tableList 186 }; 187 188 return (NavigationEvent) getEvent(einfo, goToConstructorArgsTypes2, 189 constructorArgs); 190 } 191 192 193 198 protected void initializeEvents() throws Exception { 199 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_NEW, 200 "org.dbforms.event.NavNewEvent")); 201 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_COPY, 202 "org.dbforms.event.NavCopyEvent")); 203 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_GOTO, 204 "org.dbforms.event.datalist.GotoEvent")); 205 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_FIRST, 206 "org.dbforms.event.datalist.NavFirstEvent")); 207 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_LAST, 208 "org.dbforms.event.datalist.NavLastEvent")); 209 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_NEXT, 210 "org.dbforms.event.datalist.NavNextEvent")); 211 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_PREV, 212 "org.dbforms.event.datalist.NavPrevEvent")); 213 214 addEventInfo(new EventInfo(EventType.EVENT_NAVIGATION_RELOAD, 215 "org.dbforms.event.datalist.ReloadEvent")); 216 } 217 } 218 | Popular Tags |