Using Dropdowns

Hello all,

I am “trying” to do something which is NOT obvious in CAF.

I want to populate a Dropdown with some values. I got this working using a WSDL and injecting my connector into my canvas. I created a Content Provider for an Option Group and linked that with my dropdown. So far so good!

Next, I wanted to display MULTIPLE values in my dropdown (several columns). So I tried to do “#{output.param1}, #{output.param2}”… and AMAZINGLY it WORKED. So that’s about 50% of what I need to do.

Now I created a Input Text box and added a “Change” event (in my dropdown) to populate the Input Text box
(using CAF.model(’#{caf:cid(“textValue”)}’).element.setValue(CAF.model(this).element.getValue()); ). This also works no problems.

Okay so what is missing??? Obviously I will convert my Input Text box to a Hidden Input. No problems there.

Where I have an issue is that I want to SET the value of #{output.param3} to the “textValue” GUI element.

Basically I want the dropdown to show TEXTUAL representation ("#{output.param1}, #{output.param2}") of my ROWS and an ID version as an async input parameter ("#{output.param3}").

If I have not been clear please reply and I will try to clarify any confusion. This is very important because I need to call an Async command button with an ID and display pretty descriptions in the dropdown…

Many thanks!

I have tried the following (and it does NOT work):

CAF.model(’#{caf:cid(“textValue”)}’).element.setValue(CAF.model(’#{output.param3}’));

Maybe this is ALMOST correct - maybe something to do with the syntax… Somehow I am referring to the model and trying to get param3…

It could have something to do with using #{activePageBean … } but I’m not certain about the SYNTAX.

If you just want the other control to have the same value as the dropdown, you might consider using the “Control / Behaviors / Synchronize Values” control instead of writing custom scripts.

Otherwise, you may want to use the getValue/setValue methods from the CAF model instead of the DOM element so it takes care of some of the details for you.

For example:


var targetModel = CAF.model('#{caf:cid("yourTextInputId")}');
var sourceModel = CAF.model('#{caf:cid("yourDropdownId")}');

targetModel.setValue(sourceModel.getValue());

Thanks for that model “copy” information… It SOLVED my problem.

Here is the complete solution (for reference):

1-Create the dropdown and give it a good ID, like “partnerDropDown1”
2-Create a webservice call using a WSDL
3-Create the Content Provide as a Group List (to populate the dropdown)
4-Bind your DISPLAY Fields/Params to “Label Expression”
5-Bind your ID Field to “Value Expression”

What this does is setup a Nice/Pretty label, like “Last name, First name” and uses internal an ID, like #0001 as Input Data for Submit (still need to understand how to do this step…)

And of course, use Eric’s method of copying the CAF.model data so that the dropdown ID gets populated to a Hidden Input (which will be used with a submit - TBD).