You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@click.apache.org by sa...@apache.org on 2010/12/26 07:40:47 UTC
svn commit: r1052834 - in
/click/trunk/click/examples/src/org/apache/click/examples/page/introduction:
AdvancedForm.java AdvancedTable.java SimpleForm.java
Author: sabob
Date: Sun Dec 26 06:40:46 2010
New Revision: 1052834
URL: http://svn.apache.org/viewvc?rev=1052834&view=rev
Log:
Remove auto binding from examples CLK-742
Modified:
click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedForm.java
click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java
click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleForm.java
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedForm.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedForm.java?rev=1052834&r1=1052833&r2=1052834&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedForm.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedForm.java Sun Dec 26 06:40:46 2010
@@ -37,7 +37,6 @@ import org.apache.click.examples.page.Ho
import org.apache.click.examples.service.CustomerService;
import org.apache.click.extras.control.DateField;
import org.apache.click.extras.control.EmailField;
-import org.apache.click.util.Bindable;
import org.springframework.stereotype.Component;
/**
@@ -48,8 +47,7 @@ public class AdvancedForm extends Border
private static final long serialVersionUID = 1L;
- @Bindable protected Form form = new Form();
- @Bindable protected String msg;
+ private Form form = new Form("form");
private Select investmentSelect = new Select("investments");
@@ -59,6 +57,8 @@ public class AdvancedForm extends Border
// Constructor ------------------------------------------------------------
public AdvancedForm() {
+ addControl(form);
+
FieldSet fieldSet = new FieldSet("Customer");
form.add(fieldSet);
@@ -114,7 +114,8 @@ public class AdvancedForm extends Border
form.clearValues();
- msg = "A new customer record has been created.";
+ String msg = "A new customer record has been created.";
+ addModel("msg", msg);
}
return true;
}
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java?rev=1052834&r1=1052833&r2=1052834&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/introduction/AdvancedTable.java Sun Dec 26 06:40:46 2010
@@ -32,7 +32,6 @@ import org.apache.click.examples.page.Bo
import org.apache.click.examples.page.EditCustomer;
import org.apache.click.examples.service.CustomerService;
import org.apache.click.extras.control.LinkDecorator;
-import org.apache.click.util.Bindable;
import org.apache.click.dataprovider.DataProvider;
/**
@@ -45,9 +44,9 @@ public class AdvancedTable extends Borde
private static final long serialVersionUID = 1L;
- @Bindable protected Table table = new Table();
- @Bindable protected PageLink editLink = new PageLink("Edit", EditCustomer.class);
- @Bindable protected ActionLink deleteLink = new ActionLink("Delete", this, "onDeleteClick");
+ private Table table = new Table("table");
+ private PageLink editLink = new PageLink("Edit", EditCustomer.class);
+ private ActionLink deleteLink = new ActionLink("Delete", this, "onDeleteClick");
/**
* Spring injected CustomerService bean. The service is marked as transient
@@ -59,6 +58,12 @@ public class AdvancedTable extends Borde
// Constructor ------------------------------------------------------------
public AdvancedTable() {
+ // Add controls
+ addControl(table);
+ addControl(editLink);
+ addControl(deleteLink);
+
+ // Setup table
table.setClass(Table.CLASS_ITS);
table.setPageSize(10);
table.setShowBanner(true);
@@ -98,22 +103,9 @@ public class AdvancedTable extends Borde
return getCustomerService().getCustomers();
}
});
- }
-
- // Event Handlers ---------------------------------------------------------
-
- public boolean onDeleteClick() {
- Integer id = deleteLink.getValueInteger();
- getCustomerService().deleteCustomer(id);
- return true;
- }
-
- @Override
- public void onInit() {
- super.onInit();
- // Restore the table sort and paging state from the session
- table.restoreState(getContext());
+ // Below we setup the table to preserve it's state (sorting and paging)
+ // while editing customers
table.getControlLink().setActionListener(new ActionListener() {
@@ -127,6 +119,17 @@ public class AdvancedTable extends Borde
return true;
}
});
+
+ // Restore the table sort and paging state from the session between requests
+ table.restoreState(getContext());
+ }
+
+ // Event Handlers ---------------------------------------------------------
+
+ public boolean onDeleteClick() {
+ Integer id = deleteLink.getValueInteger();
+ getCustomerService().deleteCustomer(id);
+ return true;
}
// Public Methods ---------------------------------------------------------
Modified: click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleForm.java
URL: http://svn.apache.org/viewvc/click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleForm.java?rev=1052834&r1=1052833&r2=1052834&view=diff
==============================================================================
--- click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleForm.java (original)
+++ click/trunk/click/examples/src/org/apache/click/examples/page/introduction/SimpleForm.java Sun Dec 26 06:40:46 2010
@@ -22,7 +22,6 @@ import org.apache.click.control.Form;
import org.apache.click.control.Submit;
import org.apache.click.control.TextField;
import org.apache.click.examples.page.BorderPage;
-import org.apache.click.util.Bindable;
/**
* Provides a simple Form example Page.
@@ -38,12 +37,13 @@ public class SimpleForm extends BorderPa
private static final long serialVersionUID = 1L;
- @Bindable protected Form form = new Form();
- @Bindable protected String msg;
+ private Form form = new Form("form");
// Constructor ------------------------------------------------------------
public SimpleForm() {
+ addControl(form);
+
form.add(new TextField("name", true));
form.add(new Submit("OK"));
@@ -57,7 +57,8 @@ public class SimpleForm extends BorderPa
*/
public boolean onSubmit() {
if (form.isValid()) {
- msg = "Your name is " + form.getFieldValue("name");
+ String msg = "Your name is " + form.getFieldValue("name");
+ addModel("msg", msg);
}
return true;
}