You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jürgen Lind <Ju...@iteratec.de> on 2012/05/09 11:06:52 UTC

Force child component enabled

Hi,

I have a little problem in my application and maybe someone has an idea how to solve it:
I have a complex form that is structured using a custom collapsible AJAX-panel to show/hide
certain parts of the form. Now, if a user does not have the write permission for the form, the
form is disabled and therefore all input elements as well (which is good). However, for
obvious reaons, I would like the collapsible panels to remain enabled. How could I achieve
this? I have already tried to have the ajax-link for the panel to always return true from
isEnabled, but that seems to be overriden by the parent component. Any ideas where to look?

Cheers,

Jürgen


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


Re: Force child component enabled

Posted by Alexander Cherednichenko <le...@gmail.com>.
Hi!

I'd make this case more general -- we have faced the one like this in
non-JS-case.

For instance, there is a Panel which contains a DataTable. Each row of
datatable represents a Document. Each row contains a set of buttons - Edit
Confirm and Download.
When panel is hidden due to security (isVisibleInHierarchy and
authorization strategy) no issues here.

However, in a case when we make the whole panel disabled with the
permissions, everything would be disabled within this panel. It is good for
Edit, Confirm buttons. It is not good for Download button. Requirement and
common sense allow for viewing everything.

I was unable to get this on easily :(

Issue is that Component's both isEnableAllowed (bindings to the auth
strategy) and isEnabledInHierarchy(traversing up component tree) are final.
Thus there is no way to make an 'exception' for certain components. In our
case, if the parent panel is disabled, everything within it would be
disabled, with no exceptions. And we need an exception.

We had to go the hard way of making our own layer of components which
support more flexible enabled/readonly behavior -- extending every single
component. Also, instead of using built-in
MetaDataRoleAuthorizationStrategy which is looped into component's life
cycle we had to bind this behavior in the compat layer component's own
lifecycle (binding to onBeforeRender and modifying isEnabled accordingly).

Maybe there's some better way that we missed?

Using wicket 1.4

Thank you all!
br,
alex.

2012/5/9 Martin Grigorov <mg...@apache.org>

> Hi,
>
> Why don't use plain Javascript for this. It will be faster because it
> wont make roundtrip to the server and wont be disabled as a Wicket
> component ?
>
> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind <Ju...@iteratec.de>
> wrote:
> > Hi,
> >
> > I have a little problem in my application and maybe someone has an idea
> how
> > to solve it:
> > I have a complex form that is structured using a custom collapsible
> > AJAX-panel to show/hide
> > certain parts of the form. Now, if a user does not have the write
> permission
> > for the form, the
> > form is disabled and therefore all input elements as well (which is
> good).
> > However, for
> > obvious reaons, I would like the collapsible panels to remain enabled.
> How
> > could I achieve
> > this? I have already tried to have the ajax-link for the panel to always
> > return true from
> > isEnabled, but that seems to be overriden by the parent component. Any
> ideas
> > where to look?
> >
> > Cheers,
> >
> > Jürgen
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Alexander Cherednichenko

[ the only way out is the way up ]

Re: Force child component enabled

Posted by Jürgen Lind <Ju...@iteratec.de>.
Hi Martin,

I have created a quickstart and filed an issue (WICKET-4551). Thank you for your help.

J.

