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#HXWiki27sVelocit... 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