Use regular expression in object mode

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Use regular expression in object mode

pierrick.bena
Hi everybody !

I have a problem with validation using regular expression.

I created a class with a number property "price". I defined the
Validation Regular Expression : [-+]?[0-9]*[.,]?[0-9]+  and the
Validation Message is stored in a translation page.

I would like that  the Validation message appears when I try to edit
the price property  of an object of this class with a bad value.
Currently it seems my regexp is not used : I never see my validation
message.

I tried to use this page but no success :
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#Attachments

Need help please.

Thanks a lot!

Pierrick

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Use regular expression in object mode

Marius Dumitru Florea
On Tue, Jul 9, 2013 at 4:35 PM,  <[hidden email]> wrote:

> Hi everybody !
>
> I have a problem with validation using regular expression.
>
> I created a class with a number property "price". I defined the Validation
> Regular Expression : [-+]?[0-9]*[.,]?[0-9]+  and the Validation Message is
> stored in a translation page.
>
> I would like that  the Validation message appears when I try to edit the
> price property  of an object of this class with a bad value. Currently it
> seems my regexp is not used : I never see my validation message.
>
> I tried to use this page but no success :
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#Attachments

You mean http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HHowtocreatevalidationsusingregularexpressions
? So you added the xvalidate hidden input to your form? Can you check
that you have it on the client (inspect with Firebug or other browser
dev tool)? What happens on save when the price value is invalid? Is
the page saved with the bad value? What version of XWiki are you
using?

Hope this helps,
Marius

>
> Need help please.
>
> Thanks a lot!
>
> Pierrick
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Use regular expression in object mode

pierrick.bena
Hi Marius, thanks for your answer.

I'm using the version 5.0.1.

I added the hidden input but I think it's at the wrong place. Where
should I add it ? in myclassClass, myclassTemplate or in the page
containing my object ?
When I put a bad value for the price, the page is not saved.

Pierrick

On Tue, 9 Jul 2013 18:17:28 +0300, Marius Dumitru Florea
<[hidden email]> wrote:

> On Tue, Jul 9, 2013 at 4:35 PM,  <[hidden email]> wrote:
>> Hi everybody !
>>
>> I have a problem with validation using regular expression.
>>
>> I created a class with a number property "price". I defined the Validation
>> Regular Expression : [-+]?[0-9]*[.,]?[0-9]+  and the Validation Message is
>> stored in a translation page.
>>
>> I would like that  the Validation message appears when I try to edit the
>> price property  of an object of this class with a bad value. Currently it
>> seems my regexp is not used : I never see my validation message.
>>
>> I tried to use this page but no success :
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#Attachments
>
> You mean
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HHowtocreatevalidationsusingregularexpressions
> ? So you added the xvalidate hidden input to your form? Can you check
> that you have it on the client (inspect with Firebug or other browser
> dev tool)? What happens on save when the price value is invalid? Is
> the page saved with the bad value? What version of XWiki are you
> using?
>
> Hope this helps,
> Marius
>
>>
>> Need help please.
>>
>> Thanks a lot!
>>
>> Pierrick
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.xwiki.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Use regular expression in object mode

Marius Dumitru Florea
On Wed, Jul 10, 2013 at 10:36 AM,  <[hidden email]> wrote:
> Hi Marius, thanks for your answer.
>
> I'm using the version 5.0.1.
>
> I added the hidden input but I think it's at the wrong place. Where
> should I add it ? in myclassClass, myclassTemplate or in the page
> containing my object ?

That hidden input must be put in the sheet that controls what is
displayed in Inline Form edit mode for objects of your class. Most
classes have a template (storing default values) and a sheet
(controlling the presentation). See
http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial and
http://extensions.xwiki.org/xwiki/bin/view/Extension/Sheet+Module . A
minimal sheet that displays your 'price' property looks like this:

----------8<----------
{{velocity}}
#set ($xclass = $xwiki.getDocument('Space.SomeClass').xWikiClass)
(% class="xform" %)(((
  ; $doc.displayPrettyName('price')##
    #set ($validationMessageKey =
$xclass.get('price').getProperty('validationMessage').value)
    (% class="xErrorMsg" %)#if
($xcontext.validationStatus.errors.contains($validationMessageKey))$services.localization.render($validationMessageKey)#end(%%)
  : $doc.display('price')
)))

{{html}}
<div class="hidden">
  ## Enable validation.
  <input type="hidden" name="xvalidate" value="1" />
</div>
{{/html}}
{{/velocity}}
---------->8----------

This is partially explained in
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HDisplaythevalidationerrormessagesnexttothefield
(but with deprecated API and syntax).

Hope this helps,
Marius

