Re: how to connect elements - label and input (checkbox)

2014-10-01 Thread Martin Grigorov
Hi,

Please attach a quickstart that reproduce this in a ticket in JIRA.
Thanks!

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

On Wed, Oct 1, 2014 at 6:49 AM, miguel mig...@thedeanda.com wrote:

 wow this is the strangest thing. i searched for the same thing a year later
 (to the day almost) and again its a silly agree to terms checkbox and
 guess what... wicket 6.17.0 seems to have the same problem...

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4667770.html
 Sent from the Users forum mailing list archive at Nabble.com.

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




Re: how to connect elements - label and input (checkbox)

2014-09-30 Thread miguel
wow this is the strangest thing. i searched for the same thing a year later
(to the day almost) and again its a silly agree to terms checkbox and
guess what... wicket 6.17.0 seems to have the same problem...

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4667770.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: how to connect elements - label and input (checkbox)

2013-10-01 Thread miguel
I found this searching for the same answer and my existing code was:

input type=checkbox wicket:id=acceptTerms/
label wicket:for=acceptTermsI agree to the terms/label

but the output is:

input type=checkbox name=acceptTerms id=acceptTerms5/
label for=acceptTerms5I agree to the terms/label

but sometimes it seems that the id isn't set on the checkbox. I'm still
trying to figure out why. (using 6.10 still)



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4661648.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: how to connect elements - label and input (checkbox)

2013-10-01 Thread miguel
aha! it seems that the first time it renders it doesn't include the id in the
checkbox. when it fails validation, the id appears and the label works as
expected. i'll dig into the code when i get a chance.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4661649.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: how to connect elements - label and input (checkbox)

2012-07-05 Thread yesotaso
I am not exactly sure if it is what you want but I used a decoretor for
labeling task.
public class SimpleDecorator extends Behavior implements
IAjaxRegionMarkupIdProvider{
@Override
public String getAjaxRegionMarkupId(Component component){
// This method is overriden from IAjaxRegionMarkupIdProvider see its
@JavaDoc for details
return component.getMarkupId() + _fd;
}

@Override
public void bind(Component component) {
component.setOutputMarkupId(true);
}

@Override
public void beforeRender(Component component) {
FormComponentlt;? fc = (FormComponentlt;?) component;
Response r = component.getResponse();
String label = (fc.getLabel() != null) ? 
fc.getLabel().getObject()  : null;

if(fc.getParent() instanceof FormComponentlt;?) {
label = null;
}

if (label != null) {
r.write(label for=\quot;quot;);
r.write(fc.getMarkupId());
r.write(quot;\quot;quot;);
if (fc.isValid() == false) {
r.write(quot; class=\quot;error\quot;quot;);
}
r.write(quot;);
r.write(Strings.escapeMarkup(label));
if (fc.isRequired()) {
// You can put a * or something else if field is required
}
r.write(lt;/label);
}
super.beforeRender(component);
}
@Override
public void afterRender(Component component) {
Response r = component.getResponse();
r.write(lt;/div);
}

@Override
public void onComponentTag(Component component, ComponentTag tag) {
// If you want to put some css stuff etc for more striking invalid
visuals...
FormComponentlt;? fc = (FormComponentlt;?) component;
if (fc.isValid() == false) {
String cl = tag.getAttribute(class);
if (cl == null) {
tag.put(class, error);
} else {
tag.put(class, error  + cl);
}
}
}
}

And usage is 
... add(new TextField(someId).setLabel(Model.of(I'm a label)).add(new
SimpleDecorator()))

I believe this is from _Wicket Cookbook_ or _Wicket In Action_ I cant
recall. For checkbox etc you can omit invalid input etc... but idea is the
same.
You can also omit adding behavior and add it later via visitor. I hope it
helps.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4650386.html
Sent from the Users forum mailing list archive at Nabble.com.

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



how to connect elements - label and input (checkbox)

2012-06-30 Thread Dan12321
Hi,
is there any easy way, how can I connect label and input(checkbox) in
repeater?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: how to connect elements - label and input (checkbox)

2012-06-30 Thread Andrea Del Bene

Hi,

what do you mean exactly with connect the two component?

Hi,
is there any easy way, how can I connect label and input(checkbox) in
repeater?



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304.html
Sent from the Users forum mailing list archive at Nabble.com.

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





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



Re: how to connect elements - label and input (checkbox)

2012-06-30 Thread Dan12321
Hi,
when I click on text in  element, it select or unselect checkbox. But I need
to set attribute for in label and attribute id in checkbox input.
I use it in repeater. So I have to generate random text for this attributes.
Is there any better way how to do it?

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4650308.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: how to connect elements - label and input (checkbox)

2012-06-30 Thread Dan Retzlaff
The easiest way is probably to use a wicket:for attribute:
label wicket:for=enabledCheckEnabled/label
input type=checkbox wicket:id=enabledCheck/

Alternatively, you can also use FormComponent#setLabel(IModelString) in
Java to define an input's label value, then show that label by adding
(Simple)FormComponentLabel as a separate component (i.e. with its own
wicket:id).

On Sat, Jun 30, 2012 at 9:13 AM, Dan12321 wee...@centrum.cz wrote:

 Hi,
 when I click on text in  element, it select or unselect checkbox. But I
 need
 to set attribute for in label and attribute id in checkbox input.
 I use it in repeater. So I have to generate random text for this
 attributes.
 Is there any better way how to do it?

 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/how-to-connect-elements-label-and-input-checkbox-tp4650304p4650308.html
 Sent from the Users forum mailing list archive at Nabble.com.

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