You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Martin Marinschek <ma...@gmail.com> on 2004/12/19 02:29:29 UTC

JsSetValue Component

Hi there,

I have created a new component helping with jsValueSetListener Tag
discussed in my last e-mail.

Imagine you want to do a little more in your expression, e.g. you want
to change the value of a "currency" field depending on the selection
of a country in another field.

That should be easy now!

Prepare a map in your backing bean which links country-codes to
currency-codes and use something like the following tag in your jsp
(before the jsValueChangeListener tag):

<x:jsValueSet name="countryCurrenciesMap"
value="#{countryList.countryCurrenciesMap}"/>

where countryList.countryCurrenciesMap references this map.

then prepare your valueChangeListener as follows:

<h:inputText id="sourceElementWhereYouEnterTheCountryCode">
<x:jsValueChangeListener for="text6" expressionValue="$destElem.value
= countryCurrenciesMap[$srcElem.value]" />
</h:inputText>

<%-- destination element where the currency-code will be shown --%>
<h:inputText id="text6" />

regards,

Martin