> When I put a bad value for the price, the page is not saved.
>
> Pierrick
>
> On Tue, 9 Jul 2013 18:17:28 +0300, Marius Dumitru Florea
> <[hidden email]> wrote:
>> On Tue, Jul 9, 2013 at 4:35 PM,  <[hidden email]> wrote:
>>> Hi everybody !
>>>
>>> I have a problem with validation using regular expression.
>>>
>>> I created a class with a number property "price". I defined the Validation
>>> Regular Expression : [-+]?[0-9]*[.,]?[0-9]+  and the Validation Message is
>>> stored in a translation page.
>>>
>>> I would like that  the Validation message appears when I try to edit the
>>> price property  of an object of this class with a bad value. Currently it
>>> seems my regexp is not used : I never see my validation message.
>>>
>>> I tried to use this page but no success :
>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#Attachments
>>
>> You mean
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HHowtocreatevalidationsusingregularexpressions
>> ? So you added the xvalidate hidden input to your form? Can you check
>> that you have it on the client (inspect with Firebug or other browser
>> dev tool)? What happens on save when the price value is invalid? Is
>> the page saved with the bad value? What version of XWiki are you
>> using?
>>
>> Hope this helps,
>> Marius
>>
>>>
>>> Need help please.
>>>
>>> Thanks a lot!
>>>
>>> Pierrick
>>>
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.xwiki.org/mailman/listinfo/users
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.xwiki.org/mailman/listinfo/users
>
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Use regular expression in object mode

Marius Dumitru Florea
And btw the regular expression needs to follow the Perl5 standard
http://www.perl.com/doc/FMTEYEWTK/regexps.html . You may need to put
it between // (forward slash).

On Wed, Jul 10, 2013 at 1:19 PM, Marius Dumitru Florea
<[hidden email]> wrote:

> On Wed, Jul 10, 2013 at 10:36 AM,  <[hidden email]> wrote:
>> Hi Marius, thanks for your answer.
>>
>> I'm using the version 5.0.1.
>>
>> I added the hidden input but I think it's at the wrong place. Where
>> should I add it ? in myclassClass, myclassTemplate or in the page
>> containing my object ?
>
> That hidden input must be put in the sheet that controls what is
> displayed in Inline Form edit mode for objects of your class. Most
> classes have a template (storing default values) and a sheet
> (controlling the presentation). See
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial and
> http://extensions.xwiki.org/xwiki/bin/view/Extension/Sheet+Module . A
> minimal sheet that displays your 'price' property looks like this:
>
> ----------8<----------
> {{velocity}}
> #set ($xclass = $xwiki.getDocument('Space.SomeClass').xWikiClass)
> (% class="xform" %)(((
>   ; $doc.displayPrettyName('price')##
>     #set ($validationMessageKey =
> $xclass.get('price').getProperty('validationMessage').value)
>     (% class="xErrorMsg" %)#if
> ($xcontext.validationStatus.errors.contains($validationMessageKey))$services.localization.render($validationMessageKey)#end(%%)
>   : $doc.display('price')
> )))
>
> {{html}}
> <div class="hidden">
>   ## Enable validation.
>   <input type="hidden" name="xvalidate" value="1" />
> </div>
> {{/html}}
> {{/velocity}}
> ---------->8----------
>
> This is partially explained in
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HDisplaythevalidationerrormessagesnexttothefield
> (but with deprecated API and syntax).
>
> Hope this helps,
> Marius
>
>> When I put a bad value for the price, the page is not saved.
>>
>> Pierrick
>>
>> On Tue, 9 Jul 2013 18:17:28 +0300, Marius Dumitru Florea
>> <[hidden email]> wrote:
>>> On Tue, Jul 9, 2013 at 4:35 PM,  <[hidden email]> wrote:
>>>> Hi everybody !
>>>>
>>>> I have a problem with validation using regular expression.
>>>>
>>>> I created a class with a number property "price". I defined the Validation
>>>> Regular Expression : [-+]?[0-9]*[.,]?[0-9]+  and the Validation Message is
>>>> stored in a translation page.
>>>>
>>>> I would like that  the Validation message appears when I try to edit the
>>>> price property  of an object of this class with a bad value. Currently it
>>>> seems my regexp is not used : I never see my validation message.
>>>>
>>>> I tried to use this page but no success :
>>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#Attachments
>>>
>>> You mean
>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HHowtocreatevalidationsusingregularexpressions
>>> ? So you added the xvalidate hidden input to your form? Can you check
>>> that you have it on the client (inspect with Firebug or other browser
>>> dev tool)? What happens on save when the price value is invalid? Is
>>> the page saved with the bad value? What version of XWiki are you
>>> using?
>>>
>>> Hope this helps,
>>> Marius
>>>
>>>>
>>>> Need help please.
>>>>
>>>> Thanks a lot!
>>>>
>>>> Pierrick
>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> [hidden email]
>>>> http://lists.xwiki.org/mailman/listinfo/users
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.xwiki.org/mailman/listinfo/users
>>
>> _______________________________________________
>> users mailing list
>> [hidden email]
>> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Use regular expression in object mode

