Class: ClassSheet
Log-in
|
XWiki
:
WebHome
>
Welcome to the Class Editor
>
Class: ClassSheet
Top Menu
Show
:
Comments
Attachments
History
Information
Stampa
:
Stampa
Anteprima di stampa
Esporta come PDF
Esporta in formato RTF
Esporta come HTML
Esporta in formato XAR
Wiki source code of
Class: ClassSheet
Show line numbers
#set( $class = $doc.name.substring(0,$doc.name.indexOf("Class"))) #set( $doc1new = $xwiki.getDocument("${doc.space}.${class}ClassSheet").isNew()) #set( $doc2new = $xwiki.getDocument("${doc.space}.${class}ClassTemplate").isNew()) #if (!$defaultweb) #set($defaultweb = "Main") #end #if (!$defaultparent) #set($defaultparent = "${doc.space}.${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" method="post"> <div> <input type="hidden" name="parent" value="${defaultparent}"/> <input type="hidden" name="template" value="${doc.space}.${class}ClassTemplate"/> <input type="hidden" name="sheet" value="1"/> Space: <input type="text" name="webname" value="${defaultweb}" size="8"/> Document: <input type="text" name="name" value="Name of your document"/> <br/> <br/> ## TODO: remove this onclick <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(); }’/> </div> </form> 1.1 Sheet and Template #set($templatedoc = $xwiki.getDocument("${doc.space}.${class}ClassTemplate")) #set($hasobj = $templatedoc.getObject("${doc.space}.${class}Class")) #if(!$hasobj) #set($xredirect = $request.getRequestURL()) #set($createUrl = $templatedoc.getURL("objectadd", "classname=${doc.space}.${class}Class&xredirect=${xredirect}")) #set($m = "The template does not have an object of class ${class}Class. <a href=’$createUrl’>Click here to add it</a>.") #warning($m) #end * Sheet: [${doc.space}.${class}ClassSheet] * Template: [${doc.space}.${class}ClassTemplate] * [View the sample code to show the document list and create new documents>XWiki.ClassSheet?xpage=code] 1.1 Existing documents #set ($sql = ", BaseObject as obj where obj.name=doc.fullName and obj.className=’${doc.space}.${class}Class’ and obj.name<>’${doc.space}.${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="$xwiki.getURL("${doc.space}.${class}ClassSheet","edit")" method="post"> <div> <input type="hidden" name="parent" value="${doc.space}.${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"/> </div> </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="$xwiki.getURL("${doc.space}.${class}ClassTemplate","edit")" method="post"> <div> <input type="hidden" name="parent" value="${doc.space}.${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"/> </div> </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
Search
Quick Links
Wiki Dashboard
Document Index
Blog
Sandbox
My Recent Modifications
dany
|
marco