Hi, A1. If you do not have programming rights, one way to update XWiki object properties is doing a custom HTTP post. The easiest place to figure out the details is the HTML source of the object editor. There, you can see the required post form parameters. I wrote a little bit about it here: http://soal.xwiki.com/xwiki/bin/view/Code/DojoInXWiki#HUpdatingXWikiobjectsv... If you don't want the user to feel like they are submitting a form you can use redirects or asynchronous requests. If you do have programming rights, you can do something like this: <% myXWikiDocument=xwiki.getDocument("MyWeb.MyDoc").getDocument() // note 1 myXWikiDocument.setLargeStringValue("XWiki.MyClass", "message", "new value 12345") // note 2 xwiki.getXWiki().saveDocument(myXWikiDocument, context.getContext()) // note 3 %> note 1: If you're wondering why there are two getDocument calls, the first one returns a Document object, which is part of the unprotected API and does not give access to the object layer (http://build.xpertnet.biz/doc/api/com/xpn/xwiki/api/Document.html); the second returns an instance of XWikiDocument, which lets you do pretty much anything if you have programming rights (http://build.xpertnet.biz/doc/api/com/xpn/xwiki/doc/XWikiDocument.html). note 2: We're using setLargeStringValue, but if you look at the XWikiDocument API linked above you'll see there are various alternatives to set properties for different types. note 3: a. Again we call xwiki.getWiki() and context.getContext() to go below the unprotected API objects and get under the covers into the meaty stuff. b. You __MUST__ explicitly save the XWikiDocument after changing its objects, else the changes will be lost when the cache is flushed or tomcat is restarted (at least in v0.9.840). A2. Not sure about all the details... maybe look at the Java code? :) By the way, are you seeking to programmatically add instances of a class to documents? If so you do not need to interact directly with the database (in fact you probably should not). Similarly to A1, if you don't have programming rights, you can view the source of the HTML forms you normally use to create objects via web pages, and then write scripts that do equivalent HTTP posts. If you do have programming rights you can do something like (untested code): <% myTemplateObject=xwiki.getDocument("MyWeb.MyTemplateDoc").getObject("XWiki.MyClass").getXWikiObject() myNewObject=myTemplateObject.clone() //modify myTemplateObject to suit your needs myXWikiDocument=xwiki.getDocument("MyWeb.MyDoc").getDocument() myXWikiDocument.addObject("XWiki.MyClass","XWiki.MyClass") xwiki.getXWiki().saveDocument(myXWikiDocument, context.getContext()) %> The above gives you an idea of the methods to start looking from in the Java code if you want to get down into the guts of the object layer. Hope this helps, Robin. On 21/09/06, e Box <[email protected]> wrote:
Hi,
Q1. How does one write a new property value to the database from any generic XWiki page? XWiki's conventional method for inputting property values for a document through the ClassSheet/etc. will not work in this particular case.
------------------------------------------------------------------------------------------------------------------------------------
Q2. Also, let's say I create a class with XWiki's standard Class Creation interface. Now I want to add an instance of this class. I go through the standard process, and now am entering data values (viewing the ClassSheet) for this particular document.
At this point in the process, how exactly is XWiki engaging the database? What is going on behind the scenes? If someone can, please explain this process more (e.g., what database connections are open, methods being called, etc.)
Thanks!
Danielle
_________________________________________________________________ Find a local pizza place, music store, museum and moreā¦then map the best route! http://local.live.com
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws