You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Malcolm Edgar (JIRA)" <ji...@apache.org> on 2010/03/04 03:43:27 UTC

[jira] Commented: (CLK-637) FormTable setRowList twice does not display fields correctly

    [ https://issues.apache.org/jira/browse/CLK-637?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12841016#action_12841016 ] 

Malcolm Edgar commented on CLK-637:
-----------------------------------

Hi Huy,

These types of questions you should probably raise on the user@click.apache.org mailing list rather than raising a bug.

Please note with a FormTable you need to set the data before it is processed, please see the IMPORTANT NOTE in the documentation.

http://click.apache.org/docs/extras-api/org/apache/click/extras/control/FormTable.html

Also note your Page#onPost handler will only be called on POST requests not GET requests and has branch based on whether the form is valid. This could also relate to the issues you are observing. 

regards Malcolm Edgar

> FormTable setRowList twice does not display fields correctly
> ------------------------------------------------------------
>
>                 Key: CLK-637
>                 URL: https://issues.apache.org/jira/browse/CLK-637
>             Project: Click
>          Issue Type: Bug
>          Components: extras
>    Affects Versions: 2.1.0
>            Reporter: Huy Do
>
> See following code. onPost, the table does not display the "code" field on the correct row as it's corresponding "description" field.
> This only happens if you setRowList once, then setRowList again in the one request.
> public class TestPage extends Page {
> 	public String msg;
> 	public FormTable table = new FormTable();
> 	public void onInit() {
> 		super.onInit();
> 		table.setSortable(false);
> 		table.setClass(Table.CLASS_SIMPLE);
> 		table.getForm().setButtonAlign(Form.ALIGN_RIGHT);
> 		
> 		table.addColumn(new FieldColumn("selected", "Select", new Checkbox()));
> 		table.addColumn(new Column("description"));
> 		TextField ledgerCodeField = new TextField();
> 		ledgerCodeField.setSize(22);
> 		table.addColumn(new FieldColumn("code", "Code", ledgerCodeField));
> 		table.setRowList(getRowList1());
> 		
> 		table.getForm().add(new Submit("ok", "  OK  "));
> 	}	
> 	
> 	public List getRowList1() {
> 		List data = new ArrayList();
> 		for (int i=0; i<10; i++) {
>     		data.add(new DataRow(false, "Item" + i, "code" + i));
> 		}
> 		return data;
> 	}
> 	
> 	public List getRowList2() {
> 		List data = new ArrayList();
> 		for (int i=0; i<10; i++) {
> 			if (i % 2 == 0) {
>         		data.add(new DataRow(true, "Item" + i, "code" + i));
> 			}
> 		}
> 		for (int i=0; i<10; i++) {
> 			if (i % 2 != 0) {
>         		data.add(new DataRow(false, "Item" + i, "code" + i));
> 			}
> 		}
> 		return data;
> 	}
> 	
> 	
> 	public void onPost() {
> 		boolean valid = true;
> 		if (table.getForm().isValid()) {
> 			table.getRowList().clear();
> 			table.setRowList(getRowList2());
> 		}
> 	}
> }
> public class DataRow {
> 	boolean selected = false;
> 	String description = "";
> 	String code = "";
> 	
> 	public DataRow() {
> 		
> 	}
> 	public DataRow(boolean selected, String description, String code) {
> 		this.selected = selected;
> 		this.description = description;
> 		this.code = code;
> 	}
> 	
> 	public boolean isSelected() {
> 		return selected;
> 	}
> 	public void setSelected(boolean selected) {
> 		this.selected = selected;
> 	}
> 	public String getDescription() {
> 		return description;
> 	}
> 	public void setDescription(String description) {
> 		this.description = description;
> 	}
> 	public String getCode() {
> 		return code;
> 	}
> 	public void setCode(String code) {
> 		this.code = code;
> 	}
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.