On Sat, May 4, 2013 at 9:22 PM, heyson <heyson.dev(a)gmail.com> wrote:
I'm trying to edit a object in a wiki page
I created a class with name = "Test.Message" and a single string attribute
named "text"
I put this code in a page
{{velocity}}
{{html clean="false" wiki="true"}}
#set($mobj=$doc.getObject("Tests.Message",true))
s/Tests/Test
$mobj.display("text",$context.action)<p/>
{{/html}}
{{/velocity}}
It show the form but when I save the page the object is not saved/updated.
What am I doing wrong?
When the page is saved the form is submitted to the save action which
by default only updates the values of existing objects. In your case
you want the object to be added if it doesn't exist. There are 2
solutions:
(A) The best practice, as indicated in
http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial , is to
create a template (= a document that has a Test.Message object with
default values) and a sheet (= a document that contains the above
code). Then you bind the Test.Message class to the sheet and use
/xwiki/bin/edit/SomeSpace/NewMessage?template=Test.MessageTemplate to
create a new message.
(B) You write the HTML form yourself and handle the submit. You need
to write code that adds the objects and saved the document on submit.
I highly recommend (A).
Hope this helps,
Marius
--
View this message in context:
http://xwiki.475771.n2.nabble.com/Update-objects-editing-a-page-tp7585001.h…
Sent from the XWiki- Users mailing list archive at
Nabble.com.
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users