Hi Denis,

  plugin worked fine with me as I worked with the example and I guess
  I do now understand the the basic of developing plugins. Thanks.

  Actually I am using a data service's RPC call to invoke functions and
  get the data. I have already set up the DS with xwiki and can call POJO
  functions through the DS.The requirement for the server side remote object
  is as stated here:

  "You can use any plain old Java object (POJO) that is available in the web
   application classpath as the source of the Remoting Service destination.
   The class must have a zero-argument constructor so that DataService can
   construct an instance."

   I tried to make HelloWorldPluginApi of the example my remote object but
   got a long error sice remote obj can only have zero argument!!!

   Now my question is if I have a very simple POJO like this:

   package com.xpn.xwiki.plugin.helloworld;
   //import com.xpn.xwiki.plugin.helloworld.HelloWorldPluginApi;
   public class SampleService
   {    
        public String sayHelloTo(String name)
        {
            return "Hello " + name;
        }       
   }

   how can I call the example's HelloWorldPluginApi's hello()
function from this POJO's
   sayHelloTo("") function?

   Thanks.........




On Sun, Nov 8, 2009 at 9:13 AM, Vivian Richard <[email protected]> wrote:
>   Thanks Denis,
>
>   for taking time to write this well explained, long email - really
> appreciate it.
>   From all your given options I found plugin is the easiest(since I understand
>   the code very clearly) for me which is  explained here -
>
>           http://platform.xwiki.org/xwiki/bin/view/DevGuide/CreatingPlugins
>
>   Let me work on it and I will let you know if I have any further questions.
>
>   Regards,
>
>   Viv
>
>
> On Sun, Nov 8, 2009 at 3:17 AM, Denis Gervalle <[email protected]> wrote:
>> Hi Vivian,
>>
>> Are you sure that you want to interact with XWiki  the old way  (using
>> plug-ins) ?
>> Have you read 
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents
>>  or probably better for your needs 
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingMacros
>>  ?
>>
>> The context is an XWikiContext object that was the old way of keeping
>> track of the current request, and it had to be passed around from
>> method to method, everywhere in the code. It is progressively being
>> replaced by an execution context managed by an execution manager
>> component.
>>
>> In velocity, if you have programming rights, you may reach the
>> XWikiContext using the velocity context this way:
>>
>> #set( $xcontext = $context.context )
>>
>> In a plugins, if you read carefully the 
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/CreatingPlugins
>>  , you will notice that you have to extends XWikiDefaultPlugin and
>> implements an init method to receive the context that you will
>> passover to the constructor of your plugin API. This way, you will
>> have access to the context in your plugin API as needed through the
>> protected variable context that is initialized at construction time.
>> The plugin API should be instantiated newly for each call to the
>> getPluginApi method of your plugin. This way, the API represent the
>> contextual instance of your plugin during a given request while the
>> plugin itself is a singleton.
>>
>> Regards,
>>
>> Denis Gervalle
>>
>> On Nov 8, 2009, at 9:10, Vivian Richard wrote:
>>
>>>   Thank you very much Arun for your help. Actually I have already
>>>   used velocity and was able to do whatever I needed through velocity.
>>>
>>>   But my requirements changed and now I need to do exactly the
>>>   same thing is pure java. If you can help me in that will really be
>>>   appreciated.
>>>
>>>   at the bottom of the following link
>>>             
>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/CreatingPlugins
>>>
>>>    this line of code
>>> com.xpn.xwiki.doc.XWikiDocument doc =
>>> context.getWiki().getDocument("theSpace.theDoc", context); // any
>>> document
>>>
>>>    where this contest is coming from?
>>>
>>>    If I have a class how do I get the context?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Sat, Nov 7, 2009 at 7:47 PM, Arun Reddy <[email protected]>
>>> wrote:
>>>> Hi Richard,
>>>>
>>>> On Sun, Nov 8, 2009 at 6:14 AM, Vivian Richard <[email protected]>
>>>> wrote:
>>>>
>>>>> Hello devs,
>>>>>
>>>>> got a really newbie question and sitting on it for hours.
>>>>> Your help will be appreciated. All I am trying to do is
>>>>> - writing a Java class which has a method - when called
>>>>> with doc name/ID will return the document title. That is all.
>>>>>
>>>>
>>>> If you are looking for a method which returns document title of a
>>>> particular
>>>> doc name/ID , You can use velocity to achive that easily on the fly
>>>> by
>>>> putting the code inside your wiki pages itself.
>>>>
>>>> You can have a look at these :
>>>> velocity scripting guide :
>>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Scripting#HXWiki27sVelocityAPI
>>>> XWiki API                   :
>>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/API
>>>>
>>>>
>>>> $doc.getTitle()  -> to get title of current doc.
>>>> $xwiki.getDocument(java.lang.String web,java.lang.String
>>>> fullname).getTitle()
>>>>
>>>> And many more methods, kindly check the API (link given above).
>>>>
>>>> The following code is what Itried:
>>>>>
>>>>> import com.xpn.xwiki.XWikiContext;
>>>>> import com.xpn.xwiki.api.Api;
>>>>> import com.xpn.xwiki.api.XWiki;
>>>>> import com.xpn.xwiki.doc.XWikiDocument;
>>>>>
>>>>>
>>>>> public class SampleService extends Api
>>>>> {
>>>>>        public SampleService()
>>>>>        {
>>>>>                super();   ///   I guess there should be XwikiContext
>>>>> parameter in
>>>>> the constructor
>>>>>        }
>>>>>        public String myDocTitle(String:name)
>>>>>        {
>>>>>                com.xpn.xwiki.doc.XWikiDocument docu =
>>>>> context.getWiki().getDocument("theSpace.theDoc", context);  //   I
>>>>> do
>>>>> not where to get this context from
>>>>>                return docu.getTitle();
>>>>>        }
>>>>> }
>>>>> _______________________________________________
>>>>> devs mailing list
>>>>> [email protected]
>>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>> Arun Reddy
>>>> _______________________________________________
>>>> devs mailing list
>>>> [email protected]
>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>
>>> _______________________________________________
>>> devs mailing list
>>> [email protected]
>>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>> _______________________________________________
>> devs mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
>
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to