Consortium
Activities
Projects
Forge
Events
Log-in
Register
Class: $doc.name
Space Menu
Consortium
|
Solutions
|
Middleware
|
Forge
|
MyObjectWeb
|
PDF
|
History
|
More Actions
View
Code
|
XML
|
Help
Documentation
|
XWiki Syntax
|
#includeTopic("XWiki.XWikiCommonJavascript") #set( $class = $doc.name.substring(0,$doc.name.indexOf("Class"))) #set( $doc1new = $xwiki.getDocument("${doc.web}.${class}ClassSheet").isNew()) #set( $doc2new = $xwiki.getDocument("${doc.web}.${class}ClassTemplate").isNew()) #if (!$defaultweb) #set($defaultweb = "Main") #end #if (!$defaultparent) #set($defaultparent = "${doc.web}.${class}Class") #end 1 Class: $doc.name The first thing to do is to <a href="$doc.getURL("edit", "xpage=editclass")">Edit the Class</a> to add properties to it. #if (!($doc1new||$doc2new)) 1.1 Create a new document To create a new document, you should first choose a name for you document <form action="" id="newdoc"> <input type="hidden" name="parent" value="${defaultparent}"> <input type="hidden" name="template" value="${doc.web}.${class}ClassTemplate"> <input type="hidden" name="sheet" value="1"> Web: <input type="text" name="webname" value="${defaultweb}" size="8"> Document: <input type="text" name="name" value="Name of your document" /> <br /> <br /> <input type="button" value="Create this document" onclick='if (updateName(this.form.name)) {this.form.action="../inline/" + this.form.webname.value + "/" + this.form.name.value; this.form.submit(); }'> </form> 1.1 Existing documents #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='${doc.web}.${class}Class' and obj.name<>'${doc.web}.${class}ClassTemplate'") #foreach ($item in $xwiki.searchDocuments($sql)) * [$item] #end #else 1.1 Create templates and sheets Before using this class you must first create the sheet and template for it. Follow the instructions below to do this. #if ($doc1new) <form action=""> <input type="hidden" name="parent" value="${doc.web}.${class}Class"> <input type="hidden" name="template" value="XWiki.ClassItemSheet"> <input type="hidden" name="sheet" value="1"> <input type="submit" value="Create the document sheet" onclick='this.form.action="../edit/${doc.web}/${class}ClassSheet"; this.form.submit();'> </form> #else The Sheet allows to control the presentation of documents using the class you define. You can use the default presentation which looks for all available fields and presents them in a table, or you can decide to write your own presentation showing only part of the fields. You can also decide to have a different presentation for the viewing and for the editing modes. * [${class}ClassSheet] #end #if ($doc2new) <form action=""> <input type="hidden" name="parent" value="${doc.web}.${class}Class"> <input type="hidden" name="template" value="XWiki.ClassItemTemplate"> <input type="hidden" name="sheet" value="1"> <input type="submit" value="Create the document template" onclick='this.form.action="../edit/${doc.web}/${class}ClassTemplate"; this.form.submit();'> </form> #else The template is the document that will be "copied" into the new document that you create. It will automatically contain a reference to the Sheet defined previously and an instance of the object of your Class. You need to add the instance of your class manually using the "Edit Objects" link in the right menu and also modify the content of the template to reference update the class name. You should also customize the parent field which will be the default parent of all documents that are created using the class. * [${class}ClassTemplate] #end #end