I don't think I'm doing a good job communicating what I'm trying to do.
The markup looks like this (note there is no attribute readonly for input
field with id="label"):
<select wicket:id="type">
<option>home</option>
<option>work</option>
<option>other</option>
</select>
<input wicket:id="label" type="text" class="label" />
What I want to do is dynamically set or remove the attribute readonly on the
input field (label) depending on the dropdownchoice selection (type). If
the user selects "home" or "work" I want the attribute readonly to be set.
If the user selects "other" I want the attribute to be removed so that the
user can edit label.
The Java code looks like:
final AttributeModifier rot = new AttributeModifier("readonly", true, new
Model("readonly")); // true
if (email.getType() != EmailAddress.Type.OTHER)
emailLabel.add(rot); // <---- this works, by adding the readonly
attribute
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.remove ??????? ; // <----- I can't figure out how
to remove the attribute
emailLabel.requestFocus();
} else {
emailLabel.setModelValue(newSelection.toString());
emailLabel.add(rot);
}
}
});
Because I have wantOnSelectionChangedNotifications() set to true, the user
can select a choice and the label should change accordingly -- i.e., add
attribute readonly or remove it for the selection of "other".
So the problem that I'm having right now is how do I dynamically remove
readonly (once added to the input field) when the user selects "other" from
the dropdownchoice?
- JA
Eelco Hillenius wrote:
>
>> I don't understand. Are you saying that I should use setEnabled(false)
>> or
>> are you saying that I should use:
>>
>> final AttributeModifier rof = new AttributeModifier("readonly", false,
>> new
>> Model("readonly"));
>
> new AttributeModifier("readonly", true, new Model("readonly") {
> public boolean isEnabled(Component c) {
> return shouldTheAttributeBeAdded();
> }
> }
>
> and don't add the attribute in your markup.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/setEnabled%28false%29-on-FocusableTextField-breaks-persistence-tf4351731.html#a12408876
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]