the entire point of disabling the component is that you do not want it to
process submitted input and update its model. you are looking for readonly
behavior rather then disabled i think. why not just set the readonly
attribute on that field.

-igor


On 8/29/07, janders <[EMAIL PROTECTED]> wrote:
>
>
> I posted this on the Databinder forum but no one seems to know of a
> work-around so I thought I'd post it here.
>
> Essentially I have a FocusableTextField that gets set by a DropDownChoice.
> If the choice is not "other" then I setEnabled to false and I place the
> string value of the DropDownChoice into the FocusableTextField. However
> the
> model is not persisted when setEnabled is false.
>
> Here is the code:
>
>             // list of existing emailAddresses
>             final List emailTypeList =
> Arrays.asList(EmailAddress.Type.values());
>             final ListView emailAddresses = new
> PropertyListView("emailAddresses") {
>                 @Override
>                 protected void populateItem(final ListItem item) {
>                     final EmailAddress email = (EmailAddress)
> item.getModelObject();
>                     final FocusableTextField emailLabel = new
> FocusableTextField("label", page);
>                     if (email.getType() != EmailAddress.Type.OTHER)
>                         emailLabel.setEnabled(false);
>                     item.add(emailLabel);
>                     item.add(new DropDownChoice("type", emailTypeList) {
>                         @Override
>                         protected boolean
> wantOnSelectionChangedNotifications() {
>                             return true;
>                         }
>                         @Override
>                         protected void onSelectionChanged(final Object
> newSelection) {
>                             if (newSelection == EmailAddress.Type.OTHER) {
>                                 emailLabel.setEnabled(true);
>                                 emailLabel.requestFocus();
>                             } else {
>
> emailLabel.setModelValue(newSelection.toString());
>                                 emailLabel.setEnabled(false);
>                             }
>                         }
>                     });
>           <snip>
>
> In this email example the dropdown choices are "home", "work", and
> "other".
> If user selects home or work I want the value of the FocusableTextField to
> be home or work and I do not want the user to be able to edit the field.
> That's why I set the field's isEnabled to false. On the other hand, if the
> user selects other, then I set isEnabled to true so that the user can edit
> the field. This works properly (persists the value) because isEnabled is
> true.
>
> Is there a workaround for this problem or can someone recommend a
> different
> approach?
>
> --
> View this message in context:
> http://www.nabble.com/setEnabled%28false%29-on-FocusableTextField-breaks-persistence-tf4351731.html#a12399840
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to