Yes, you could do it another way. Make each component that you want to
enable/disable like this:
form.add(new xxxFormComponent("id") {
@Override
isEnabled() {
return your logic here;
}
});
2009/7/17 Steve Lowery <[email protected]>:
> I would like to build a simple form whose markup looks like the
> following:
>
>
>
> <wicket:panel>
>
> <form wicket:id="form">
>
> <table>
>
> <thead>
>
> <tr>
>
> <th>[Label]</th>
>
> <th><a
> wicket:id="editLink">[edit]</a></th>
>
> </tr>
>
> </thead>
>
> <tbody>
>
> <tr>
>
> <td>[attr1]</td>
>
> <td><input type="text"
> wicket:id="attr1"/></td>
>
> </tr>
>
> <tr>
>
> <td>[attr2]</td>
>
> <td><input type="text"
> wicket:id="longitude"/></td>
>
> </tr>
>
> </tbody>
>
> <tfoot>
>
> <tr>
>
> <td colspan="2">
>
> <button
> wicket:id="submit">[submit]</button>
>
> <button
> wicket:id="cancel">[cancel]</button>
>
> </td>
>
> </tr>
>
> </tfoot>
>
> </table>
>
> </form>
>
> </wicket:panel>
>
>
>
> I call setEnabled(false) on the Form when it is constructed which makes
> its FormComponents disabled making a "read only" version of the form.
> I'd then like the editLink.onClick() to enable the form, which will
> enable it's components. However, since the editLink is a child of the
> Form which is initially disabled, that link is disabled. I am looking
> for a way to not have the link be disabled eventhough the form it is in
> is disabled. My thought was for that link, I could override
> isEnabledInHierarchy() to just negate the value returned by super (if
> the form is disabled the link is enabled and vice versa), but that
> method is final, so no can do.
>
>
>
> Is anyone aware of another way I could go about doing this? I know I
> could create a wicket component on say the tbody element and have it be
> disabled, but then the link would have to be passed which element(s) it
> needs to enable when clicked and I was hoping to just be able to use the
> hierarchy so I can make the EditLink a reusable component since this is
> a very common use case for us (having read only forms that become
> editable with a click).
>
>
>
> Thanks in advance!
>
> Steve
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]