Correct method of retrieving a control's ID

Hi,

Which of these two methods is the preferred way of retrieving a control’s ID?

1) "#{caf:cid('defaultForm:htmlInputText21')}"
2) '#{activePageBean.clientIds["defaultForm:htmlInputText21"]}'

In the following example both methods return the same value.

CAF.model('#{caf:cid("defaultForm:htmlInputText21")}').addValueChangeListener(
function(id, oldValue, newValue) {
    alert("changed >>" + id + "\nfrom " + oldValue + "\nTo " + newValue);
    alert("#{caf:cid('defaultForm:htmlInputText21')}");
    alert('#{activePageBean.clientIds["defaultForm:htmlInputText21"]}');
} );

Method 1) is never show in the documentation but works all the time and does not generates a warning on Designer (I suppose Designer does not try to resolve JavaScript functions).

With method 2) most of the time I get an warning in Designer about not being able to resolve activePageBean (after all it is not even on the Implicit Variables in the Bindings Pane) and in most cases, but not all, it works, but it is the only method present in the documentation.

Using 8.2 SP1.

Both methods are valid. The activePageBean is a JSF VariableResolver that provides a shortcut to lookup the active page’s bean. The caf:cid was a new shortcut introduced in 8.0.

Regards,
–mark

Do you know why Designer complains about not being able to resolve the activePageBean object and that it is not possible to use it in the Java code?

Also, is there a place where caf:cid and other shortcuts are documented?

Have a nice weekend.

My first thought is that if you are using an imported view, Designer might not be resolving the correct page bean. If you have a simple sample that demonstrates this problem, i’d love to see it.

Regarding the EL Functions, they are available from the Corporate University class on wM8_CAF_UI_and_Portlet_Development, so if you’ve taken that class you’ll have the documentation for them.

Regards,
–mark

No, it is from a new view created from scratch.

Try to add a com.softwareag.caf.controls.mwsx.PeoplePickerDialog to the form and by default the “Saved Search Provider” property is bound to “#{activePageBean.savedSearchProvider}” which has the yellow alert problem: ‘Invalid expression for property “Saved Search Provider”: [validation.error.for.property.expression.value.unableToResolve]: Unable to resolve: activePageBean.savedSearchProvider’.

On the source view, that object is also not recognised.

Maybe I am missing a library? I have the default JSF as proposed.

What that message is saying is that it can resolve the activePageBean, but it can’t find a savedSearchProvider property in your page bean. The Picker will work without a Saved Search Provider, but if you want your users to be able to save searches, then you’ll need to supply a provider, such as the com.webmethods.caf.faces.search.saved.SimpleSavedSearchProvider

Hope this helps,
–mark

FYI: You can set the “Saved Search Provider” property to “#{null}” if you don’t need saved searches for your use case. That will get rid of the warning.