pierrick.bena
On Wed, 10 Jul 2013 13:28:16 +0300, Marius Dumitru Florea
<[hidden email]> wrote:

> And btw the regular expression needs to follow the Perl5 standard
> http://www.perl.com/doc/FMTEYEWTK/regexps.html . You may need to put
> it between // (forward slash).
>
> On Wed, Jul 10, 2013 at 1:19 PM, Marius Dumitru Florea
> <[hidden email]> wrote:
>> On Wed, Jul 10, 2013 at 10:36 AM,  <[hidden email]> wrote:
>>> Hi Marius, thanks for your answer.
>>>
>>> I'm using the version 5.0.1.
>>>
>>> I added the hidden input but I think it's at the wrong place. Where
>>> should I add it ? in myclassClass, myclassTemplate or in the page
>>> containing my object ?
>>
>> That hidden input must be put in the sheet that controls what is
>> displayed in Inline Form edit mode for objects of your class. Most
>> classes have a template (storing default values) and a sheet
>> (controlling the presentation). See
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial and
>> http://extensions.xwiki.org/xwiki/bin/view/Extension/Sheet+Module . A
>> minimal sheet that displays your 'price' property looks like this:
>>
>> ----------8<----------
>> {{velocity}}
>> #set ($xclass = $xwiki.getDocument('Space.SomeClass').xWikiClass)
>> (% class="xform" %)(((
>>   ; $doc.displayPrettyName('price')##
>>     #set ($validationMessageKey =
>> $xclass.get('price').getProperty('validationMessage').value)
>>     (% class="xErrorMsg" %)#if
>> ($xcontext.validationStatus.errors.contains($validationMessageKey))$services.localization.render($validationMessageKey)#end(%%)
>>   : $doc.display('price')
>> )))
>>
>> {{html}}
>> <div class="hidden">
>>   ## Enable validation.
>>   <input type="hidden" name="xvalidate" value="1" />
>> </div>
>> {{/html}}
>> {{/velocity}}
>> ---------->8----------
>>
>> This is partially explained in
>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HDisplaythevalidationerrormessagesnexttothefield
>> (but with deprecated API and syntax).
>>
>> Hope this helps,
>> Marius
>>
>>> When I put a bad value for the price, the page is not saved.
>>>
>>> Pierrick
>>>
>>> On Tue, 9 Jul 2013 18:17:28 +0300, Marius Dumitru Florea
>>> <[hidden email]> wrote:
>>>> On Tue, Jul 9, 2013 at 4:35 PM,  <[hidden email]> wrote:
>>>>> Hi everybody !
>>>>>
Hi Marius, thanks for your help, it works now.

Regards, Pierrick

>>>>> I have a problem with validation using regular expression.
>>>>>
>>>>> I created a class with a number property "price". I defined the Validation
>>>>> Regular Expression : [-+]?[0-9]*[.,]?[0-9]+  and the Validation Message is
>>>>> stored in a translation page.
>>>>>
>>>>> I would like that  the Validation message appears when I try to edit the
>>>>> price property  of an object of this class with a bad value. Currently it
>>>>> seems my regexp is not used : I never see my validation message.
>>>>>
>>>>> I tried to use this page but no success :
>>>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#Attachments
>>>>
>>>> You mean
>>>> http://platform.xwiki.org/xwiki/bin/view/DevGuide/Creating+a+form+with+validation+and+tooltips#HHowtocreatevalidationsusingregularexpressions
>>>> ? So you added the xvalidate hidden input to your form? Can you check
>>>> that you have it on the client (inspect with Firebug or other browser
>>>> dev tool)? What happens on save when the price value is invalid? Is
>>>> the page saved with the bad value? What version of XWiki are you
>>>> using?
>>>>
>>>> Hope this helps,
>>>> Marius
>>>>
>>>>>
>>>>> Need help please.
>>>>>
>>>>> Thanks a lot!
>>>>>
>>>>> Pierrick
>>>>>
>>>>> _______________________________________________
>>>>> users mailing list
>>>>> [hidden email]
>>>>> http://lists.xwiki.org/mailman/listinfo/users
>>>> _______________________________________________
>>>> users mailing list
>>>> [hidden email]
>>>> http://lists.xwiki.org/mailman/listinfo/users
>>>
>>> _______________________________________________
>>> users mailing list
>>> [hidden email]
>>> http://lists.xwiki.org/mailman/listinfo/users
> _______________________________________________
> users mailing list
> [hidden email]
> http://lists.xwiki.org/mailman/listinfo/users

_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users