i have got code, written else. situation there table on page, has 1 row. there add row button adds row table. till repainting entire page, have been assigned task ajax-ify addition of rows. when press add row button, message
ajax post stopped because of precondition check, url ....
here code:
the html:
<div id="tablebg"> <table class="borderbg" wicket:id="table"> //this web markup container <tr class="thead"> <th class="stylethleft"></th> <th class="styleth">foo</th> <th class="styleth">bar</th> <th class="styleth">baz</th> </tr> <tr wicket:id="gpoffrow"> <td class="tdstyle_serial_number" wicket:id="sno">1</td> <td class="td_address" id="alpha"><input type="text" wicket:id="address" class="styledinput" /></td> <td class="td_twochars" id="alpha"><select wicket:id="country" class="styledselect"> <option>nl</option> <option>uk</option> </select></td> <td class="td_phone" id="number"><input type="text" wicket:id="telephone" class="styledinput" /></td> </tr> </table> </div>
java code:
public class gpofficepage extends webpage { private static final long serialversionuid = 1l; protected form<void> form; private generalpartner generalpartner; private list<gpoffice> gpofficerows; private webmarkupcontainer wmc=null; private string editornew; public gpofficepage(generalpartner gp, string editornew) { this.generalpartner = gp; this.editornew = editornew; add(new toppanel("toppanel", "general partner offices details")); add(new feedbackpanel("gpofffeedback")); form = new form<void>("gpoffform"); add(form); wmc=new webmarkupcontainer("table"); form.add(commons.createcancelbutton("cancelbutton")); form.add(createsavenextbutton("savenextbutton")); form.add(createajaxbutton("addrowbutton",form,wmc)); form.add(wmc);
list view:
listview<gpoffice> gpo = new listview<gpoffice>("blah", blah) { private static final long serialversionuid = 1l; @override protected void populateitem(listitem<gpoffice> item) { item.setmodel(new compoundpropertymodel<blahblah>(item .getmodel())); item.add(new label("sno", new integer(item.getindex()) .tostring())); textfield<string> addresstf = new textfield<string>("address"); addresstf.setrequired(true); item.add(addresstf); dropdownchoice<country> countrylist = new dropdownchoice<country>( "country", new loadabledetachablemodel<list<country>>() { private static final long serialversionuid = 1l; @override protected list<country> load() { arraylist<country> countries = new arraylist<country>(); country c1 = new country(); c1.setname("inr"); c1.setisocode("inr"); countries.add(c1); country c2 = new country(); c2.setname("inr2"); c2.setisocode("inr2"); countries.add(c2); return countries; } }); item.add(countrylist); textfield<string> telephonetf = new textfield<string>( "telephone"); item.add(telephonetf); } }; wmc.add(gpo);//add webmarkupcontainer
, createajaxbutton() method
private ajaxbutton createajaxbutton(final string id, form<?> form, final webmarkupcontainer wmc){ system.out.println("look here"+" "+ wmc.size()+" "+wmc.getmarkupid()); ajaxbutton ajaxbutton=new ajaxbutton(id){ private static final long serialversionuid = 1l; @override protected void onsubmit(ajaxrequesttarget target, form<?> form){ target.add(wmc); } @override protected void onerror(ajaxrequesttarget target, form<?> form){} }; return ajaxbutton; } what might wrong here ? thanks
Comments
Post a Comment