Orbeon forms - clear dropdown label - orbeon

I have 2 dropdowns (country_1 and country_2) populate with countries. Both are required. If I choose value some in the country_1 dropdown, the country_2 dropdown should be cleared (value and label).
Example:
In the country_1 dropdown I choose something.
In the country_2 dropdown I choose something.
In the country_1 dropdown I change value. country_2 should be cleard.
When I validate form I get error on country_2 dropdown (so it seems that the value has been cleared).
I would like to in step 3 the country_2 will have empty label.
I have added value change action to country_1 dropdown, that should clear country_2 dropdown value and label.
Example form:
https://demo.orbeon.com/demo/fr/orbeon/builder/edit/bc71b6532f4faee1ec711105a2db00bb65995d80
Source code: https://gist.github.com/mmakos-profidata/9728f086da3abc7bd96af27c8d5a70b8
Error screen:

Moving your code to be inside the <xf:model> does the trick. I've updated your form on demo.orbeon.com, but in case it disappears, this is the snippet that I put directly inside the <xf:model>:
<xf:action event="xforms-value-changed" observer="c_country_1-control">
<xf:action if="//c_country_1 != 'af'">
<xf:setvalue ref="//c_country_2"/>
<xf:setvalue ref="//c_country_2/#label"/>
</xf:action>
</xf:action>

Related

How to make Grails drop down readonly

I had a requirement of making drop down read only in Grails gsp page. I had two gsp pages create and show. In create user select an element in drop down and submits the selection. In show.gsp, I would like to fetch and show the same element( element selected in create page ) and drop down must be readonly.
Example :
Create.gsp : drop-down 1 2 3
User selected 3
Show.gsp : drop-down must be readonly with value 3
You can disable the input, this does mean the value won't be submitted but if this is a read only view it shouldn't matter, if it does you could add a hidden field for the real value
<g:select name="mySelect" from="${[1,2,3]}" value="3" disabled="disabled" />

ViewModel binding without SelectList in ASP.NET MVC

In my ASP.NET Core application, I have an ASP.NET MVC View which displays a list of products. (I guess this applies to other versions of MVC as well).
When I select an item from this list and submit the page, I want the selected product ID to be bound to a ViewModel property in the action method of the controller. I am using POST for this.
I do NOT want to use SelectList for rendering the list of products due to some formatting issues. Therefore I am looping over the list in my view.
How can I bind the selected product with the ProductId property of the inbound ViewModel object?
It's unclear what you mean by "select an item from this list and submit the page". Are you picking an item, potentially filling out more fields, and then submitting the whole shebang, or does picking an item constitute submitting the form. Depending on the situation there's a few approaches:
If picking an item submits the form, then you can simply make the "Select" button a submit button and give it a name and value. For example:
Item 1 <button type="submit" name="ProductId" value="1">Select</button>
Whichever "Select" button is clicked, then, will have its value posted as ProductId.
If you need to pick an item while remaining on the page to fill out other fields, then you can use radio buttons as an alternative to a select list. This is similar to approach above, except you will not instantly post the form. Your inputs would look similar though:
<label>
<input type="radio" name="ProductId" value="1"> Item 1
</label>
<label>
<input type="radio" name="ProductId" value="2"> Item 2
</label>
...
Finally, if you need to not instantly submit and you do not want to use radio buttons either, then your only real option is using JavaScript to set a hidden input. You would bind to the click event of your "Select" button or whatever and then set a hidden input with name="ProductId" to the appropriate value. Then, when you finally submit the form, the value of the hidden input will be posted as ProductId.

sj:select tag in struts2-jquery plugin calls the JSON method again when the page gets submitted for a different action

This question is on Struts2 jquery plugin. While loading a JSP be default I am loading one dropdown list values and the second dropdown values are loaded based on selection of first dropdown. When the second dropdown value is selected an onChange event get executed and the page is getting refreshed. When the page is refreshing the First dropdown is getting called again! Is there anyway to avoid the second time execution of default loading of firstdropdown and also need to hold the selected values for both the submitted dropdown values of the JSP?
Note: First dropdown and second dropdowns are evaluated in SampleAction.java and onChange event executes LoadAction.java
Please let me know if you require further details!
Thanks
An option from the first dropdown is selected
Second dropdown is filled accordingly and then a value is selected
Instead of page-refresh, you can submit a form passing the values of both select tags
Now you get the selected values in your action and then you can show the same page but with prefilled values. This time when the page loads, the first select box by default shows the same previously selected value.
For the second select to show the previously selected value, you'll have to write some javascript code which will select the previously selected value.

DropDown default selection

I have an Orbeon Form containing a DropDown Menu. This one is populated (all country names) by an action at Form Load from an SQL Datasource. Both Label and Value are populated.
How to have a default value selected instead of the [Select...] ? In this case, I know the Value of the default item to be selected.
The simplest way to do this is to include the value in the fr-form-instance in the model.
For example:
<xf:instance id="fr-form-instance">
<form>
<section-1>
<country>CHE</country>
</section-1>
</form>
</xf:instance>
There are other ways, as discussed at XForms: set default selection in dropdown in binding
Regards
jez

how to populate values in listbox based on value entered in textbox in BIRT?

I want to populate values in a list box based on a value entered in textbox. It cant be aceived through cascading paramters as all parameters in Cascading parameters are List Boxes. But my requirement is to populate values inside a ListBox based on the value entered inside a textbox. Please help.
Cascading parameter is the only way to define a dependency between two parameters. As you can see, the birt web viewer displays a textbox just below each combobox, and a radio button to select if we fill each list parameter from the combobox or the textbox:
I know some users had exactly the same requirement, and have successfully modified "ComboBoxParametersFragments.jsp" to display only the textbox when it is needed. For example we can use a specific prefix in the parameter name, or a user property, so that we can decide in the JSP if we hide the combobox or not.

Resources