1

我有一些代码,由其他人编写。情况是页面上有一个表格,最初只有一行。有一个 Add Row 按钮可以向表中添加一行。直到现在它正在重新绘制整个页面,现在我被分配了Ajax-ify添加行的任务。但是当我按下添加行按钮时,我收到一条消息
Ajax POST stopped because of precondition check, url ....

这是代码:

的HTML:

<div id="tablebg">
                <table class="borderbg"  wicket:id="table"> //this will be the 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 代码:

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);


列表视图:

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 to the WebMarkupContainer


createAjaxButton()方法

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;
}

这里可能有什么问题?谢谢

4

0 回答 0