<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<h2>form</h2>
<form wicket:id="form">
<div wicket:id="lbl"></div>
<input wicket:id="searchH" type="text" />
<input type="submit" name="Ara" value="Ara" />
</form>
<br />
<a href="#" wicket:id="link">TEXT TO REPLACE</a>
</body>
</html>
import java.io.Serializable;
public class Musteri implements Serializable{
public String searchH;
public String getSearchH() {
return searchH;
}
public void setSearchH(String searchH) {
this.searchH = searchH;
}
}
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
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.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.PropertyModel;
public class HomeData extends WebPage
{
private static final long serialVersionUID = 1L;
private Musteri musteri = new Musteri();
public <T> HomeData() {
//Butona tıklanınca çalışır
Form<Musteri> frm = new Form<Musteri>("form", new CompoundPropertyModel<Musteri>(musteri)) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit() {
System.out.println("on submit "+musteri.getSearchH());
}
};
final Label label = new Label("lbl", new PropertyModel<String>(musteri, "searchH"));
label.setOutputMarkupId(true);
frm.add(label);
// TextField onkeyup özelliğine göre çalışır
frm.add(new TextField<String>("searchH").add(new AjaxFormComponentUpdatingBehavior("onkeyup"){
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
target.addComponent(label);
System.out.println(musteri.getSearchH());
}
}));
//Link popup olarak açılır
add(new AjaxLink("link"){
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
target.appendJavascript("window.open('http://www.javamakale.com/')");
}
});
add(frm);
}
}
Hiç yorum yok:
Yorum Gönder