I guess we're out of luck. Component#canCallListenerInterface() doesn't 
exist in 1.4.x & AbstractLink#isLinkEnabled() is final, so we can't 
override it.

Will have to redesign our form class. Sigh.



From:   Martin Grigorov <mgrigo...@apache.org>
To:     "users@wicket.apache.org" <users@wicket.apache.org>
Date:   12/08/2014 03:55 PM
Subject:        Re: Can't Get IAuthorizationStrategy Working



Hi,

Not certain about 1.4.x but in 6.x if a parent component is disabled then 
all its children are disabled as well. For AbstractLink there is a special 
#isLinkEnabled() method which combined with 
Component#canCallListenerInterface(Method) can make the link enabled even 
if any of its parents is disabled.

Good luck!

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Mon, Dec 8, 2014 at 10:16 PM, Richard W. Adams <rwada...@up.com> wrote:

> We have a use case which requires an enabled link inside a disabled 
form.
> The form being disabled is based on user's security role, but the link
> being enabled depends on the results returned from a separate database
> query. Thus, we might have a disabled form, but an enabled link, or vice
> versa.  Our link class (below) implements IAuthorizationStrategy, but 
for
> some reason, when the parent form is disabled, and the link is enabled,
> the onClick() method is not called.
>
> Can anyone see what we're doing wrong?
>
> We use Wicket 1.4.17 (no option to upgrade due to corporate framework
> constraints).
> ______________________________________________________
>
> package com.uprr.enm.web.track.detail;
>
> import org.apache.wicket.Component;
> import org.apache.wicket.ajax.AjaxRequestTarget;
> import org.apache.wicket.ajax.markup.html.AjaxLink;
> import org.apache.wicket.authorization.Action;
> import org.apache.wicket.authorization.IAuthorizationStrategy;
>
> import com.uprr.eni.commons.util.ApiLog;
> import com.uprr.eni.valid.tracks.TrackAttribute;
> import com.uprr.enm.dao.jdbc.track.history.TrackHistoryReadDAO;
> import com.uprr.enm.web.track.history.HistoryModal;
> import
> 
com.uprr.ui.wicket.components.ajax.listener.RemovePleaseWaitAjaxListener;
> import com.uprr.ui.wicket.components.behavior.PleaseWaitBehavior;
>
>
> 
//-----------------------------------------------------------------------------------------------
> /**
>  * A link to open a track history modal. This class lets us have a 
working
> history link even if
>  * the parent form is disabled.
>  */
> class TrackHistoryLink extends AjaxLink<Object> implements
> IAuthorizationStrategy {
>
> private static final long serialVersionUID = 4693199534296169911L;
>
> private TrackAttribute attribute        ;
> private HistoryModal     modal  ;
> private Integer          track  ;
>
>
> 
//-----------------------------------------------------------------------------------------------
> /**
>  * Constructor.
>  * @param id Markup ID.
>  * @param track Track system number.
>  * @param attribute The track attribute for which history is desired.
>  * @param dao Data access object to provide track history.
>  * @param modal Dialog to display the history data.
>  */
> public TrackHistoryLink(final String id, final Integer track, final
> TrackAttribute attribute,
>         final TrackHistoryReadDAO dao, final HistoryModal modal) {
>
>         super(id);
>         if (dao.historyExists(track, attribute)) {      // If track has
> history records
>                 setEnabled(true);
>                 add(new PleaseWaitBehavior());
>                 this.track              = track;
>                 this.modal              = modal;
>                 this.attribute  = attribute;
>         } else {
>                 setEnabled(false);
>         }
>         ApiLog.debug("%s history link is %s%n", attribute, isEnabled() ?
> "enabled" : "disabled");
> }
>
> 
//-----------------------------------------------------------------------------------------------
> @Override public boolean isActionAuthorized(final Component component,
> final Action action) {
>         return true;
> }
>
> 
//-----------------------------------------------------------------------------------------------
> @Override public <T extends Component> boolean isInstantiationAuthorized
>         (final Class<T> componentClass) {
>         return true;
> }
>
> 
//-----------------------------------------------------------------------------------------------
> @Override public void onClick(final AjaxRequestTarget ajax) {
>         ajax.addListener(RemovePleaseWaitAjaxListener.getInstance());
>         modal.show(track, attribute, ajax);
> }
>
> 
//-----------------------------------------------------------------------------------------------
> }
>
>
> **
>
> This email and any attachments may contain information that is
> confidential and/or privileged for the sole use of the intended 
recipient.
> Any use, review, disclosure, copying, distribution or reliance by 
others,
> and any forwarding of this email or its contents, without the express
> permission of the sender is strictly prohibited by law.  If you are not 
the
> intended recipient, please contact the sender immediately, delete the
> e-mail and destroy all copies.
> **
>



**

This email and any attachments may contain information that is confidential 
and/or privileged for the sole use of the intended recipient.  Any use, review, 
disclosure, copying, distribution or reliance by others, and any forwarding of 
this email or its contents, without the express permission of the sender is 
strictly prohibited by law.  If you are not the intended recipient, please 
contact the sender immediately, delete the e-mail and destroy all copies.
**

Reply via email to