AjaxLink doesn't work for Wicket 1.3.3 ?

2008-04-14 Thread Tomasz Prus
I have AjaxLink which works good in Wicket 1.3.2 but doens't work whe i
change version to 1.3.3.

package pl.mainseek.car.wicket.components;

import java.util.Arrays;
import java.util.List;

import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.StatelessForm;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.spring.injection.annot.SpringBean;

import pl.mainseek.car.dao.CarsDAO;
import pl.mainseek.car.entities.CarModel;
import pl.mainseek.car.entities.CarPart.Condition;
import pl.mainseek.car.wicket.CommonWebPage;
import pl.mainseek.car.wicket.models.SearchCarPartsModel;
import pl.mainseek.car.wicket.pages.AdvertismentsList;
import pl.mainseek.forum.wicket.pages.ForumList;

public class SearchPanel extends Panel {

public static final String FORUM_OPTION = forum;
public static final String ADS_OPTION = ads;

@SpringBean
private CarsDAO carsDAO;

//keys
private static final String ADVANCED_SEARCH_BUTTON_KEY =
advanced.search.button;

//wicket:ids
public static final String SEARCH_FORM = search_form;
public static final String CONDITION = condition;
public static final String CAR_MODEL = carModel;
public static final String CAR_MARK = carMark;
public static final String QUERY = query;
public static final String ADVANCED_SEARCH = advanced_search;
public static final String SEARCH_BUTTON = search_button;
public static final String SEARCH_WHERE = searchWhere;

private final DropDownChoice searchWhereDDC, carMarkDDC, carModelDDC,
conditionDDC;
private final RequiredTextField queryField;

private final String[] searchWhereKeys = new String[] {ADS_OPTION,
FORUM_OPTION};

//model
private SearchCarPartsModel carPartsModel;

public SearchPanel(String id, SearchCarPartsModel model) {
super(id);
this.carPartsModel = model;
final Form searchForm = new StatelessForm(SEARCH_FORM, new
CompoundPropertyModel(carPartsModel)) {
@Override
protected void onSubmit() {
super.onSubmit();
setRedirect(true);
PageParameters pageParameters = new PageParameters();
pageParameters.add(query, carPartsModel.getQuery());
if(carPartsModel.getCarModel() != null) {
pageParameters.add(carModel,
String.valueOf(carPartsModel.getCarModel().getId()));
} else if(carPartsModel.getCarMark() != null) {
pageParameters.add(carMark,
String.valueOf(carPartsModel.getCarMark().getId()));
}
if(carPartsModel.getSearchWhere().equals(ADS_OPTION)) {
if(carPartsModel.getCondition() != null) {
pageParameters.add(condition,
carPartsModel.getCondition().toString().toLowerCase());
}
setResponsePage(AdvertismentsList.class,
pageParameters);
} else
if(carPartsModel.getSearchWhere().equals(FORUM_OPTION)) {
setResponsePage(ForumList.class, pageParameters);
}
}
};
searchForm.setOutputMarkupId(true);
queryField = new RequiredTextField(QUERY);
searchWhereDDC = getSearchWhereDDC(searchForm);
conditionDDC = getConditionDDC(searchForm);
ListCarModel carModels =
carsDAO.getCarModels(carPartsModel.getCarMark());
carModelDDC = getCarModelDDC(carModels);
carMarkDDC = getCarMarkDDC(carModels);
carMarkDDC.setVisible(false);
carModelDDC.setVisible(false);
conditionDDC.setVisible(false);

searchForm.add(queryField);
searchForm.add(searchWhereDDC);
searchForm.add(conditionDDC);
searchForm.add(carMarkDDC);
searchForm.add(carModelDDC);
final AjaxLink advancedSearch = new AjaxLink(ADVANCED_SEARCH) {
@Override public void onClick(AjaxRequestTarget target) {
carMarkDDC.setVisible(!carMarkDDC.isVisible());
carModelDDC.setVisible(!carModelDDC.isVisible());
conditionDDC.setVisible(!carModelDDC.isVisible());
if(carMarkDDC.isVisible()){
carMarkDDC.setChoices(carsDAO.getAllCarMarks());
}
target.addComponent(searchForm);
}
};
searchForm.add(advancedSearch);
searchForm.add(new 

Re: AjaxLink doesn't work for Wicket 1.3.3 ?

2008-04-14 Thread Matej Knopp
Please create a jira issue and attach a page source code that doesn't work.

-Matej

2008/4/14 Tomasz Prus [EMAIL PROTECTED]:
 I have AjaxLink which works good in Wicket 1.3.2 but doens't work whe i
  change version to 1.3.3.

  package pl.mainseek.car.wicket.components;

  import java.util.Arrays;
  import java.util.List;

  import org.apache.wicket.PageParameters;
  import org.apache.wicket.ajax.AjaxRequestTarget;
  import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
  import org.apache.wicket.ajax.markup.html.AjaxLink;
  import org.apache.wicket.markup.html.form.Button;
  import org.apache.wicket.markup.html.form.DropDownChoice;
  import org.apache.wicket.markup.html.form.Form;
  import org.apache.wicket.markup.html.form.IChoiceRenderer;
  import org.apache.wicket.markup.html.form.RequiredTextField;
  import org.apache.wicket.markup.html.form.StatelessForm;
  import org.apache.wicket.markup.html.panel.Panel;
  import org.apache.wicket.model.CompoundPropertyModel;
  import org.apache.wicket.model.Model;
  import org.apache.wicket.spring.injection.annot.SpringBean;

  import pl.mainseek.car.dao.CarsDAO;
  import pl.mainseek.car.entities.CarModel;
  import pl.mainseek.car.entities.CarPart.Condition;
  import pl.mainseek.car.wicket.CommonWebPage;
  import pl.mainseek.car.wicket.models.SearchCarPartsModel;
  import pl.mainseek.car.wicket.pages.AdvertismentsList;
  import pl.mainseek.forum.wicket.pages.ForumList;

  public class SearchPanel extends Panel {

 public static final String FORUM_OPTION = forum;
 public static final String ADS_OPTION = ads;

 @SpringBean
 private CarsDAO carsDAO;

 //keys
 private static final String ADVANCED_SEARCH_BUTTON_KEY =
  advanced.search.button;

 //wicket:ids
 public static final String SEARCH_FORM = search_form;
 public static final String CONDITION = condition;
 public static final String CAR_MODEL = carModel;
 public static final String CAR_MARK = carMark;
 public static final String QUERY = query;
 public static final String ADVANCED_SEARCH = advanced_search;
 public static final String SEARCH_BUTTON = search_button;
 public static final String SEARCH_WHERE = searchWhere;

 private final DropDownChoice searchWhereDDC, carMarkDDC, carModelDDC,
  conditionDDC;
 private final RequiredTextField queryField;

 private final String[] searchWhereKeys = new String[] {ADS_OPTION,
  FORUM_OPTION};

 //model
 private SearchCarPartsModel carPartsModel;

 public SearchPanel(String id, SearchCarPartsModel model) {
 super(id);
 this.carPartsModel = model;
 final Form searchForm = new StatelessForm(SEARCH_FORM, new
  CompoundPropertyModel(carPartsModel)) {
 @Override
 protected void onSubmit() {
 super.onSubmit();
 setRedirect(true);
 PageParameters pageParameters = new PageParameters();
 pageParameters.add(query, carPartsModel.getQuery());
 if(carPartsModel.getCarModel() != null) {
 pageParameters.add(carModel,
  String.valueOf(carPartsModel.getCarModel().getId()));
 } else if(carPartsModel.getCarMark() != null) {
 pageParameters.add(carMark,
  String.valueOf(carPartsModel.getCarMark().getId()));
 }
 if(carPartsModel.getSearchWhere().equals(ADS_OPTION)) {
 if(carPartsModel.getCondition() != null) {
 pageParameters.add(condition,
  carPartsModel.getCondition().toString().toLowerCase());
 }
 setResponsePage(AdvertismentsList.class,
  pageParameters);
 } else
  if(carPartsModel.getSearchWhere().equals(FORUM_OPTION)) {
 setResponsePage(ForumList.class, pageParameters);
 }
 }
 };
 searchForm.setOutputMarkupId(true);
 queryField = new RequiredTextField(QUERY);
 searchWhereDDC = getSearchWhereDDC(searchForm);
 conditionDDC = getConditionDDC(searchForm);
 ListCarModel carModels =
  carsDAO.getCarModels(carPartsModel.getCarMark());
 carModelDDC = getCarModelDDC(carModels);
 carMarkDDC = getCarMarkDDC(carModels);
 carMarkDDC.setVisible(false);
 carModelDDC.setVisible(false);
 conditionDDC.setVisible(false);

 searchForm.add(queryField);
 searchForm.add(searchWhereDDC);
 searchForm.add(conditionDDC);
 searchForm.add(carMarkDDC);
 searchForm.add(carModelDDC);
 final AjaxLink advancedSearch = new AjaxLink(ADVANCED_SEARCH) {
 @Override public void onClick(AjaxRequestTarget target) {
 carMarkDDC.setVisible(!carMarkDDC.isVisible());
 carModelDDC.setVisible(!carModelDDC.isVisible());
 conditionDDC.setVisible(!carModelDDC.isVisible());