Updating properties dynamically from velocity
Hi all, Not sure if this can be done; but I've come across the need to update object properties directly from velocity. For example, object A is in a particular document 4 times. Each has 25 sets of 2 string properties, (field1_before; field1_after) When the user updates the _after field, I need to do certain operations - when done, I then need to update the _before field so that it only happens once. I guess, long and short of it is: anyone managed to update a property from velocity directly (without redirecting the url each time)? Or have any idea's how it could be done?
I guess, long and short of it is: anyone managed to update a property from
velocity directly (without redirecting the url each time)? Or have any idea's how it could be done?
Only documents with programming rights can update objects and save the document. So, what you need is a page that performs all the changes, saved by a user with programming rights. This page should receive as parameters the target document name, objects and properties, perform all the changes, and save back the document. There is the set(String fieldname, Object value) method in the Object API, which can be called by any user, but in order to keep the changes, you need to call $doc.save() at the end. -- http://purl.org/net/sergiu
Hi Sergui, Thanks, I shoulda looked to the API first, sorry o.O - at least would just be a matter of knowing $doc.save after using. I can do this from a static include (so programming rights are no real problem). If I read it right, I would call set directly from the Object ($doc.getObject() result for example) reference and not the document reference? ________________________________ From: Sergiu Dumitriu [mailto:[email protected]] Sent: 19 February 2007 14:29 To: [email protected] Subject: Re: [xwiki-users] Updating properties dynamically from velocity I guess, long and short of it is: anyone managed to update a property from velocity directly (without redirecting the url each time)? Or have any idea's how it could be done? Only documents with programming rights can update objects and save the document. So, what you need is a page that performs all the changes, saved by a user with programming rights. This page should receive as parameters the target document name, objects and properties, perform all the changes, and save back the document. There is the set(String fieldname, Object value) method in the Object API, which can be called by any user, but in order to keep the changes, you need to call $doc.save() at the end. -- http://purl.org/net/sergiu
participants (2)
-
Esbach, Brandon -
Sergiu Dumitriu