wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Bors <p...@bors.ws>
Subject RE: Graying Out Disabled Buttons/Controls
Date Wed, 26 Jun 2013 14:47:38 GMT
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:RWADAMS1@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 <paul@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 <RWADAMS1@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 <lists@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 <RWADAMS1@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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message