You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Entropy <bl...@gmail.com> on 2014/03/27 16:36:30 UTC
One field enabled in a disabled container
A wierd requirement was just handed to me. We have a form that gets
enabled/disabled depending on business rules as normal. However, now I am
being told to disable ALL BUT TWO fields in a particular state. Is my only
option here to leave the form enabled and then disable EVERY other control
explicitly like:
form.get("A").setEnabled(true);
form.get("B").setEnabled(true);
form.get("C").setEnabled(true);
form.get("D").setEnabled(true);
[...etc]
Or is there a way to disable the container, and spare specific fields? I
suspect I'll have to do the former, but there's quite a few fields and I am
hoping there's some wicket trick.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/One-field-enabled-in-a-disabled-container-tp4665156.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: One field enabled in a disabled container
Posted by Ernesto Reinaldo Barreiro <re...@gmail.com>.
Why not use what Tomas proposed with an IVisitor that visits all form
components and enable/disable them? Look at forms with flair
http://code.google.com/p/londonwicket/downloads/detail?name=LondonWicket-FormsWithFlair.pdf
for inspiration.
On Thu, Mar 27, 2014 at 5:21 PM, Entropy <bl...@gmail.com> wrote:
> Yeah, I considered that. Unfortunately the hierarchy is such that these
> two
> are in the middle and buried a bit in the HTML hierarchy. In a simpler
> situation, that would've worked spendidly.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/One-field-enabled-in-a-disabled-container-tp4665156p4665160.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
--
Regards - Ernesto Reinaldo Barreiro
RE: One field enabled in a disabled container
Posted by Entropy <bl...@gmail.com>.
Yeah, I considered that. Unfortunately the hierarchy is such that these two
are in the middle and buried a bit in the HTML hierarchy. In a simpler
situation, that would've worked spendidly.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/One-field-enabled-in-a-disabled-container-tp4665156p4665160.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
RE: One field enabled in a disabled container
Posted by "Richter, Marvin" <Ma...@jestadigital.com>.
Maybe split this one form in two, one with these 2 fields and one with the rest.
Depending on the state, you enable either all, just the one with the 2 fields or none.
Best,
Marvin Richter
-----Original Message-----
From: Entropy [mailto:blmulholland@gmail.com]
Sent: Thursday, March 27, 2014 4:38 PM
To: users@wicket.apache.org
Subject: One field enabled in a disabled container
A wierd requirement was just handed to me. We have a form that gets enabled/disabled depending on business rules as normal. However, now I am being told to disable ALL BUT TWO fields in a particular state. Is my only option here to leave the form enabled and then disable EVERY other control explicitly like:
form.get("A").setEnabled(true);
form.get("B").setEnabled(true);
form.get("C").setEnabled(true);
form.get("D").setEnabled(true);
[...etc]
Or is there a way to disable the container, and spare specific fields? I suspect I'll have to do the former, but there's quite a few fields and I am hoping there's some wicket trick.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/One-field-enabled-in-a-disabled-container-tp4665156.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
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: One field enabled in a disabled container
Posted by "thomas@jarnot.de" <th...@jarnot.de>.
Before committing to a - as you said wierd requirement - by breaking the form
structure, I'd rather do the setEnabled() - dance but separate it into a
special behavior attached to the form. So you have your requirement
fulfilled while keeping the GUI code clean and readable.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/One-field-enabled-in-a-disabled-container-tp4665156p4665158.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: One field enabled in a disabled container
Posted by niestroj <rn...@go2.pl>.
I do it using a behavior. For Components i want to keep enabled i need to
make fields. Then i pass them to the behavior in the constructor.
public class ComponentEnabledBehavior extends Behavior {
private final Component[] notDisabledComponents;
public ComponentEnabledBehavior (Component... notDisabledComponent) {
notDisabledComponents = notDisabledComponent;
}
public ComponentEnabledBehavior () {
notDisabledComponents = null;
}
@Override
public void onConfigure(Component component) {
super.onConfigure(component);
if (someCondition) {
for (Iterator it = ((WebMarkupContainer) component).iterator();
it.hasNext();) {
Component comp = (Component) (it.next());
comp.setEnabled(ArrayUtils.contains(notDisabledComponents,
comp));
}
}
}
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/One-field-enabled-in-a-disabled-container-tp4665156p4665180.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org