On Sat, Jan 16, 2010 at 06:56, Caleb James DeLisle
<calebdeli...@lavabit.com> wrote:
> I am not sure how a view counter would work (using ObservationManager)
> but can show you a piece of code which updates the search index every time a
> document is changed.
> http://svn.xwiki.org/svnroot/xwiki/platform/xwiki-plugins/trunk/lucene/src/main/java/com/xpn/xwiki/plugin/lucene/IndexUpdater.java
> Search for the method that starts with:
> public void onEvent(Event event, Object source, Object data)
>
> You can see whenever a document is changed or saved, this method is called by 
> the
> ObservationManager and the index is updated.
>
> To get your EventListener to work you have to implement EventListener and you
> have to register your EventListener with ObservationManager.

Note that you don't need to do that explicitly, your java componenet
implementing EventListener will be automatically registered (if it's a
component). The groovy page has to do it "by hand" because we don't
have such mechanism for wiki pages.

>
> The irc bot which is written entirely in Groovy but it contains a class which
> implements EventListener (IRCEventListener) and it has a section which 
> registers
> IRCEventListener with ObservationManager using this:
>    def listener = new IRCEventListener(bot, xwiki, xcontext)
>    observation.addListener(listener)
>
> Best of luck,
>
> Caleb James DeLisle
>
>
> J. Allen Santos wrote:
>> Hi
>> Sorry, I'm having a hard time understanding how to do it. May I request for 
>> a sample program/code for the remote observation module? Say for example, 
>> whenever a user views, a view counter increments.
>> ThanksAllen
>>
>>> From: vinc...@massol.net
>>> Date: Mon, 11 Jan 2010 11:54:56 +0100
>>> To: users@xwiki.org
>>> Subject: Re: [xwiki-users] Observer
>>>
>>> Hi,
>>>
>>> On Jan 11, 2010, at 11:48 AM, J. Allen Santos wrote:
>>>
>>>> What we want to do is to create an application that we could use to 
>>>> connect to an XWiki Server to do certain actions whenever a user 
>>>> creates/modifies/updates a document in the Wiki. Is it possible to create 
>>>> such an application that wouldn't require us to include code snippets in 
>>>> the wiki pages/documents as stated in 
>>>> http://dev.xwiki.org/xwiki/bin/view/Drafts/GroovyNotifications, or even 
>>>> modify a module used by XWiki? We want it to be portable so that it can be 
>>>> used by any other XWiki Servers with very minimal, or better yet, no 
>>>> configurations.
>>> So I assume you're coding from Java. Yes it's possible. Everything in XWiki 
>>> is coded in Java. The tutorial shows how to write java code in a groovy 
>>> page but you don't have to use groovy for that! :)
>>>
>>> Here's the doc:
>>> http://code.xwiki.org/xwiki/bin/view/Modules/ObservationModule
>>>
>>> However I see that Thomas has "forgotten" to write a quick example on
>>> http://code.xwiki.org/xwiki/bin/view/Modules/LocalObservationModule
>>>
>>> As you can see you have 2 options:
>>> - in-JVM
>>> - as distributed events
>>>
>>> You can also look at the source code:
>>> http://svn.xwiki.org/svnroot/xwiki/platform/core/trunk/xwiki-observation/
>>>
>>> Hope it helps,
>>> -Vincent
>>>
>>>>> From: vinc...@massol.net
>>>>> Date: Mon, 11 Jan 2010 09:05:13 +0100
>>>>> To: users@xwiki.org
>>>>> Subject: Re: [xwiki-users] Observer
>>>>>
>>>>>
>>>>> On Jan 11, 2010, at 5:01 AM, J. Allen Santos wrote:
>>>>>
>>>>>> How do I create an observer without adding a groovy code within a page?I 
>>>>>> saw this document: 
>>>>>> http://dev.xwiki.org/xwiki/bin/view/Drafts/GroovyNotifications but it 
>>>>>> requires code to be added within a page.
>>>>> You mean how to do it from java?
>>>>>
>>>>> What do you want to achieve?
>>>>>
>>>>> Thanks
>>>>> -Vincent
>>> _______________________________________________
>>> users mailing list
>>> users@xwiki.org
>>> http://lists.xwiki.org/mailman/listinfo/users
>>
>> _________________________________________________________________
>> Windows 7: Simplify what you do everyday. Find the right PC for you.
>> http://windows.microsoft.com/shop
>> _______________________________________________
>> users mailing list
>> users@xwiki.org
>> http://lists.xwiki.org/mailman/listinfo/users
>>
>
> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users
>



-- 
Thomas Mortagne
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to