Changing Wicket text field validation error message - wicket

I have a text field that uses a PropertyModel, like this:
TextField<Integer> ageField = new TextField<Integer>("age",
new PropertyModel<Integer>(person, "age"));
When a non-integer value is submitted, the following error is displayed in the browser:
"The value of 'age' is not a valid Integer."
How can I modify this error message?

In Wicket 6 you need to set up a properties file with the inputs Wicket-ID appended by .Required:
myinput.Required = Please provide this input field
Define own feedback messages in Wicket

Create a properties file and specify your own message:
TextField.age=Your custom message
More info about properties here and here

Add
age.IConverter.Integer = Your Custom Message
to your properties file

What worked for me was adding this to the properties file:
<entry key="IConverter.Integer">${label} must be an integer.</entry>

Related

InfoPath 2010 How to avoid validation when a section is hidden?

I am trying to design an info path form that links to a share point list.
I have a "extra" section on the form which is only visible if a check box value = true.
The problem is some of the fields on the "extra" section is mandatory. So when the check box value = false, the section is hidden and I cannot fill in the fields. But when I try to submit the form I get an error message to say mandatory fields must be completed. But I do not want to complete those fields.. as the section is to be kept hidden.
Any suggestion on how to get this working would be very helpful thanks.
Do not add the required field checkbox instead create a validation rule that checks if your value is true and the hidden field is empty then send a required error.
This way you can submit the form.
put a sample value on that field like "none" then when the section is checked, set a rule that will clear that field.

When using ['#access'] in hook_form_alter() for a field than I am loosing '$form field default value' and $form_state input

When using an EntityReference field and in hook_form_alter() hiding that field with ['access'] than after submitting form $form_state input is empty for that field.
I have field field_to_a which is an entityrefence field on content type B that references content type A.
I am using hook_form_alter() in which i am using a line like $form['field_to_a']['#access'] = FALSE; and also setting this field to a certain value
When I am pressing submit button (my Save button) on node add:
When I am using $form['field_to_a']['#access'] = FALSE;: I am loosing $form_state['input']['field_to_a'] (does not exist) and $form['field_to_a']['und'][0]['target_id']['#default_value'] (empty) and I have PHP errors.
When I am using NOT $form['field_to_a']['#access'] = FALSE;: I have $form_state['input']['field_to_a'] properly and node is saved without any errors.
When I am using any other field I can use ['#access'] = FALSE and not loosing input in $form_state for that field.
Is there any solution or workaround for this thing? Is it a bug or normal behavior?
Thanks
First check log what you have received.
try this :
function hook_submit($form, &$form_state) {
watchdog("Your Form data ", '<pre>'.print_r($form_state, true).'</pre>');
}
Then check your log report. you will receive your value in $form_state['values']
It may helps you

iReport: localized default values for parameters

How to use localized default values for parameters in iReport?
Using a $R{message.key} as the parameter default value has negative consequences in the "Read fields" functionality of iReport's SQL editor. More precisely, the following error is shown (after pressing the Read fields button in Report query dialog):
Sourced file: inline evaluation of: ``$R{message.key}'' : Attempt to access property on undefined variable or class name
Any way around this iReport problem?
Here is the image to illustrate the problem:
I think this is a iReport's bug.
You can temporary comment the defaultValueExpression expression and add the fields via the Report query -> Read fields button.
Or you can manually add the fields declaration.
This is iReport bug ! To solve this issue please follow the below steps.
Open XML File
Remove defaultValueExpression tag value.

Wicket Drop down choice to set default value

I want to replace "choose one" option in drop down choice with other String "successfully occured" and I dont want to show list item to set the default.
DropDownChoice<Person> customer = new DropDownChoice<Person>(
"customer", new PropertyModel<Person>(customermodel, "customer"),list, new ChoiceRenderer<Person>("name", "id"));
The best way to do this is to put the definition
customer.null=successfully occured
in a properties file associated with the form or page containing the choice.
The properties file can also be localized so that what's shown depends on the locale.
For me I had to do following to get this done.
customer.setNullValid(true);
Then created a file named "HomePage.properties" (I added the drop down to HomePage)
set the null text in the .properties file as bellow.
nullValid=Choose one..

Zend hidden elements: hide html values

I am facing a special scenario here on some of my forms.
I have settled a permission system over some fields many of which are required.
When removing the permission to view the field on a form, I set:
$field->setDecorators('disableLoadDefaultDecorators', true);
The problem in that case is that I get prompted with the validation error over the required field, which is logical.
The other option would be to set the $field to hidden but the issue turns to become an html problem where any person can retrieve the hidden value through the source code.
Hopefully someone can offer me a suggestion on how to hide the element from the form and metadata but return it on form validation as if it was displayed.
Thank you in advance!
Change the field validation rules so that it is not required:
$field->setRequired(false)->setDecorators('disableLoadDefaultDecorators', true);