I have egg on my face. After delving into this more deeply, I discovered 
our corporate framework "helpfully" removes disabled buttons before they 
get to the browser. Don't agree with the approach, but it is what it is. 

(slinks away with tail between legs...)




From:   Paul Bors <p...@bors.ws>
To:     <users@wicket.apache.org>
Date:   06/26/2013 11:18 AM
Subject:        RE: Graying Out Disabled Buttons/Controls



Create a quick-start attach it to your e-mail and we'll look it over.
Feel free to use drop box or some other file sharing server.

You're doing something wrong...

~ Thank you,
  Paul Bors

-----Original Message-----
From: Richard W. Adams [mailto:rwada...@up.com] 
Sent: Wednesday, June 26, 2013 11:41 AM
To: users@wicket.apache.org
Subject: RE: Graying Out Disabled Buttons/Controls

Wow. Now it gets even stranger. I modified the code as follows:

public DisabledButtonPage() {

        final Form<?> form = new Form<Object>("myForm");
        add(form);

        final Button enabledButton = new Button("enabled-button");
        boolean visible = enabledButton.isVisibleInHierarchy();
        System.out.printf("Enabled button visible? %s%n", visible ? "Yes" 
: "No");
        System.out.printf("Enabled button's ID: %s%n",
enabledButton.getMarkupId());

        final Button disabledButton = createDisabledButton();
        visible = disabledButton.isVisibleInHierarchy();
        System.out.printf("Disabled button visible? %s%n", visible ? "Yes" 

: "No");
        System.out.printf("Disabled button's ID: %s%n",
disabledButton.getMarkupId());

        form.add(enabledButton);
        form.add(disabledButton);
}
private Button createDisabledButton() {

        final Button button = new Button("disabled-button") ;
        button.setVisibilityAllowed(true);
        button.setVisible(true);
        button.setEnabled(false);
        return button;
}

Strangely, the output says:

Enabled button visible? Yes
Enabled button's ID: id5
Disabled button visible? Yes
Disabled button's ID: id6

But the generated HTML (snippet below) does NOT show the disabled button; 
it
SHOULD be right after the enabled button

<form id="idb" method="post" action="
?wicket:interface=:1:myForm::IFormSubmitListener::"><div
style="width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflo
w:hidden"><input
type="hidden" name="idb_hf_0" id="idb_hf_0" /></div> <button 
value="Enabled
Button" name="enabled-button" id="id5" 
xmlns:wicket="http://wicket.apache.org";>Enabled Button</button>

</form>




From:   Paul Bors <p...@bors.ws>
To:     <users@wicket.apache.org>
Date:   06/26/2013 09:48 AM
Subject:        RE: Graying Out Disabled Buttons/Controls



Button -> FormComponent -> WebMarkupContainer -> WebMarkupContainer ->
MarkupContainer -> Component

Inside Component:
      /**
                  * Gets whether this component and any children are
visible.
                  * <p>
                  * WARNING: this method can be called multiple times 
during
a request. If you override this
                  * method, it is a good idea to keep it cheap in terms of
processing. Alternatively, you can
                  * call {@link #setVisible(boolean)}.
                  * <p>
                  * 
                  * @return True if component and any children are visible
                  */
                 public boolean isVisible()
                 {
                                 return getFlag(FLAG_VISIBLE);
                 }

So calling isVisible() on any component would only report the current 
state
for the visible flag but not that of the parent.
Try calling isVisibleInHierarchy() instead:

      /**
                  * Checks if the component itself and all its parents are
visible.
                  * 
                  * @return true if the component and all its parents are
visible.
                  */
                 public final boolean isVisibleInHierarchy()
                 {
                                 Component parent = getParent();
                                 if (parent != null &&
!parent.isVisibleInHierarchy())
                                 {
                                                 return false;
                                 }
                                 else
                                 {
                                                 return
determineVisibility();
                                 }
                 }

Second, why would you have a button attached to a page directly? Isn't 
that
invalid HTML?
I through all form components should be inside a <form> (even w/o a
wicket:id) otherwise the browser might choke on it...

~ Thank you,
  Paul Bors

-----Original Message-----
From: Richard W. Adams [mailto:rwada...@up.com]
Sent: Wednesday, June 26, 2013 9:42 AM
To: users@wicket.apache.org
Subject: Re: Graying Out Disabled Buttons/Controls

I believe the parent component (the page itself) is visible. My test page 
is
very simple, with only two buttons, one enabled & the other disabled; both
buttons are children of the page itself. However, only the enabled button
appears in the generated HTML. I've tried changing the order of the 
various
method calls in createDisabledButton(), tried overriding
isVisible() with return true, etc. No matter what I do, though, the the
generated HTML does not include the disabled button.

I'm out of ideas. Does this work in a later version of Wicket (after
1.14.17)?
_________________________________

The source HTML (extends a generic page type, whose header/footer display
correctly):

<wicket:extend xmlns:wicket="http://wicket.apache.org";>

<p>This page demonstrates the inability to make disabled buttons visible,
but grayed out.</p>

<button value="Enabled Button" wicket:id="enabled-button"></button>
<button value="Disabled Button" wicket:id="disabled-button"></button>

</wicket:extend>
_________________________________

The source code:
_________________________________

public DisabledButtonPage() {

        add(new Button("enabled-button"));
        add(createDisabledButton());
}
private Button createDisabledButton() {

        final Button button = new Button("disabled-button");
        button.setVisibilityAllowed(true);
        button.setVisible(true);
        button.setEnabled(false);
        return button;
}





From:   Paul Bors <p...@bors.ws>
To:     users@wicket.apache.org
Date:   06/26/2013 08:30 AM
Subject:        Re: Graying Out Disabled Buttons/Controls



You need to make sure all of your component parents are also visible.

Remeber that wicket uses a component tree (you can see it in your
DebugToolbar if you add it to your pages).
The inspector looks something like this:

http://www.wicket-library.com/wicket-examples-6.0.x/spring/wicket/bookmarkab


le/org.apache.wicket.devutils.inspector.InspectorPage;jsessionid=76EE1D9ED70
B7660542E78B4C1333951?0&pageId=0



On Wed, Jun 26, 2013 at 9:16 AM, Richard W. Adams <rwada...@up.com> wrote:

> We tried that (code below), but the button does not appear in the 
> generated HTML. We're using Wicket 1.4.17. Do later versions of Wicket 
> render a grayed out (vice invisible) button?
>
> private Button createDisabledButton() {
>
>         final Button button = new Button("disabled-button");
>         button.setEnabled(false);
>         button.setVisible(true);
>         return button;
> }
>
>
>
>
> From:   Thomas Matthijs <li...@selckin.be>
> To:     users@wicket.apache.org
> Date:   06/26/2013 07:45 AM
> Subject:        Re: Graying Out Disabled Buttons/Controls
>
>
>
> On Wed, Jun 26, 2013 at 2:30 PM, Richard W. Adams <rwada...@up.com>
wrote:
>
> > We have a customer requirement that disabled form buttons be grayed
out
> > rather than Wicket's default behavior of making them invisible. 
> > Google
> has
> > a lot of discussion on the topic, but I didn't see a "best practice"
> > solution. Does Wicket provide a way to gray out buttons (or any form 
> > control, for that matter)?
> >
>
>
> Use setEnabled(false) instead of setVisible()
>
>
>
> **
>
> 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.
**


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




**

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.
**


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




**

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