Thanks very much for your post. Two more questions:

1. We want to update the webpage a user sees triggered by external events
which arrive at a "servicemanagerimpl" manager. This means, rather than
having the user poll for new data by refreshing his page in the browser, we
would like to have the page automatically refresh and display new data upon
arrival of the external event in Appfuse. (the event means that new data is
in the database which will be displayed upon refresh). therefore we now
first tried to use your internal eventing advice to propagate the event from
the manager who receives the external event to the site's controller. Do you
know how to now make this event in the controller update the user's page?
Maybe with JSF? I heard that maybe the site would update automatically, soon
as the event arrives in the controller of the jsp site. is that correct?

2. About the internal eventing itself:
I did the following: 

1. create a new event called myevent extending Application event

/* MyServiceEvent.java
package org.cdtm.collasoa.service.impl;

import org.springframework.context.ApplicationEvent;

public class MyServiceEvent extends ApplicationEvent{
        /**
         * Comment for <code>serialVersionUID</code>
         */
        private static final long serialVersionUID = 1L;

        public MyServiceEvent(Object source) {
                super(source);
                }
}

2. publish it in the manager (in the managers onEvent function, which fires
on arrival of the external event)

public void onEvent(Event ev) {

//              propagate event internally for virtualofficeController
                MyServiceEvent event = new MyServiceEvent(this);
                ctx.publishEvent(event);
                          ......

3. subscribe in the site's controller

public void onApplicationEvent(ApplicationEvent event) {
            if (event instanceof MyServiceEvent) {
                        if (log.isDebugEnabled()) {
                        log.debug("MDA Presence Event propagated");
                        }
                        System.err.println("MDA Presence Event propagated");
                }
            }
                 ....

All the imports and implements have been made and the code can compile fine.
however nothing appears in the log although events are arriving in the
manager triggering the event.publish() method in the manager's onEvent
function.

Do you know what might be wrong? Is it necessary to add something to the
controllers bean declaration? right now it looks as follows:

<bean id="virtualofficeController"
class="org.cdtm.collasoa.webapp.controller.VirtualofficeController">
        <property name="userManager" ref="userManager"/>
                <property name="serviceManager" ref="serviceManager"/>
    </bean>

Thank you very much!


Sanjiv Jivan wrote:
> 
> I've used Spring event mechanism successfully in propagating events from
> the
> service layer to the web layer. Basically have your Controller implement
> ApplicationListener
> and in your implmentation of  ApplicationListener#onApplicationEvent carry
> out the logic pertaining to the event you're going to raise in your
> service
> layer
> 
> public void onApplicationEvent(ApplicationEvent event) {
>         if (event instanceof MyServiceEvent) {
>             ...
>         }
> }
> 
> ------------------------------------------------------------------------------------
> 
> In your service layer, you create and raise the event as follows :
> 
> MyServiceEvent event = new MyServiceEvent(<event related data>);
> 
> ctx.publishEvent(event);
> 
> Here ctx is an instance of your app's application context file which you
> can
> get in your service layer by having the service implement
> ApplicationContextAware and the Spring container will automatically inject
> the application contenxt.
> 
> http://www.springframework.org/docs/reference/beans.html#context-functionality-events
> 
> 
> Hope this helps.
> 
> Sanjiv
> 
> On 7/2/07, mda <[EMAIL PROTECTED]> wrote:
>>
>>
>> Hello,
>>
>> we would like to implement for the course an application with a web
>> interface which gets updated after certain events are received in service
>> layer. We are developing our application based on Appfuse2.0 w. Spring
>> MVC,
>> and we would actually like to have a list of users and their status
>> information listed on a web page.
>>
>> The contents of the web page should be udpated after a manager on the
>> service layer gets updates about the users' status. How can that event be
>> propagated to the web layer? What is the best practice for implementing
>> the
>> observer pattern with appfuse 2.0?
>>
>> Thanks for a quick answer in advance!
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-implement-an-observer-in-the-web-layer-tf4013763s2369.html#a11398407
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-implement-an-observer-in-the-web-layer-tf4013763s2369.html#a11511859
Sent from the AppFuse - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to