You wrote: "However, the choices object carries the key instead of the value in the backend."

What do you want written into your object? The key, e.g. "forms.cf37.question8.oneTimeOrMonthly"? Then your first solution should work.

If you want the value in your object's property, e.g. "One time or ongoing payment:", then my suggestion should work.

I'm confused what you're looking for. Can you create a quickstart?

Sven


Am 29.01.2018 um 19:06 schrieb extraquoo:
thanks for replying.
Looks like it still put the value in the choices object.
Maybe I am describing the issue incorrectly.

so if put value in the choices object , construct the DropDownChoice and
override localizeDisplayValues
DropDownChoice<String> selector = new DropDownChoice<String>(fieldName,
choices){

                        private static final long serialVersionUID = 1L;

                        @Override
                        protected boolean localizeDisplayValues() {
                                return true;
                        }
                };

then it wont support i18n when executing below code of AbstractChoice.class

/**
         * Generates and appends html for a single choice into the provided 
buffer
         *
         * @param buffer
         *            Appending string buffer that will have the generated html
appended
         * @param choice
         *            Choice object
         * @param index
         *            The index of this option
         * @param selected
         *            The currently selected string value
         */
        @SuppressWarnings("unchecked")
        protected void appendOptionHtml(AppendingStringBuffer buffer, E choice, 
int
index,
                String selected)
        {
                T objectValue = (T)renderer.getDisplayValue(choice);
                Class<T> objectClass = (Class<T>)(objectValue == null ? null :
objectValue.getClass());

                String displayValue = "";
                if (objectClass != null && objectClass != String.class)
                {
                        final IConverter converter = getConverter(objectClass);

                        displayValue = converter.convertToString(objectValue, 
getLocale());
                }
                else if (objectValue != null)
                {
                        displayValue = objectValue.toString();
                }
                buffer.append("\n<option ");
                if (isSelected(choice, index, selected))
                {
                        buffer.append("selected=\"selected\" ");
                }
                if (isDisabled(choice, index, selected))
                {
                        buffer.append("disabled=\"disabled\" ");
                }
                buffer.append("value=\"");
                buffer.append(Strings.escapeMarkup(renderer.getIdValue(choice, 
index)));
                buffer.append("\">");

                String display = displayValue;
                if (localizeDisplayValues())
                {
                        *display = getLocalizer().getString(displayValue, this, 
displayValue);*
                }
                CharSequence escaped = display;
                if (getEscapeModelStrings())
                {
                        escaped = escapeOptionHtml(display);
                }
                buffer.append(escaped);
                buffer.append("</option>");
        }


the bold line is using getString and here displayValue should be the key not
the value.



--
Sent from: http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to