I'm struggling with CheckBoxes not holding their state after calling
target.addComponent.
I've got a repeating view filling out a table. Each row has text fields and
checkboxes. An ajax modal window pops up over that table to edit the row
data, but after ok-ing the modal window, the check boxes in the table always
get turned off. Even if I have a checkbox bound to the constant "true", it
will be turned off.
Strange thing is, on the same row I can bind the boolean to a span/Label,
and the span/Label works fine.
This only happens when the table is inside of a form. If outside of a form,
things are fine.
Here's the code:
<form wicket:id="form">
<table>
<tr wicket:id="table">
<td><input type="checkbox" wicket:id="cbTrue"></input></td>
<td><input type="checkbox" wicket:id="cb"></input></td>
<td></td>
<td> modal <div wicket:id="modalWindow"></div></td>
</tr>
</table>
</form>
<script id="source" language="javascript" type="text/javascript">
$j(document).ready(function() {Wicket.Window.unloadConfirmation = false;})
</script>
public class AboutPage extends BasePage {
class Stuff {
public boolean bool;
public Stuff(boolean b){bool=b;}
}
public AboutPage(final PageParameters parameters) {
super(parameters);
this.setOutputMarkupId(true);
add( new TestForm("form") );
//bindTable(this,this); //works
}
class TestForm extends Form<Stuff> {
public TestForm(String name) {
super(name);
this.setOutputMarkupId(true);
bindTable(this,this); //doesnt work
}
}
public void bindTable( final Component c, MarkupContainer mc ) {
List<Stuff> stuff = new ArrayList<Stuff>();
stuff.add( new Stuff(true) ); stuff.add( new Stuff(true) );
final RepeatingView repeatingView = new RepeatingView("table");
mc.add( repeatingView );
WebMarkupContainer markupContainer = null;
for( Stuff s : stuff ) {
markupContainer = new WebMarkupContainer(
repeatingView.newChildId(),
new
CompoundPropertyModel<Stuff>(s));
repeatingView.add(markupContainer);
markupContainer.add( new CheckBox("cbTrue", new
Model<Boolean>(new Boolean(true)) ) );
markupContainer.add( new CheckBox("cb" , new
PropertyModel<Boolean>(s,"bool")) );
markupContainer.add( new Label("cbVal" , new
PropertyModel<Boolean>(s,"bool")) );
final ModalWindow modalWindow
= new ChartItemEditModal("modalWindow") {
void onOk(AjaxRequestTarget target) {
target.addComponent(c);
close(target);
}
void onCancel(AjaxRequestTarget target) {
close(target);
}
};
markupContainer.add(modalWindow);
AjaxLink lnk = new AjaxLink("lnk"){
@Override
public void onClick(AjaxRequestTarget arg0) {
modalWindow.show(arg0);
}
};
markupContainer.add(lnk);
}
}
}
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/CheckBoxes-cleared-by-Modal-popup-tp3035463p3035463.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
|