I have a dropdown list with few rows in a table. All the dropdown are required fields. if none of the dropdown list has been selected and a user select only one dropdown and tries to save. A validation error is thrown which is correct, the problem is the value for the selected dropdown choice gets reset to "Choose one". how can i correct that?
Wicket uses the IChoiceRenderer#getIdValue() to find the selected option. If you do not provide custom IChoiceRenderer then Wicket will use ChoiceRenderer and as an id it will use the index of the item in the List of options.
See the usages of #equals() at https://github.com/apache/wicket/blob/7bef3d67c8ccc269f02e8943bf9a22c3cd5438e9/wicket-core/src/main/java/org/apache/wicket/markup/html/form/AbstractSingleSelectChoice.java. Even better fire the debugger and see what happens!
Related
I'm new to Magnolia, and I'm making my own module.
I have a dialog box when adding a component and I want to change next fields below dynamically using a select field.
Example:
Select field with {"type 1", "type 2", ...}
IF "type 1" is selected
->show a text field below
ELSE
->show a basicUpload field below
Thanks in advance.
I believe same was already discussed here and few other places if you look over questions tagged "magnolia".
Long story short, fields are atomic, independent entities. They do not know about each other. So the only way to create such dynamic connection is over "parent" form. You need to extend form presenter and field factory (if you want select that would be SelectFieldFactory) and in there, when field is created, attach value changed or similar listener to it so when value is changed in the field, you can inform presenter to make some other field visible or hide it.
IIRC you can see example of that done in External Forms module (if you have access to enterprise code). Not sure if any of the community modules show the same.
When creating a form in Orbeon Form Builder, you can define a list of values for a dropdown list box.
When running the form in form runner, is it possible to remove the "[Select...]" value from this dropdown list box?
I would like to restrict the possible values only to the given ones and restricting the user from selecting an "[Select...]" value when filling in the form. I hope you understand what I mean :)
Here is a screenshot
It's not possible without changes to Orbeon Forms to remove the empty option.
The best way to achieve what you want is to make the field required. When that's the case, the user will have to select a value or validation won't pass.
(The rationale for adding/keeping an empty option at the top is to force the user to make a selection. Otherwise it is possible that users might not even look at the option selected by default, and involuntarily select an incorrect option.)
While executing protractor tests, I would like to clear a dropdown. I know how to select a particular option in dropdown. How can it be cleared?
The dropdown is part of a form. The values of the options for dropdown are loaded with an ajax call. So, the select looks something like this.
<select>
<option>First Value</option>
<option>Second Value</option>
<select>
Now, when the form is loaded, no value is selected. But, as soon as a value is selected it is not possible to clear it (even manually) as this is a mandatory field. It is only possible to select an alternate value from the dropdown.
However, I would like to do a second test, which checks if the value of this field is blank (no selection). For this I have to clear the dropdown. Does protractor provide a way?
Let's say I can't change the order of tests for some reason.
Currently, I reload the entire form in order to clear the dropdown.
If the dropdown cannot be typed into, the only way to clear a dropdown using Protractor is to have an option in your dropdown that acts as a default selection before a user has selected 'First Value' or 'Second Value. This can be a blank option as well, like you desire
Something like this:
<select>
<option></option>
<option>First Value</option>
<option>Second Value</option>
</select>
And then select the first option via
element.all(by.tagName('option')).get(0).click();
This should get you the desired effect. Let me know if this helps!
I have created a form in orbeon form builder which has three 30 questions which are belongs to 3 categories. Now I don't want to show all the 30 questions to every one also I don't want to create different forms for each category because all these categories belongs to one module.
While adding the form I have a drop down question like "Select Category". If user select the first category then I need to display only first category related questions and hide the second and third category related questions.
Is there any way to achieve my task in Form Runner?
UPDATE:
#ebruchez, I have followed your suggestion, I tried testing this feature on default "contacts" form. I have created a new text field in the contact form named "Account Related Field" as a label and "control-10" as Control Name. Below is the screen shot for the same.
Then After that I clicked on control setting of the "Account Related Field" and under the "Formulas" tab I have added the following XPath expression in "Visibility" section. $topic='Account' following is the screenshot.
After adding the path expression I saved the contact form and published. Then I tried opening the form in form runner. But I am not able to view the "Account Related Field" field on UI after selecting the "topic" value is "Account" in the form runner. This is the screenshot of form runner after publishing form in form builder.
Did I miss something. Please help to resolve the issue. I need to view "Account Related Field" field only if "topic" field value is "Account"
Thanks in advance.
Yes you can, by using a "Visibility" formula under the section settings. For example if your dropdown is named foo and has two entries, category1 and category2, then you can write:
$foo = 'category1'
to make the section visible only if the dropdown selected category1, and:
$foo = 'category2'
to make the section visible only if the dropdown selected category2.
This doc might help.
I am facing issue in Setting the Value of Select Box in Grid .
Scenario: in the ListGrid i am having two Combo box .
For One combo box i am getting the value in the list during the onload and displaying .
On change value of first combo i need to fetch data from a list with input value from frst combo. i am getting the value from list but when i try to set in the second combo its not loading
Please find my code below.
//Properly Loading Combo
TaskName=new ListGridField("task_name","task_label);
SelectItem taskItem=new SelectItem("task_name","task_label);
taskNameList=populateTaskName();//Getting while onload
taskItem.setValueMap(taskNameList);
taskItem.addChangedHandler(...);
TaskName.setEditorType(taskItem);
TaskName.setValueMap(taskNameList);
TaskName.setRequired(true);
TaskName.setCanEdit(true);
//Not Loading Combo
SubTaskName=new ListGridField("Sub_task_name","Sub_task_label);
SelectItem subTaskItem=new SelectItem("Sub_task_name","Sub_task_label);
subTaskItem.addChangedHandler(...);
SubTaskName.setEditorType(taskItem);
TaskName.setRequired(true);
TaskName.setCanEdit(true);
//ChangeHandlerFor taskItem-FirstCombo
onChange(){
Form item=event.getItem();
item.setTooltip(item.getDisplayValue());
String taskId=String.valueOf(item.getValue());
populateSubTaskname(taskId);
subTaskItem.setValueMap(subtaskNameList);//getting the subtaskname List from RPC Call
SubTaskName.setValueMap(subtaskNameList);
populateSubTaskname(){
getting the value and loads in List
//subtaskNameList
subTaskItem.setValueMap(subtaskNameList);//getting the subtaskname List
SubTaskName.setValueMap(subtaskNameList);
}
//ChangeHandlerFor taskItem-Second Combo
onChange(){
Form item=event.getItem();
item.setTooltip(item.getDisplayValue());
}//Here also Name in the Map is not setting instead setting the value alone sometimes
Please help me where im wrong.
Once value in the combobox/select item changes, you need to assign it again to List grid field.
eg: listGridField.setEditorProperties(selectItem)