I have an AEM site. My front-end content.xml has a select list of different color options to pick from:
<items jcr:primaryType="nt:unstructured">
<colors
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/select"
fieldLabel="Select a Color"
name="./colors">
<items jcr:primaryType="nt:unstructured">
<blue
jcr:primaryType="nt:unstructured"
text="Blue"
value="bl blue"/>
<green
jcr:primaryType="nt:unstructured"
text="Green"
value="gr green"/>....
My model looks something like:
@Model(adaptables=Resource.class)
public class Color{
@Inject @Named("colors") @Optional
private String cssClass ;
@Inject @Named("colors.text") @Optional //This is not working
private String label;
public String getCssClass() {
return cssClass;
}
public String getLabel() {
return label;
}
public void setCssClass(String cssClass) {
this.cssClass = cssClass;
}
public void setLabel(String label) {
this.label = label;
}
}
This code will return the cssClass string as either "bl blue" or "gr green" depending on what the user selected.
My question is how do I get the label string to return "Blue" or "Green" (aka the text attribute of the selected color item)?
Thanks!