[xwiki-users] Java api/method th get the text content of xwiki page?
Hi All, i created a space i.e MySpace1. On WebHome, i put the some content i.e "This is my latest content". Now in my java class, i want to get the content of MySpace1.WebHome page . Here is the code snippet i tried to get the content of page but i get the document1 as null though the page exists. com.xpn.xwiki.api.XWiki xwikiApi= new com.xpn.xwiki.api.XWiki(context.getWiki(),context); Document document1=null; try { document1 = xwikiApi.getDocument("MySpace1.WebHome");// getting document1 as null } catch (XWikiException e) { log.info("did not find OrgDataCreation.WebHome page"); } String contentStr=""; if(document1!=null) { contentStr=document1.getContent(); } I am not sure what i am missing here?
Hi, Why are you trying to use the scripting (wrapping) API when you are in Java and not use directly the core API? DocumentReference docRef = new DocumentReference("xwiki", "MySpace1", "WebHome"); XWiki xwiki = context.getWiki(); XWikiDocument document = xwiki.getDocument(docRef, context); String documentContent = document.getContent(); Thanks, Eduard On Mon, May 14, 2012 at 12:52 PM, mohit gupta <[email protected]> wrote:
Hi All,
i created a space i.e MySpace1. On WebHome, i put the some content i.e "This is my latest content". Now in my java class, i want to get the content of MySpace1.WebHome page . Here is the code snippet i tried to get the content of page but i get the document1 as null though the page exists.
com.xpn.xwiki.api.XWiki xwikiApi= new com.xpn.xwiki.api.XWiki(context.getWiki(),context); Document document1=null; try { document1 = xwikiApi.getDocument("MySpace1.WebHome");// getting document1 as null } catch (XWikiException e) { log.info("did not find OrgDataCreation.WebHome page");
} String contentStr=""; if(document1!=null) { contentStr=document1.getContent();
}
I am not sure what i am missing here? _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
participants (2)
-
Eduard Moraru -
mohit gupta