Hi again, I tried the quick start application and tracked down the issue to this. When a selection is changed (using FireBug/Chrome),
* in the quick start application, I see that of the request is Content-Type: application/x-www-form-urlencoded; charset=UTF-8 * in my application, I see that the content-type of the request is text/plain This is why in my application, the request POST data is actually ignored. I verified that all my HTML files start with <!DOCTYPE html> <html xmlns:wicket="http://wicket.apache.org"> So, can you please let me know how to fix this? Thanks, Behrooz On Thu, Jan 3, 2013 at 5:42 PM, Behrooz Nobakht <nob...@gmail.com> wrote: > Hi, > > I've also tested without the prefix input name and it's still the same. > > Thanks, > Behrooz > > > > On Thu, Jan 3, 2013 at 9:08 AM, Martin Grigorov <mgrigo...@apache.org>wrote: > >> Hi, >> >> If you are able to reproduce the problem in a quickstart application then >> please attach it to a ticket in Jira. >> But I guess the problem is related to the custom prefix you use (# >> getInputNamePrefix()). >> In FormComponent#getInputAsArray() check what is the inputName and compare >> it against the ones shown by Firebug. >> >> >> On Thu, Jan 3, 2013 at 1:56 AM, Behrooz Nobakht <nob...@gmail.com> wrote: >> >> > Hello, >> > >> > I'm trying to have a simple widget in Apache Wicket 6.4.0 using >> > Form< >> > >> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/form/Form.html >> > > >> > , DropDownChoice< >> > >> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/markup/html/form/DropDownChoice.html >> > > >> > ,AjaxButton< >> > >> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/markup/html/form/AjaxButton.html >> > > >> > along >> > with AjaxFormComponentUpdatingBehavior< >> > >> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/ajax/form/AjaxFormComponentUpdatingBehavior.html >> > > >> > . >> > >> > The model (an inner class) that is used is as follows: >> > >> > private class SampleModel implements IClusterable { >> > >> > private static final long serialVersionUID = 1L; >> > >> > private String value; >> > >> > public void setValue(String value) { >> > this.value = value; >> > } >> > >> > public String getValue() { >> > return value; >> > } >> > >> > @Override >> > public int hashCode() { >> > return value.hashCode(); >> > } >> > >> > @Override >> > public boolean equals(Object obj) { >> > if (obj == null) { >> > return false; >> > } >> > if (obj == this) { >> > return true; >> > } >> > if (obj instanceof SampleModel == false) { >> > return false; >> > } >> > return hashCode() == obj.hashCode(); >> > } >> > } >> > >> > >> > The form is another class as: >> > >> > private class TheForm extends Form<SampleModel> { >> > >> > private static final long serialVersionUID = 1L; >> > >> > // This form is to be used several times in a single large page >> > private final String prefix = "form_" + (counter++) + "_"; >> > >> > public TheForm(String id, SampleModel model) { >> > super(id, new CompoundPropertyModel<>(model)); >> > List<String> choices = getChoices(); >> > final DropDownChoice<String> select = new >> > DropDownChoice<String>("value", choices); >> > select.setOutputMarkupId(true); >> > select.add(new AjaxFormComponentUpdatingBehavior("onchange") { >> > >> > private static final long serialVersionUID = 1L; >> > >> > @Override >> > protected void onUpdate(AjaxRequestTarget target) { >> > String m1 = select.getModelObject(); >> > String m2 = TheForm.this.getModelObject().getValue(); >> > System.out.println(m1 + " ===== " + m2); >> > } >> > >> > }); >> > >> > AjaxButton action1 = new AjaxButton("action", Model.of("Ajax >> > Action")) { >> > >> > private static final long serialVersionUID = 1L; >> > >> > @Override >> > protected void onSubmit(AjaxRequestTarget target, Form<?> >> > form) { >> > String m1 = select.getModelObject(); >> > String m2 = TheForm.this.getModelObject().getValue(); >> > System.out.println(m1 + " ===== " + m2); >> > } >> > >> > }; >> > action1.setOutputMarkupId(true); >> > >> > add(select); >> > add(action1); >> > } >> > >> > @Override >> > protected String getInputNamePrefix() { >> > return prefix; >> > } >> > } >> > >> > >> > And putting it all together in a simple widget class: >> > >> > public class SampleFormDropDownWidget extends Panel { >> > >> > private static final long serialVersionUID = 1L; >> > >> > private static int counter = 1; >> > >> > private SampleModel model = new SampleModel(); >> > >> > public SampleFormDropDownWidget(String id) { >> > super(id); >> > model.setValue("C"); >> > TheForm form = new TheForm("form", model); >> > add(form); >> > } >> > >> > private List<String> getChoices() { >> > return Lists.newArrayList("A", "B", "C", "D", "E", "F", "G"); >> > }} >> > >> > >> > And the markup HTML is: >> > >> > <wicket:panel> >> > <form class="form-horizontal" wicket:id="form"> >> > <div class="control-group"> >> > <label class="control-label">Choices</label> >> > <div class="controls"> >> > <select class="input-xlarge" wicket:id="value"></select> >> > </div> >> > </div> >> > <div class="form-actions"> >> > <input class="btn" wicket:id="action" /> >> > </div> >> > </form></wicket:panel> >> > >> > >> > Using a client debugging tool such as FireBug, I can trace that the AJAX >> > request actually carries POST data, e.g.: >> > >> > >> > >> form_1_formb1_hf_0=&form_1_value=5&form_1_action=Ajax+Action&form_1_action=1 >> > >> > However, in both cases of onUpdate for the select component and >> onSubmit >> > for >> > the button, I getnull values. Additionally, I debugged the code until >> > Wicket's FormComponent#getInputAsArray()and there actually I can see >> that >> > >> > >> RequestCycle.getRequest().getRequestParameters().getParameterValues(VALUE_SELECT)does >> > not find any data on the request parameters. >> > >> > Is there a chance that this could be bug in Wicket to ignore AJAX >> request >> > payload? Or, what am I doing wrong? Thanks. >> > >> > Thanks, >> > -- Behrooz Nobakht >> > >> >> >> >> -- >> Martin Grigorov >> jWeekend >> Training, Consulting, Development >> http://jWeekend.com <http://jweekend.com/> >> > > > > -- > -- Behrooz Nobakht > -- -- Behrooz Nobakht