cancel
Showing results for 
Search instead for 
Did you mean: 

Updating field value based on constraint selection

mikepoole
Champ in-the-making
Champ in-the-making
I have a property on my form that has a constraint built from a Java class. I would like to update the value of a second field on the form with a value when the user selects one of the options

IE: my field "CountryCode" has 3 options: "UK", "USA", "GER"

When the user selects one of the options, there should be another field "CountryLabel" that gets updated with "United Kingdom", "United States of America", "Germany" based on the selection

I have all my Java code in place and am confident I can get the correct value based on the selection but I'm unsure as to the approach I need to take. Do I add a listener to my CountryCode field?

HELP!!!!!  :?

Many thanks

Mike
3 REPLIES 3

afaust
Legendary Innovator
Legendary Innovator
Hello,

do you actually need to separate code from label? Why not use a list of value constraint that maps codes to their respective label, having the select field show the label instead of the code to the user.

Otherwise, you would need a JavaScript listener on your code field that updates your label HTML (if changes need to be immediately reflected in the form without a reload).

Regards
Axel

mikepoole
Champ in-the-making
Champ in-the-making
Axel

Many thanks for your reply

I think my example was a little simplistic. I will have several values to retrieve based on the selection the user makes (so selecting the country code will lead me to get name PLUS several other attributes of the country)

Most of the stuff I can find about JavaScript listeners within Alfresco relate to Activit and workflow processes. Are there any good tutorials for adding JS listeners within Alfresco itself (as I think my users will not want a form reload)

Many thanks again

Mike

afaust
Legendary Innovator
Legendary Innovator
Hello Mike,

there is no Alfresco specific form listener concept and no examples that I know off that show how to do this in a structured form. The event mechanism used by Alfresco is provided by YUI and described in their documentation. Depending on the type of control used (i.e. association, text, number, date), the events issues may differ as basically only the low-level, control-internal events are available for additional scripting.

Regards
Axel