on further investigation I have found that basic form responsible for
creating the object based on some class template is:
<form action="" id="newdoc" method="post">
<div>
<input type="hidden" name="template"
value="${doc.web}.${class}ClassTemplate"/>
<input type="hidden" name="sheet" value="1"/>
Space: <input type="text" readonly="true" name="webname"
value="${defaultweb}" size="8"/>
Parent: <input type="text" readonly="true" name="parent"
value="${defaultparent}"/>
Supplier: <input type="text" name="name" value="Supplier
Name"/>
<br/>
<br/>
## TODO: remove this onclick
<input type="button" value="Create this supplier" onclick='if
(updateName(this.form.name)) {this.form.action="../../inline/" +
this.form.webname.value + "/" + this.form.name.value; this.form.submit();
}'/>
</div>
</form>
now parent can be specified while creating and its not static.
also if you see on submit it directs me to a link like:
xwiki/bin/inline/<space name>/
in the breadcrumb I see the current navigation path ie <parent page name>/.
but while saving parent defaults to the <class name> and not the <parent
page name>.
I also saw in the form (doing view source of this page that is to be saved),
and I did not see any input type with name parent.
However I see the correct template name being passed to this new page about
to be saved.
I this some kind of bug.
Also to verify if I add a input type parent in the MyClassSheet and add some
static value to this then I can see this input type in this form and the new
page is saved under this static page.
So the whole point is before page creation, one should be dynamically able
to pass the parent page name and that should be added as one of the input
fields under the new object about to be created.
Let me know how to achieve this.
Thanks
Sachin
Sachn Mittal wrote:
This is the code in my following Class pages
1. aeternam.SupplierClass
## replace Main with the Space where you want your documents to be created
## replace the default parent with the one of your choice
## Save this template using the ?Save? button
##set( $class = $doc.name.substring(0,$doc.name.indexOf("Class")))
#set($defaultparent = "aeternam.Suppliers")
#set($defaultweb = "aeternam")
#includeForm("XWiki.ClassSheet")
2. aeternam.SupplierClassTemplate
## replace MyName with the real class name
## save this template using the save button at the top left
#includeForm("aeternam.SupplierClassSheet")
3. aetername.SupplierClassSheet
## You can modify this page to customize the presentation of your object
## at first you should keep the default presentation.
## Save this template using the save button.
1 Document $doc.name
## Change class name to your class name
#set($class = $doc.getObject("aeternam.SupplierClass").xWikiClass)
#set($hasProps = false)
#foreach($prop in $class.properties)
#if($velocityCount == 1)
#set($hasProps = true)
<dl>
#end
<dt> ${prop.prettyName} </dt>
<dd>$doc.display($prop.getName())</dd>
#end
#if($hasProps)
</dl>
#end
So you can see that defaultParent is set in the SupplierClass page.
Let me know if I am doing anything wrong.
Thanks
Sachin
Sergiu Dumitriu-2 wrote:
Did you try setting the parent on the SuppliersTemplate document?
--
View this message in context:
http://www.nabble.com/Creating-structured-objects-tp14268015p14295378.html
Sent from the XWiki- Dev mailing list archive at
Nabble.com.