PloneFormGen Override Uppercase Output - plone

I am trying to figure out how to make the replacement parts fields data show up in all uppercase when the email is received. This form will be used for entering serial numbers containing alphanumeric characters which makes it hard to read when lowercase letters are used.
Is there an override that can accomplish this or will the mailer template need to be modified? How would you resolve this?

Assuming the field has the id 'replacement-parts', add a custom script adapter with the key code:
request.form['replacement-parts'] = request.form.get('replacement-parts', '').upper())
Make sure it's above your mailer, as the action adapters are executed in folder-contents order.

Related

How can I verify a field is required using Geb?

I am writing an automated test using Spock/Geb and I want to verify that a field is actually required.
Here is the code:
Code for Client Name and Client ID fields which are both required
Here is what I have tried to write that did NOT successfully check to make sure the two fields are actually required:
Assertions
Does anyone have any idea what my code should look like?
Here is what the actual page looks like - I am trying to verify the red asterisk:
enter image description here
Update: The following code worked:
assert clientConfigPage.modalClientNameTextBox.getAttribute("required")
You want to use Navigator.hasClass(String className). This will return a boolean whether the element has a class by the given name. In your example you use .getAttribute("class") == "req" but the class attribute is "required" so you must check for that string literal.

Adding IP Address to Email Validation RegEx

I am using the RegEx "^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*#[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+[.])*(\.[a-zA-Z]{2,17})$"to validate Email but my lead want to validate as per the Microsoft standard. SO i need to follow
http://msdn.microsoft.com/en-us/library/01escwtf(v=vs.100).aspx
In that everything working fine as per the standard but still i am facing the issues with
Valid: js#internal#proseware.com
Valid: j_9#[129.126.118.1]
the above mentioned mail ID is still returning as invalid. I tried using the regex used in that page
^(?("")(""[^""]+?""#)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])#))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9]{2,17}))$
but i am getting the error in the server page. Though I pasted the expression inside the validation Expression it can't able to accept the characters.
Note : am using ASP.Net validators for validating the email.
Description
To match both of those email addresses in your sample text, I think I would rewrite your expression like this:
[A-Z0-9._%#+-]+#(?:[A-Z0-9.-]+\.[A-Z]{2,4}|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\])
If you're looking to use this to validate a string which may contain only an email then you can add the start/end of string anchors ^ and $.
Example
Live Demo
Sample Text
Valid: js#internal#proseware.com Valid: j_9#[129.126.118.1]
Matches
[0][0] = js#internal#proseware.com
[1][0] = j_9#[129.126.118.1]

How can I make input fields accept locale dependent number formatting?

I'm working on a Spring MVC Project and ran into a problem with the internationalization in forms, especially the number formatting.
I already use fmt:formatNumber to format the numbers according to the current selected locale.
<fmt:formatNumber value="${object[field]}"/>
Like this, number formatting works well when I display numbers. But how about the forms?
At the moment, the input fields that are supposed to receive float values are prefilled with 0.0 and expect me to use "." as decimal separator, no matter what locale is selected. Values containing "," are refused by the server (...can not convert String to required type float...).
How can I make my input fields use and accept the appropriate number format as well?
Did you have a look at #NumberFormat? If you annotate the property the input field is bound to, this should result in the proper formatting. Something like:
#NumberFormat(style = Style.NUMBER)
private BigDecimal something;
This style is the "general-purpose number format for the current locale". I guess, the current locale is determined threadwise from the LocaleContextHolder.
Your app needs to be annotation-driven, also see the section "Annotation-driven Formatting" in the docs.
You might want to take a look at the DecimalFormatSymbols as suggested in this answer.

Drupal: Edit !name variable in my Drupal to first name?

I’ve a bit of annoying problem with a Drupal site. I’ve a “recommend to a friend” field where one can send an article link to an E-mail address. The problem is, that it uses the variable !name in the mail and when I’m receive a mail, it uses the name before the “#” in my mail.
I use my mail as username, so if I’ve registered a user with the username: johndoe#google.com it will present the !name variable as johndoe.
What I want is to display the first name (and maybe the last name) so it says: John Doe recommends this article …
But how can I do that? I’ve search like crazy for the setting.
Thanks
Sincere
- Mestika
To replace user names in quotes by reals names it's necessary to replace Phorum´s standard function for quoting. Since it only makes sense to have one module modifying the quoted text, you can disable this one part of this module. Use System Sanity Checks to control if there is only one module using the quote hook. The default value is "disabled".
TUV Rheinland of North America
You could also try the Custom Tokens module. I use it to get text from my user's Content Profile.

Test if the user typed email format ASP.NET (VB)

I have a TextBox, and I want to force the user to type an email format in this field like (example#mail.com) ?
I don't want to use FilteredTextBoxExtender or the RegularExpressionValidator.
I want to do it manualy.
Use the MailAddress class of System.Net.Mail. If what you pass into it is not a valid email address it will fail.
Example:
How do I validate email address formatting with the .NET Framework?
You are really going to reinvent the wheel.
But if it is your wish, you have to use string manipulation functions built in to the String object.
First do a check whether there is a in # symbol in the text.
Use String.Contains to check that.
Or you can use String.IndexOf to check whether the # symbol is present, and if present which index is it present. (considering the string as an array of characters)
And then check whether there are any (and how many) characters present before the # symbol.
If the symbol # symbol was in the 4th index, then you know there are 3 characters before etc.
There's plethora of functions for the String object. You may have to use Length function and String.SubString to retrieve parts of the string.
Get the indexes of the # symbol and the . symbol and check whether there are at least 3 characters in between.
I really cant seem to think of all the possibilities but first list down all the possibilities and check them one by one.
You can also use the Contains method to check whether illegal characters are present :)
EDIT: String.LastIndexOf will return the last index where a specified character was found ;)
And you count and check whether the # symbol was found more than once etc
String.IndexOfAny(Char[])
String.IndexOfAny Method (Char[], Int32)
String.IndexOfAny Method (Char[], Int32, Int32)
This is the best way I found on internet.
Regex.IsMatch(YourStringEmail, "^(?("")("".+?""#)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])#))" + _
"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$")
Thank you.

Resources