Thank you for your help! The mapping to my servlet works now!
-- Unfortunately I have an other error now... I tried to use a columnDefintions which are causing errors now. It seems like that I didn't define them correctly. But I really unsure about how to use them correctly.
Does anyone has an idea on how to create my dynamic table without using an extra class for the columnDefinition? My goal is it to get the value of actionName, targetAmount and amountDonationSoFar from my Campaign object which I have in my ArrayList<T>.
The source Code for my table looks like this:
public void setRowData(ArrayList<T> rowData) { this.rowData = rowData; TableElement table = Document.get().createTableElement(); TableSectionElement tbody; table.appendChild(tbody = Document.get().createTBodyElement()); for(int i = 0;i<rowData.size(); ++i) { TableRowElement row = tbody.insertRow(-1); T t = rowData.get(i); for (int j = 0; j < columnDefinitions.size(); ++j) { TableCellElement cell = row.insertCell(-1); StringBuilder sb = new StringBuilder(); columnDefinitions.get(j).render(t, sb); cell.setInnerHTML(sb.toString()); Element child = cell.getFirstChildElement(); if (child != null) { Event.sinkEvents(child, Event.ONFOCUS | Event.ONBLUR); } } } actionTable.setHTML(table.getInnerHTML()); }
And the elements which are in my ArrayList<T> are coming from here:public class ActionServiceImpl extends RemoteServiceServlet implements MyActionService { private static final String[] actionName = new String[] { "Trikots für A-Jugend", "Rollstuhl für Maria" }; private static final double[] targetAmount = new double[] { 1000, 2500 }; private static final double[] donationMinimum = new double[] { 10, 10 }; private static final double[] amountDonationSoFar = new double[] { 258, 742 }; private static final String[] accountName = new String[] { "Max Mustermann", "Maria Musterfrau" }; private static final String[] iban = new String[] { "DE447818032764520919100", "DE4478180328485419100" }; private static final String[] NameOfBank = new String[] { "ABC Bank", "XYZ Bank" }; private final HashMap<String, Campaign> actions = new HashMap<String, Campaign>(); private final HashMap<String, Account> accounts = new HashMap<String, Account>(); public ActionServiceImpl() { initActions(); } private void initActions() { for (int i = 0; i < actionName.length; ++i) { Account account = new Account(accountName[i], NameOfBank[i], iban[i]); Campaign action = new Campaign(String.valueOf(i), actionName[i], targetAmount[i], donationMinimum[i], amountDonationSoFar[i], account); accounts.put(account.getName(), account); actions.put(action.getId(), action); } } @Override public ArrayList<ShowActions> getShowActions() { ArrayList<ShowActions> showActions = new ArrayList<ShowActions>(); Iterator<String> it = actions.keySet().iterator(); while (it.hasNext()) { Campaign action = actions.get(it.next()); showActions.add(action.getActions()); } return showActions; }
My Campaign class looks like this:
@SuppressWarnings("serial")
public class Campaign implements Serializable{
private String name;
private double targetAmount;
private double donationMinimum;
private double amountDonationSoFar;
private Account account;
private String id;
public Campaign() {}
public Campaign(String id, String name, double targetAmount, double donationMinimum, double amountDonationSoFar, Account account) {
this.name = name;
this.targetAmount = targetAmount;
this.donationMinimum = donationMinimum;
this.amountDonationSoFar = amountDonationSoFar;
this.account = account;
this.id = id;
}
public ShowActions getActions() {
return new ShowActions(id, name, targetAmount, amountDonationSoFar);
}
... get and set methods for all attributes
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment