You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "losdrakanos@gmx.net" <lo...@gmx.net> on 2009/05/23 20:24:22 UTC

AjaxEditableChoiceLabel: display value for Label?

I'm currently trying to use a AjaxEditableChoiceLabel for the first 
time. Everything works fine (displaying dropdown choice editor, 
retrieving/updating business object), except displaying the label value 
when the inplace dropdown choice is inactive. Instead of the selected 
values name it displays the object itself.

AjaxEditableChoiceLabel ajaxEditableLabelUsertype =
   new AjaxEditableChoiceLabel(
     "usertype",
     new PropertyModel(user, "usertype"),
     Manager.getUsertypes(),
     new ChoiceRenderer("name", "id")
   );

Class User has an Attribute of Class UserType which has an id and a 
name. Manager.getUsertypes() returns all available Intances of UserType.

When the Editor is not invoked, the label should display 
user.getUsertype.getName(). Right now it displays user.getUserType(). 
The choices inside the dropdown choice when its invoked are right (the 
names).

What am I doing wrong? Thanks for any help on this.

Roman

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


Re: AjaxEditableChoiceLabel: display value for Label?

Posted by drakanor <lo...@gmx.net>.
After reading and searching some time I found a solution in using a
converter. Is that the right way to do it (seems a bit cumbersome to me)?

AjaxEditableChoiceLabel ajaxEditableLabelUsertype =
   new AjaxEditableChoiceLabel(
     "usertype",
     new PropertyModel(user, "usertype"),
     Manager.getUsertypes(),
     new ChoiceRenderer("name", "id")
   )
  {
    @Override
    public final IConverter getConverter(Class type) {
      return new IConverter() {
        public Object convertToObject(String value, Locale locale) {
          return null;
        }
        public String convertToString(Object value, Locale locale) {
          if (value != null) {
            return ((UserType)value).getName();
          } else {
            return null;
          }
        }
      };
    }
  }

Thanks
Roman
-- 
View this message in context: http://www.nabble.com/AjaxEditableChoiceLabel%3A-display-value-for-Label--tp23687029p23695862.html
Sent from the Wicket - User mailing list archive at Nabble.com.


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