event java

controller.xml

<handler name="java" type="request" class="org.ofbiz.webapp.event.JavaEventHandler"/>
首先这里的name和screen的处理的name类似。
ofbiz在RequestHandler中
/** Find the event handler and invoke an event. */
    public String runEvent(HttpServletRequest request, HttpServletResponse response,
            ConfigXMLReader.Event event, ConfigXMLReader.RequestMap requestMap, String trigger) throws EventHandlerException {
        EventHandler eventHandler = eventFactory.getEventHandler(event.type);
        String eventReturn = eventHandler.invoke(event, requestMap, request, response);
        if (Debug.verboseOn() || (Debug.infoOn() && "request".equals(trigger))) Debug.logInfo("Ran Event [" + event.type + ":" + event.path + "#" + event.invoke + "] from [" + trigger + "], result is [" + eventReturn + "]", module);
        return eventReturn;
    }

根据EventHandler eventHandler = eventFactory.getEventHandler(event.type);
event.type获取
event.type就是
<event type="javap" path="org.ofbiz.learning.learning.LearningEvents"
invoke="processFirstForm" />这里的type
它一type作为key从eventFactory的getEventHandler获取hander
eventFactory.getEventHandler中的handler是以
事件类型的处理的name作为key,示例作为value存放的map

在其内部可以取得


locale对象可以像下面这样获取:

---------------------------------------------------

Locale locale = UtilHttp.getLocale(request);

---------------------------------------------------

delegator对象可以像下面这样获取:

---------------------------------------------------

GenericDelegator delegator =  (GenericDelegator)request.getAttribute("delegator");

---------------------------------------------------

dispatcher对象可以像下面这样获取:

---------------------------------------------------

LocalDispatcher dispatcher =  (LocalDispatcher)request.getAttribute("dispatcher");

---------------------------------------------------

security对象如下获取:

---------------------------------------------------

Security security = (Security)request.getAttribute("security");

---------------------------------------------------

userLogin对象如下获取:

---------------------------------------------------

GenericValue userLogin =  (GenericValue)request.getSession().getAttribute("userLogin");

你可能感兴趣的:(event)