Hi, I am completly new to xwiki. I would like to create a basic form to store registration (only last name info for the moment). Here is what I have already tried, but it does not work. I don't understand what I am supposed to do in order to store the new registration (should I create a Java class for this?) Any help would be appreciate - is there some demo available? thanks, ==================== XWiki.RegistrationClass: attribute name (String) ==================== XWiki.RegistrationClassSheet code: 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.Registration: 1 Registration #set ($register = $request.getParameter("register")) #if ($register) Registration of *$request.getParameter("register_first_name")* #set( $class = $xwiki.getDocument("XWiki.RegistrationClass").xWikiClass) #set( $reg = $class.newObject() ) #set($class.first_name = $request.getParameter("register_first_name")) #if ($reg>0) Your registration has been correctly registered. Thanks. #else Sorry, an error occured during the registration process. #end #else Please provide us with the following information: <form id="register" name="register" action="" method="get"> <input type="hidden" name="template" value="XWiki.RegistrationTemplate" /> <input type="hidden" name="register" value="1"> #set( $class = $xwiki.getDocument("XWiki.RegistrationClass").xWikiClass) #set( $obj = $class.newObject() ) <table class="block" cellspacing="5px" border="0"> <tr> #set($prop = $class.first_name) <td>First Name</td> <td>$doc.displayEdit($prop, "register_", $obj)</td> </tr> </table> <input type="submit" value="Save My Registration"> </form> #end ==================== -- Mathieu Peltier ObjectWeb Consortium - INRIA E-mail: [email protected] JabberID: [email protected]
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, ...) - 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? - 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? 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> ==================== -- Mathieu Peltier ObjectWeb Consortium - INRIA E-mail: [email protected] JabberID: [email protected]
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 [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?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
On Friday 15 April 2005 17:32, Ludovic Dubost wrote:
- 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
yes but the username cannot be used to identity the registration (I could use the email but this is not a valid wiki page 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.
Is there an Hello World sample available somethere which demonstrates how to use the "advanced api"...? thanks for your time. -- Mathieu Peltier ObjectWeb Consortium - INRIA E-mail: [email protected] JabberID: [email protected]
I see the problem with the registration ID if you don't want to use the username. In this case you can store the registration ID in a field and get the next one using a select max().. I can help you write the application if we make a sample application out of it.. What do you think ? Can you give me access to your server ? Ludovic Mathieu Peltier a écrit :
On Friday 15 April 2005 17:32, Ludovic Dubost wrote:
- 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
yes but the username cannot be used to identity the registration (I could use the email but this is not a valid wiki page 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.
Is there an Hello World sample available somethere which demonstrates how to use the "advanced api"...?
thanks for your time.
------------------------------------------------------------------------
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?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
participants (2)
-
Ludovic Dubost -
Mathieu Peltier