Wiki code for
Class: ClassSheet
Hide Line numbers
1: #set( $class = $doc.name.substring(0,$doc.name.indexOf("Class"))) 2: #set( $doc1new = $xwiki.getDocument("${doc.web}.${class}ClassSheet").isNew()) 3: #set( $doc2new = $xwiki.getDocument("${doc.web}.${class}ClassTemplate").isNew()) 4: #if (!$defaultweb) 5: #set($defaultweb = "Main") 6: #end 7: #if (!$defaultparent) 8: #set($defaultparent = "${doc.web}.${class}Class") 9: #end 10: 11: 1 Class: $doc.name 12: 13: The first thing to do is to
Edit the Class
to add properties to it. 14: 15: #if (!($doc1new||$doc2new)) 16: 17: 1.1 Create a new document 18: 19: To create a new document, you should first choose a name for you document 20: 21:
22:
23:
24:
25: Web:
26: Document:
27:
28:
29:
30:
31: 32: 1.1 Sheet and Template 33: 34: #set($templatedoc = $xwiki.getDocument("${doc.web}.${class}ClassTemplate")) 35: #set($hasobj = $templatedoc.getObject("${doc.web}.${class}Class")) 36: #if(!$hasobj) 37: #set($xredirect = $request.getRequestURL()) 38:
The template does not have an object of class ${class}Class.
Click here to add it
.
39: #end 40: 41: * Sheet: [${doc.web}.${class}ClassSheet] 42: * Template: [${doc.web}.${class}ClassTemplate] 43: * [View the sample code to show the document list and create new documents>XWiki.ClassSheet?xpage=code] 44: 45: 1.1 Existing documents 46: 47: #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className='${doc.web}.${class}Class' and obj.name<>'${doc.web}.${class}ClassTemplate'") 48: #foreach ($item in $xwiki.searchDocuments($sql)) 49: * [$item] 50: #end 51: #else 52: 1.1 Create templates and sheets 53: 54: Before using this class you must first create the sheet and template for it. Follow the instructions below to do this. 55: 56: #if ($doc1new) 57:
58:
59:
60:
61:
62:
63: #else 64: 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. 65: * [${class}ClassSheet] 66: #end 67: 68: #if ($doc2new) 69:
70:
71:
72:
73:
74:
75: #else 76: 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. 77: 78: 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. 79: * [${class}ClassTemplate] 80: #end 81: #end