Guest User

Untitled

a guest
Nov 20th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. package hoge.page;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7.  
  8. import org.apache.click.control.ActionLink;
  9. import org.apache.click.control.Column;
  10. import org.apache.click.control.Table;
  11. import org.apache.click.dataprovider.DataProvider;
  12. import org.seasar.s2click.S2ClickPage;
  13. import org.seasar.s2click.control.AjaxLink;
  14. import org.seasar.s2click.util.AjaxUtils;
  15.  
  16. public class AjaxLinkInTablePage extends S2ClickPage {
  17.  
  18. public Table table = new Table() {
  19.  
  20. @Override
  21. public ActionLink getControlLink() {
  22. if (controlLink == null) {
  23. AjaxLink al = new AjaxLink(AjaxLinkInTablePage.this,
  24. "onPageMove");
  25. al.addAjaxHandler(AjaxUtils.ON_COMPLETE, "movePageComplete");
  26. controlLink = al;
  27. }
  28. return controlLink;
  29. }
  30. };
  31.  
  32. public AjaxLinkInTablePage() {
  33. table.setClass(Table.CLASS_BLUE1);
  34. table.setPageSize(20);
  35. table.addColumn(new Column("id"));
  36. table.addColumn(new Column("name"));
  37. table.setDataProvider(new DataProvider<Map<String, String>>() {
  38.  
  39. public Iterable<Map<String, String>> getData() {
  40. List<Map<String, String>> data = new ArrayList<Map<String, String>>();
  41. for (int i = 0; i < 100; i++) {
  42. Map<String, String> entry = new HashMap<String, String>();
  43. Integer id = i + 1;
  44. entry.put("id", id.toString());
  45. entry.put("name", "name" + id);
  46. data.add(entry);
  47. }
  48. return data;
  49. }
  50.  
  51. });
  52. }
  53.  
  54. public boolean onPageMove() {
  55. Map<String, Object> jsonObj = new HashMap<String, Object>();
  56. jsonObj.put("tab", table.toString());
  57. renderJSON(jsonObj);
  58. return false;
  59. }
  60. }
Add Comment
Please, Sign In to add comment