Mathieu Peltier a écrit :
Hi,
I have been able to create a basic form that to allow to store my
registration. Please find below the stuff I use based on Ludovic's advises -
maybe this could help someone.
My next questions:
- where am I supposed to add validation code on the registration field (ex:
validation of email, mandatory fields, ...)
You have the following solutions for this:
1/ Do it in Javascript
2/ Not handle the form using inline/save but using the advanced API.
This means you will have more detailed control on the document.
This means using new XWikiDocument(), saveDocument() etc.. Basically it
would be taking part of the code of the createUser function and move it
in Groovy
In this case the notification would be easier to handle to.
It would be nice to have a third solution and allow to provide a script
for making this type of validations..
This is much more advanced but would be really cool..
- I would like to send a notification mail when a
Registration is created. I
have seen in the documentation that an ad hoc function is provided but where
am I supposed to add the code?
You can use the "xredirect" parameter in your form which can redirect to
a specific wiki page after the "save" action.
In this page you could have a script to handle the notification. I'll
publish an example soon for this as we did this as an exercice at the
IRCAD training.
- in Main.TestRegistration, I have hard coded the name
of the Registration
instance ("Reg1"). My first idea was to store the registrations under
Registration 1, Registration2, ..., Registrationn. How to automaticcally
calculate the name to use from the data already store in the database? Is
there a better solution?
This is the part where the fact that you can't call directly the
"save"
action causes a problem.
This will be fixed soon. Currently to do this you need to ask first for
the first name or last name then open the "inline" form with the user name
Given that you want to do one form registration, validation and
notification, maybe you should use the advanced API which will give you
more flexibility.
Ludovic
thanks,
====================
XWiki.RegistrationClass:
attribute name (String)
====================
XWiki.RegistrationClassSheet code (associated with an instance of
RegistrationClass)
1 Registration
#set( $obj = $doc.getObject("XWiki.RegistrationClass", 0))
#set( $class = $obj.xWikiClass)
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td> *First Name:* </td>
<td>$doc.display("first_name", $obj)</td>
</tr>
</table>
====================
XWiki.RegistrationClassTemplate:
#includeForm("XWiki.RegistrationSheet")
====================
Main.TestRegistration:
1 Registration
<form action="" id="newdoc">
#includeTopic("XWiki.XWikiCommonJavascript")
#set( $class = $xwiki.getDocument("XWiki.RegistrationClass").xWikiClass)
#set( $obj = $class.newObject() )
<input type="hidden" name="parent" value="Main.WebHome"
/>
<input type="hidden" name="template"
value="XWiki.RegistrationClassTemplate"
/>
<input type="hidden" name="sheet" value="1" />
<input type="hidden" name="webname" value="Main"/>
<input type="button" value="Register"
onclick='action="../../inline/" +
this.form.webname.value + "/Reg1"; this.form.submit();' />
</form>
====================
------------------------------------------------------------------------
--
You receive this message as a subscriber of the xwiki-users(a)objectweb.org mailing list.
To unsubscribe: mailto:xwiki-users-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page:
http://www.objectweb.org/wws
--
Ludovic Dubost
XPertNet:
http://www.xpertnet.fr/
Blog:
http://www.ludovic.org/blog/
XWiki:
http://www.xwiki.com
Skype: ldubost AIM: nvludo Yahoo: ludovic