On 10.05.2012 10:17, Martin Grigorov wrote:
> Hi,
>
> I'd say that it is by design.
> Component#canCallListenerInterface(Method) has been added recently
> because a user wanted its image to be shown in a disabled panel.
> File a ticket with a quickstart with the code from your earlier mail
> and I'll try to find what is the problem.
>
>
> On Thu, May 10, 2012 at 10:16 AM, Jürgen Lind<Ju...@iteratec.de>  wrote:
>> Since no further replies to this issue came up, the question remains whether
>> this is "works as
>> design" or a bug. Should I file an issue on this? And could maybe one of the
>> developers explain
>> why the Component#isEnabledInhierarchy is final? After reading some core
>> code, I would guess that
>> maybe overriding that method could achieve the intended behavior...
>>
>> J.
>>
>>
>> On 09.05.2012 16:36, Jürgen Lind wrote:
>>>
>>> Ok, I stripped down everything to a very basic setup that should work
>>> according to Martins
>>> suggestions and the wicket documentation. Any ideas why
>>> canCallListenerInterface is never called
>>> here?
>>>
>>> J.
>>>
>>> import java.lang.reflect.Method;
>>>
>>> import org.apache.wicket.ajax.AjaxRequestTarget;
>>> import org.apache.wicket.ajax.markup.html.AjaxLink;
>>> import org.apache.wicket.markup.html.WebMarkupContainer;
>>> import org.apache.wicket.markup.html.WebPage;
>>>
>>>
>>> public class SandboxPage extends WebPage {
>>>
>>>     public SandboxPage() {
>>>       WebMarkupContainer container = new WebMarkupContainer("container") {
>>>         @Override
>>>         public boolean isEnabled() {
>>>           return false;
>>>         }
>>>       };
>>>       AjaxLink<Void>    link = new AjaxLink<Void>("link") {
>>>         @Override
>>>         protected boolean isLinkEnabled() {
>>>           System.out.println(".... le");
>>>           return true;
>>>         }
>>>
>>>         @Override
>>>         public boolean canCallListenerInterface(Method method) {
>>>           System.out.println(".... cc");
>>>           return true;
>>>         }
>>>
>>>         @Override
>>>         public boolean isEnabled() {
>>>           System.out.println(".... ie");
>>>           return true;
>>>         }
>>>
>>>         @Override
>>>         public void onClick(AjaxRequestTarget target) {
>>>           System.out.println("clicked...");
>>>         }
>>>       };
>>>
>>>       container.add(link);
>>>       this.add(container);
>>>     }
>>> }
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <html>
>>>       <div wicket:id="container">
>>>         <div wicket:id="link">Click me!</div>
>>>       </div>
>>> </html>
>>>
>>>
>>> On 09.05.2012 14:29, Jürgen Lind wrote:
>>>>
>>>> Hi Martin,
>>>>
>>>> thanks for the hint, unfortunatly, it does not work :-( I've been looking
>>>> through the relevant
>>>> code and the approach seems right, however at some point, the returned
>>>> values seem to be ignored
>>>> and the link is still disabled (i.e. the onclick-handler is not
>>>> rendered)... I will have to
>>>> investigate further...
>>>>
>>>> J.
>>>>
>>>> On 09.05.2012 13:05, Martin Grigorov wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I think it is possible to do that for links.
>>>>> You'll need to override
>>>>> org.apache.wicket.markup.html.link.AbstractLink#isLinkEnabled() and
>>>>> org.apache.wicket.Component#canCallListenerInterface(Method)
>>>>>
>>>>> The first is needed to not render the link as disabled. The second is
>>>>> needed to be able to actually execute the links logic.
>>>>>
>>>>> The second method is added in 1.5.x.
>>>>>
>>>>> On Wed, May 9, 2012 at 1:47 PM, Jürgen Lind<Ju...@iteratec.de>
>>>>>   wrote:
>>>>>>
>>>>>> Hi Martin,
>>>>>>
>>>>>> that was my initial approach. However, I would like the collapsible
>>>>>> panels
>>>>>> to keep their
>>>>>> state between form submits, therefore I would need some sort of
>>>>>> Javascript
>>>>>> state management
>>>>>> or I would simply use ajax links for that purpose. Which is what I
>>>>>> would
>>>>>> prefer... A later
>>>>>> post already mentioned that this wont be too easy, so maybe I will have
>>>>>> to
>>>>>> go back to JS...
>>>>>>
>>>>>> J.
>>>>>>
>>>>>>
>>>>>> On 09.05.2012 11:16, Martin Grigorov wrote:
>>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Why don't use plain Javascript for this. It will be faster because it
>>>>>>> wont make roundtrip to the server and wont be disabled as a Wicket
>>>>>>> component ?
>>>>>>>
>>>>>>> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have a little problem in my application and maybe someone has an
>>>>>>>> idea
>>>>>>>> how
>>>>>>>> to solve it:
>>>>>>>> I have a complex form that is structured using a custom collapsible
>>>>>>>> AJAX-panel to show/hide
>>>>>>>> certain parts of the form. Now, if a user does not have the write
>>>>>>>> permission
>>>>>>>> for the form, the
>>>>>>>> form is disabled and therefore all input elements as well (which is
>>>>>>>> good).
>>>>>>>> However, for
>>>>>>>> obvious reaons, I would like the collapsible panels to remain
>>>>>>>> enabled.
>>>>>>>> How
>>>>>>>> could I achieve
>>>>>>>> this? I have already tried to have the ajax-link for the panel to
>>>>>>>> always
>>>>>>>> return true from
>>>>>>>> isEnabled, but that seems to be overriden by the parent component.
>>>>>>>> Any
>>>>>>>> ideas
>>>>>>>> where to look?
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>>
>>>>>>>> Jürgen
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>> --
>> Mit freundlichen Grüßen,
>>
>> Jürgen Lind
>>
>> --
>> Dr. Jürgen Lind
>> iteratec GmbH                Fon: +49 (0)89 614551-44
>> Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
>> 82008 Unterhaching           Web: www.iteratec.de
>>
>> Sitz und Registergericht der iteratec GmbH: München HRB 113 519
>> Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>


Mit freundlichen Grüßen,

Jürgen Lind

-- 
Dr. Jürgen Lind
iteratec GmbH                Fon: +49 (0)89 614551-44
Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
82008 Unterhaching           Web: www.iteratec.de

Sitz und Registergericht der iteratec GmbH: München HRB 113 519
Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel

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


Re: Force child component enabled

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I'd say that it is by design.
Component#canCallListenerInterface(Method) has been added recently
because a user wanted its image to be shown in a disabled panel.
File a ticket with a quickstart with the code from your earlier mail
and I'll try to find what is the problem.


On Thu, May 10, 2012 at 10:16 AM, Jürgen Lind <Ju...@iteratec.de> wrote:
> Since no further replies to this issue came up, the question remains whether
> this is "works as
> design" or a bug. Should I file an issue on this? And could maybe one of the
> developers explain
> why the Component#isEnabledInhierarchy is final? After reading some core
> code, I would guess that
> maybe overriding that method could achieve the intended behavior...
>
> J.
>
>
> On 09.05.2012 16:36, Jürgen Lind wrote:
>>
>> Ok, I stripped down everything to a very basic setup that should work
>> according to Martins
>> suggestions and the wicket documentation. Any ideas why
>> canCallListenerInterface is never called
>> here?
>>
>> J.
>>
>> import java.lang.reflect.Method;
>>
>> import org.apache.wicket.ajax.AjaxRequestTarget;
>> import org.apache.wicket.ajax.markup.html.AjaxLink;
>> import org.apache.wicket.markup.html.WebMarkupContainer;
>> import org.apache.wicket.markup.html.WebPage;
>>
>>
>> public class SandboxPage extends WebPage {
>>
>>    public SandboxPage() {
>>      WebMarkupContainer container = new WebMarkupContainer("container") {
>>        @Override
>>        public boolean isEnabled() {
>>          return false;
>>        }
>>      };
>>      AjaxLink<Void>  link = new AjaxLink<Void>("link") {
>>        @Override
>>        protected boolean isLinkEnabled() {
>>          System.out.println(".... le");
>>          return true;
>>        }
>>
>>        @Override
>>        public boolean canCallListenerInterface(Method method) {
>>          System.out.println(".... cc");
>>          return true;
>>        }
>>
>>        @Override
>>        public boolean isEnabled() {
>>          System.out.println(".... ie");
>>          return true;
>>        }
>>
>>        @Override
>>        public void onClick(AjaxRequestTarget target) {
>>          System.out.println("clicked...");
>>        }
>>      };
>>
>>      container.add(link);
>>      this.add(container);
>>    }
>> }
>>
>> <?xml version="1.0" encoding="utf-8"?>
>> <html>
>>      <div wicket:id="container">
>>        <div wicket:id="link">Click me!</div>
>>      </div>
>> </html>
>>
>>
>> On 09.05.2012 14:29, Jürgen Lind wrote:
>>>
>>> Hi Martin,
>>>
>>> thanks for the hint, unfortunatly, it does not work :-( I've been looking
>>> through the relevant
>>> code and the approach seems right, however at some point, the returned
>>> values seem to be ignored
>>> and the link is still disabled (i.e. the onclick-handler is not
>>> rendered)... I will have to
>>> investigate further...
>>>
>>> J.
>>>
>>> On 09.05.2012 13:05, Martin Grigorov wrote:
>>>>
>>>> Hi,
>>>>
>>>> I think it is possible to do that for links.
>>>> You'll need to override
>>>> org.apache.wicket.markup.html.link.AbstractLink#isLinkEnabled() and
>>>> org.apache.wicket.Component#canCallListenerInterface(Method)
>>>>
>>>> The first is needed to not render the link as disabled. The second is
>>>> needed to be able to actually execute the links logic.
>>>>
>>>> The second method is added in 1.5.x.
>>>>
>>>> On Wed, May 9, 2012 at 1:47 PM, Jürgen Lind<Ju...@iteratec.de>
>>>>  wrote:
>>>>>
>>>>> Hi Martin,
>>>>>
>>>>> that was my initial approach. However, I would like the collapsible
>>>>> panels
>>>>> to keep their
>>>>> state between form submits, therefore I would need some sort of
>>>>> Javascript
>>>>> state management
>>>>> or I would simply use ajax links for that purpose. Which is what I
>>>>> would
>>>>> prefer... A later
>>>>> post already mentioned that this wont be too easy, so maybe I will have
>>>>> to
>>>>> go back to JS...
>>>>>
>>>>> J.
>>>>>
>>>>>
>>>>> On 09.05.2012 11:16, Martin Grigorov wrote:
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Why don't use plain Javascript for this. It will be faster because it
>>>>>> wont make roundtrip to the server and wont be disabled as a Wicket
>>>>>> component ?
>>>>>>
>>>>>> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>
>>>>>> wrote:
>>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have a little problem in my application and maybe someone has an
>>>>>>> idea
>>>>>>> how
>>>>>>> to solve it:
>>>>>>> I have a complex form that is structured using a custom collapsible
>>>>>>> AJAX-panel to show/hide
>>>>>>> certain parts of the form. Now, if a user does not have the write
>>>>>>> permission
>>>>>>> for the form, the
>>>>>>> form is disabled and therefore all input elements as well (which is
>>>>>>> good).
>>>>>>> However, for
>>>>>>> obvious reaons, I would like the collapsible panels to remain
>>>>>>> enabled.
>>>>>>> How
>>>>>>> could I achieve
>>>>>>> this? I have already tried to have the ajax-link for the panel to
>>>>>>> always
>>>>>>> return true from
>>>>>>> isEnabled, but that seems to be overriden by the parent component.
>>>>>>> Any
>>>>>>> ideas
>>>>>>> where to look?
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Jürgen
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
> --
> Mit freundlichen Grüßen,
>
> Jürgen Lind
>
> --
> Dr. Jürgen Lind
> iteratec GmbH                Fon: +49 (0)89 614551-44
> Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
> 82008 Unterhaching           Web: www.iteratec.de
>
> Sitz und Registergericht der iteratec GmbH: München HRB 113 519
> Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Force child component enabled

Posted by Jürgen Lind <Ju...@iteratec.de>.
Since no further replies to this issue came up, the question remains whether this is "works as
design" or a bug. Should I file an issue on this? And could maybe one of the developers explain
why the Component#isEnabledInhierarchy is final? After reading some core code, I would guess that
maybe overriding that method could achieve the intended behavior...

J.

On 09.05.2012 16:36, Jürgen Lind wrote:
> Ok, I stripped down everything to a very basic setup that should work according to Martins
> suggestions and the wicket documentation. Any ideas why canCallListenerInterface is never called
> here?
>
> J.
>
> import java.lang.reflect.Method;
>
> import org.apache.wicket.ajax.AjaxRequestTarget;
> import org.apache.wicket.ajax.markup.html.AjaxLink;
> import org.apache.wicket.markup.html.WebMarkupContainer;
> import org.apache.wicket.markup.html.WebPage;
>
>
> public class SandboxPage extends WebPage {
>
>     public SandboxPage() {
>       WebMarkupContainer container = new WebMarkupContainer("container") {
>         @Override
>         public boolean isEnabled() {
>           return false;
>         }
>       };
>       AjaxLink<Void>  link = new AjaxLink<Void>("link") {
>         @Override
>         protected boolean isLinkEnabled() {
>           System.out.println(".... le");
>           return true;
>         }
>
>         @Override
>         public boolean canCallListenerInterface(Method method) {
>           System.out.println(".... cc");
>           return true;
>         }
>
>         @Override
>         public boolean isEnabled() {
>           System.out.println(".... ie");
>           return true;
>         }
>
>         @Override
>         public void onClick(AjaxRequestTarget target) {
>           System.out.println("clicked...");
>         }
>       };
>
>       container.add(link);
>       this.add(container);
>     }
> }
>
> <?xml version="1.0" encoding="utf-8"?>
> <html>
>       <div wicket:id="container">
>         <div wicket:id="link">Click me!</div>
>       </div>
> </html>
>
>
> On 09.05.2012 14:29, Jürgen Lind wrote:
>> Hi Martin,
>>
>> thanks for the hint, unfortunatly, it does not work :-( I've been looking through the relevant
>> code and the approach seems right, however at some point, the returned values seem to be ignored
>> and the link is still disabled (i.e. the onclick-handler is not rendered)... I will have to
>> investigate further...
>>
>> J.
>>
>> On 09.05.2012 13:05, Martin Grigorov wrote:
>>> Hi,
>>>
>>> I think it is possible to do that for links.
>>> You'll need to override
>>> org.apache.wicket.markup.html.link.AbstractLink#isLinkEnabled() and
>>> org.apache.wicket.Component#canCallListenerInterface(Method)
>>>
>>> The first is needed to not render the link as disabled. The second is
>>> needed to be able to actually execute the links logic.
>>>
>>> The second method is added in 1.5.x.
>>>
>>> On Wed, May 9, 2012 at 1:47 PM, Jürgen Lind<Ju...@iteratec.de>  wrote:
>>>> Hi Martin,
>>>>
>>>> that was my initial approach. However, I would like the collapsible panels
>>>> to keep their
>>>> state between form submits, therefore I would need some sort of Javascript
>>>> state management
>>>> or I would simply use ajax links for that purpose. Which is what I would
>>>> prefer... A later
>>>> post already mentioned that this wont be too easy, so maybe I will have to
>>>> go back to JS...
>>>>
>>>> J.
>>>>
>>>>
>>>> On 09.05.2012 11:16, Martin Grigorov wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Why don't use plain Javascript for this. It will be faster because it
>>>>> wont make roundtrip to the server and wont be disabled as a Wicket
>>>>> component ?
>>>>>
>>>>> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>
>>>>> wrote:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have a little problem in my application and maybe someone has an idea
>>>>>> how
>>>>>> to solve it:
>>>>>> I have a complex form that is structured using a custom collapsible
>>>>>> AJAX-panel to show/hide
>>>>>> certain parts of the form. Now, if a user does not have the write
>>>>>> permission
>>>>>> for the form, the
>>>>>> form is disabled and therefore all input elements as well (which is
>>>>>> good).
>>>>>> However, for
>>>>>> obvious reaons, I would like the collapsible panels to remain enabled.
>>>>>> How
>>>>>> could I achieve
>>>>>> this? I have already tried to have the ajax-link for the panel to always
>>>>>> return true from
>>>>>> isEnabled, but that seems to be overriden by the parent component. Any
>>>>>> ideas
>>>>>> where to look?
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Jürgen
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>>
>>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


-- 
Mit freundlichen Grüßen,

Jürgen Lind

--
Dr. Jürgen Lind
iteratec GmbH                Fon: +49 (0)89 614551-44
Inselkammerstrasse 4         Fax: +49 (0)89 614551-10
82008 Unterhaching           Web: www.iteratec.de

Sitz und Registergericht der iteratec GmbH: München HRB 113 519
Geschäftsführer: Klaus Eberhardt, Mark Goerke, Inge Hanschke, Ralf Menzel

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


Re: Force child component enabled

Posted by Jürgen Lind <Ju...@iteratec.de>.
Ok, I stripped down everything to a very basic setup that should work according to Martins
suggestions and the wicket documentation. Any ideas why canCallListenerInterface is never called
here?

J.

import java.lang.reflect.Method;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;


public class SandboxPage extends WebPage {

   public SandboxPage() {
     WebMarkupContainer container = new WebMarkupContainer("container") {
       @Override
       public boolean isEnabled() {
         return false;
       }
     };
     AjaxLink<Void> link = new AjaxLink<Void>("link") {
       @Override
       protected boolean isLinkEnabled() {
         System.out.println(".... le");
         return true;
       }

       @Override
       public boolean canCallListenerInterface(Method method) {
         System.out.println(".... cc");
         return true;
       }

       @Override
       public boolean isEnabled() {
         System.out.println(".... ie");
         return true;
       }

       @Override
       public void onClick(AjaxRequestTarget target) {
         System.out.println("clicked...");
       }
     };

     container.add(link);
     this.add(container);
   }
}

<?xml version="1.0" encoding="utf-8"?>
<html>
     <div wicket:id="container">
       <div wicket:id="link">Click me!</div>
     </div>
</html>


On 09.05.2012 14:29, Jürgen Lind wrote:
> Hi Martin,
>
> thanks for the hint, unfortunatly, it does not work :-( I've been looking through the relevant
> code and the approach seems right, however at some point, the returned values seem to be ignored
> and the link is still disabled (i.e. the onclick-handler is not rendered)... I will have to
> investigate further...
>
> J.
>
> On 09.05.2012 13:05, Martin Grigorov wrote:
>> Hi,
>>
>> I think it is possible to do that for links.
>> You'll need to override
>> org.apache.wicket.markup.html.link.AbstractLink#isLinkEnabled() and
>> org.apache.wicket.Component#canCallListenerInterface(Method)
>>
>> The first is needed to not render the link as disabled. The second is
>> needed to be able to actually execute the links logic.
>>
>> The second method is added in 1.5.x.
>>
>> On Wed, May 9, 2012 at 1:47 PM, Jürgen Lind<Ju...@iteratec.de> wrote:
>>> Hi Martin,
>>>
>>> that was my initial approach. However, I would like the collapsible panels
>>> to keep their
>>> state between form submits, therefore I would need some sort of Javascript
>>> state management
>>> or I would simply use ajax links for that purpose. Which is what I would
>>> prefer... A later
>>> post already mentioned that this wont be too easy, so maybe I will have to
>>> go back to JS...
>>>
>>> J.
>>>
>>>
>>> On 09.05.2012 11:16, Martin Grigorov wrote:
>>>>
>>>> Hi,
>>>>
>>>> Why don't use plain Javascript for this. It will be faster because it
>>>> wont make roundtrip to the server and wont be disabled as a Wicket
>>>> component ?
>>>>
>>>> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>
>>>> wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> I have a little problem in my application and maybe someone has an idea
>>>>> how
>>>>> to solve it:
>>>>> I have a complex form that is structured using a custom collapsible
>>>>> AJAX-panel to show/hide
>>>>> certain parts of the form. Now, if a user does not have the write
>>>>> permission
>>>>> for the form, the
>>>>> form is disabled and therefore all input elements as well (which is
>>>>> good).
>>>>> However, for
>>>>> obvious reaons, I would like the collapsible panels to remain enabled.
>>>>> How
>>>>> could I achieve
>>>>> this? I have already tried to have the ajax-link for the panel to always
>>>>> return true from
>>>>> isEnabled, but that seems to be overriden by the parent component. Any
>>>>> ideas
>>>>> where to look?
>>>>>
>>>>> Cheers,
>>>>>
>>>>> Jürgen
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>


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


Re: Force child component enabled

Posted by Jürgen Lind <Ju...@iteratec.de>.
Hi Martin,

thanks for the hint, unfortunatly, it does not work :-( I've been looking through the relevant
code and the approach seems right, however at some point, the returned values seem to be ignored
and the link is still disabled (i.e. the onclick-handler is not rendered)... I will have to
investigate further...

J.

On 09.05.2012 13:05, Martin Grigorov wrote:
> Hi,
>
> I think it is possible to do that for links.
> You'll need to override
> org.apache.wicket.markup.html.link.AbstractLink#isLinkEnabled() and
> org.apache.wicket.Component#canCallListenerInterface(Method)
>
> The first is needed to not render the link as disabled. The second is
> needed to be able to actually execute the links logic.
>
> The second method is added in 1.5.x.
>
> On Wed, May 9, 2012 at 1:47 PM, Jürgen Lind<Ju...@iteratec.de>  wrote:
>> Hi Martin,
>>
>> that was my initial approach. However, I would like the collapsible panels
>> to keep their
>> state between form submits, therefore I would need some sort of Javascript
>> state management
>> or I would simply use ajax links for that purpose. Which is what I would
>> prefer... A later
>> post already mentioned that this wont be too easy, so maybe I will have to
>> go back to JS...
>>
>> J.
>>
>>
>> On 09.05.2012 11:16, Martin Grigorov wrote:
>>>
>>> Hi,
>>>
>>> Why don't use plain Javascript for this. It will be faster because it
>>> wont make roundtrip to the server and wont be disabled as a Wicket
>>> component ?
>>>
>>> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>
>>>   wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a little problem in my application and maybe someone has an idea
>>>> how
>>>> to solve it:
>>>> I have a complex form that is structured using a custom collapsible
>>>> AJAX-panel to show/hide
>>>> certain parts of the form. Now, if a user does not have the write
>>>> permission
>>>> for the form, the
>>>> form is disabled and therefore all input elements as well (which is
>>>> good).
>>>> However, for
>>>> obvious reaons, I would like the collapsible panels to remain enabled.
>>>> How
>>>> could I achieve
>>>> this? I have already tried to have the ajax-link for the panel to always
>>>> return true from
>>>> isEnabled, but that seems to be overriden by the parent component. Any
>>>> ideas
>>>> where to look?
>>>>
>>>> Cheers,
>>>>
>>>> Jürgen
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>


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


Re: Force child component enabled

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

I think it is possible to do that for links.
You'll need to override
org.apache.wicket.markup.html.link.AbstractLink#isLinkEnabled() and
org.apache.wicket.Component#canCallListenerInterface(Method)

The first is needed to not render the link as disabled. The second is
needed to be able to actually execute the links logic.

The second method is added in 1.5.x.

On Wed, May 9, 2012 at 1:47 PM, Jürgen Lind <Ju...@iteratec.de> wrote:
> Hi Martin,
>
> that was my initial approach. However, I would like the collapsible panels
> to keep their
> state between form submits, therefore I would need some sort of Javascript
> state management
> or I would simply use ajax links for that purpose. Which is what I would
> prefer... A later
> post already mentioned that this wont be too easy, so maybe I will have to
> go back to JS...
>
> J.
>
>
> On 09.05.2012 11:16, Martin Grigorov wrote:
>>
>> Hi,
>>
>> Why don't use plain Javascript for this. It will be faster because it
>> wont make roundtrip to the server and wont be disabled as a Wicket
>> component ?
>>
>> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>
>>  wrote:
>>>
>>> Hi,
>>>
>>> I have a little problem in my application and maybe someone has an idea
>>> how
>>> to solve it:
>>> I have a complex form that is structured using a custom collapsible
>>> AJAX-panel to show/hide
>>> certain parts of the form. Now, if a user does not have the write
>>> permission
>>> for the form, the
>>> form is disabled and therefore all input elements as well (which is
>>> good).
>>> However, for
>>> obvious reaons, I would like the collapsible panels to remain enabled.
>>> How
>>> could I achieve
>>> this? I have already tried to have the ajax-link for the panel to always
>>> return true from
>>> isEnabled, but that seems to be overriden by the parent component. Any
>>> ideas
>>> where to look?
>>>
>>> Cheers,
>>>
>>> Jürgen
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Force child component enabled

Posted by Jürgen Lind <Ju...@iteratec.de>.
Hi Martin,

that was my initial approach. However, I would like the collapsible panels to keep their
state between form submits, therefore I would need some sort of Javascript state management
or I would simply use ajax links for that purpose. Which is what I would prefer... A later
post already mentioned that this wont be too easy, so maybe I will have to go back to JS...

J.

On 09.05.2012 11:16, Martin Grigorov wrote:
> Hi,
>
> Why don't use plain Javascript for this. It will be faster because it
> wont make roundtrip to the server and wont be disabled as a Wicket
> component ?
>
> On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind<Ju...@iteratec.de>  wrote:
>> Hi,
>>
>> I have a little problem in my application and maybe someone has an idea how
>> to solve it:
>> I have a complex form that is structured using a custom collapsible
>> AJAX-panel to show/hide
>> certain parts of the form. Now, if a user does not have the write permission
>> for the form, the
>> form is disabled and therefore all input elements as well (which is good).
>> However, for
>> obvious reaons, I would like the collapsible panels to remain enabled. How
>> could I achieve
>> this? I have already tried to have the ajax-link for the panel to always
>> return true from
>> isEnabled, but that seems to be overriden by the parent component. Any ideas
>> where to look?
>>
>> Cheers,
>>
>> Jürgen
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>


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


Re: Force child component enabled

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Why don't use plain Javascript for this. It will be faster because it
wont make roundtrip to the server and wont be disabled as a Wicket
component ?

On Wed, May 9, 2012 at 12:06 PM, Jürgen Lind <Ju...@iteratec.de> wrote:
> Hi,
>
> I have a little problem in my application and maybe someone has an idea how
> to solve it:
> I have a complex form that is structured using a custom collapsible
> AJAX-panel to show/hide
> certain parts of the form. Now, if a user does not have the write permission
> for the form, the
> form is disabled and therefore all input elements as well (which is good).
> However, for
> obvious reaons, I would like the collapsible panels to remain enabled. How
> could I achieve
> this? I have already tried to have the ajax-link for the panel to always
> return true from
> isEnabled, but that seems to be overriden by the parent component. Any ideas
> where to look?
>
> Cheers,
>
> Jürgen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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