Hi,

I have a a listview in a form that contains cart items.

Every list view item has quantity textfield and ajaxsubmitlink. Now I want
to add a behavior that enables enter keypress for the textfield.

public abstract class KeyEnterBehavior extends
AjaxFormComponentUpdatingBehavior{

private static final long serialVersionUID = 1L;

public KeyEnterBehavior() {
super("onkeypress");
}

@Override
protected void onComponentTag(ComponentTag tag) {
Component myComponent = getComponent();
if (myComponent.isEnabled() && myComponent.isEnableAllowed()) {
CharSequence handler = generateCallbackScript(new
AppendingStringBuffer("wicketAjaxPost('").append(getCallbackUrl(false)).append("',
wicketSerialize(Wicket.$('"+ getComponent().getMarkupId() + "'))"));
 String event = "if (event.keyCode == 13) {"+ handler.toString() + "}";
 tag.put("onkeypress", event);
}
}
}

quantity.add( new KeyEnterBehavior(){
  private static final long serialVersionUID = 1L;
  @Override
   protected void onUpdate(AjaxRequestTarget target) {
   }
});

in the onUpdate I would like to programmatically click the AjaxSubmitLink.
Any pointers?

Reply via email to