Re: Events from SelectionCell in CellTable - GWT 2.1 M1
Can you please provide an example of how to do cell selection using setFieldUpdater? Thanks, Ted On Jun 28, 10:42 am, saklig d3andr...@gmail.com wrote: The setFieldUpdater proved to be a better solution, thanks :-) For some reason InternetExplorer does not send change events when changing the value of the selectionCell. Is this a known bug in GWT 2.1 M1 ? On Jun 27, 2:59 pm, Paul Stockley pstockl...@gmail.com wrote: use the setFieldUpdater(fieldUpdater) on the Column class On Jun 27, 6:28 am, saklig d3andr...@gmail.com wrote: Which class has the addValueUpdateHandler ? On Jun 25, 4:08 pm, Paul Stockley pstockl...@gmail.com wrote: Can't you just add a ValueUpdater handler to see when the selection changes? On Jun 25, 4:27 am, saklig d3andr...@gmail.com wrote: After a couple of tries Ive managed to write something that gets the job done. My example: ListString opts = new ArrayListString(); opts.add(Enabled); opts.add(Disabled); table.addColumn(new IdentityColumnMyData(new ActiveSelectionCell(opts)), Active); private class ActiveSelectionCell implements CellMyData{ private HashMapString, Integer indexForOption = new HashMapString, Integer(); private final ListString options; public ActiveSelectionCell(ListString options) { this.options = new ArrayListString(options); int index = 0; for (String option : options) { indexForOption.put(option, index++); } } @Override public boolean consumesEvents() { return false; } @Override public boolean dependsOnSelection() { return false; } private int getSelectedIndex(String value) { Integer index = indexForOption.get(value); if (index == null) { return -1; } return index.intValue(); } @Override public void setValue(Element parent, MyData value, Object viewData) { StringBuilder sb = new StringBuilder(); render(value, viewData, sb); parent.setInnerHTML(sb.toString()); } @Override public Object onBrowserEvent(Element parent, MyData value, Object viewData, NativeEvent event, ValueUpdaterMyData valueUpdater) { String type = event.getType(); if (change.equals(type)) { SelectElement select = parent.getFirstChild().cast(); if( options.get(select.getSelectedIndex()).equalsIgnoreCase(Enabled)) value.setActive(1); else value.setActive(0); System.out.println(value.getName() + - + options.get(select.getSelectedIndex())); // valueUpdater.update(value); } return viewData; } @Override public void render(MyData value, Object viewData, StringBuilder sb) { int selectedIndex = 0; if(value.getActive().equalsIgnoreCase(1)){ selectedIndex = getSelectedIndex(Enabled); }else{ selectedIndex = getSelectedIndex(Disabled); } sb.append(select); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(option selected='selected'); } else { sb.append(option); } sb.append(option); sb.append(/option); } sb.append(/select); } } If you think this was the wrong/not the best way to get an event from a cell, pleas give me a comment. On Jun 22, 1:25 pm, saklig d3andr...@gmail.com wrote: Hi, How does one handle events from cells in aCellTable( specifically a SelectionCell ) ? -- You received this
Re: Events from SelectionCell in CellTable - GWT 2.1 M1
The setFieldUpdater proved to be a better solution, thanks :-) For some reason InternetExplorer does not send change events when changing the value of the selectionCell. Is this a known bug in GWT 2.1 M1 ? On Jun 27, 2:59 pm, Paul Stockley pstockl...@gmail.com wrote: use the setFieldUpdater(fieldUpdater) on the Column class On Jun 27, 6:28 am, saklig d3andr...@gmail.com wrote: Which class has the addValueUpdateHandler ? On Jun 25, 4:08 pm, Paul Stockley pstockl...@gmail.com wrote: Can't you just add a ValueUpdater handler to see when the selection changes? On Jun 25, 4:27 am, saklig d3andr...@gmail.com wrote: After a couple of tries Ive managed to write something that gets the job done. My example: ListString opts = new ArrayListString(); opts.add(Enabled); opts.add(Disabled); table.addColumn(new IdentityColumnMyData(new ActiveSelectionCell(opts)), Active); private class ActiveSelectionCell implements CellMyData{ private HashMapString, Integer indexForOption = new HashMapString, Integer(); private final ListString options; public ActiveSelectionCell(ListString options) { this.options = new ArrayListString(options); int index = 0; for (String option : options) { indexForOption.put(option, index++); } } @Override public boolean consumesEvents() { return false; } @Override public boolean dependsOnSelection() { return false; } private int getSelectedIndex(String value) { Integer index = indexForOption.get(value); if (index == null) { return -1; } return index.intValue(); } @Override public void setValue(Element parent, MyData value, Object viewData) { StringBuilder sb = new StringBuilder(); render(value, viewData, sb); parent.setInnerHTML(sb.toString()); } @Override public Object onBrowserEvent(Element parent, MyData value, Object viewData, NativeEvent event, ValueUpdaterMyData valueUpdater) { String type = event.getType(); if (change.equals(type)) { SelectElement select = parent.getFirstChild().cast(); if( options.get(select.getSelectedIndex()).equalsIgnoreCase(Enabled)) value.setActive(1); else value.setActive(0); System.out.println(value.getName() + - + options.get(select.getSelectedIndex())); // valueUpdater.update(value); } return viewData; } @Override public void render(MyData value, Object viewData, StringBuilder sb) { int selectedIndex = 0; if(value.getActive().equalsIgnoreCase(1)){ selectedIndex = getSelectedIndex(Enabled); }else{ selectedIndex = getSelectedIndex(Disabled); } sb.append(select); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(option selected='selected'); } else { sb.append(option); } sb.append(option); sb.append(/option); } sb.append(/select); } } If you think this was the wrong/not the best way to get an event from a cell, pleas give me a comment. On Jun 22, 1:25 pm, saklig d3andr...@gmail.com wrote: Hi, How does one handle events from cells in a CellTable( specifically a SelectionCell ) ? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more
Re: Events from SelectionCell in CellTable - GWT 2.1 M1
Which class has the addValueUpdateHandler ? On Jun 25, 4:08 pm, Paul Stockley pstockl...@gmail.com wrote: Can't you just add a ValueUpdater handler to see when the selection changes? On Jun 25, 4:27 am, saklig d3andr...@gmail.com wrote: After a couple of tries Ive managed to write something that gets the job done. My example: ListString opts = new ArrayListString(); opts.add(Enabled); opts.add(Disabled); table.addColumn(new IdentityColumnMyData(new ActiveSelectionCell(opts)), Active); private class ActiveSelectionCell implements CellMyData{ private HashMapString, Integer indexForOption = new HashMapString, Integer(); private final ListString options; public ActiveSelectionCell(ListString options) { this.options = new ArrayListString(options); int index = 0; for (String option : options) { indexForOption.put(option, index++); } } @Override public boolean consumesEvents() { return false; } @Override public boolean dependsOnSelection() { return false; } private int getSelectedIndex(String value) { Integer index = indexForOption.get(value); if (index == null) { return -1; } return index.intValue(); } @Override public void setValue(Element parent, MyData value, Object viewData) { StringBuilder sb = new StringBuilder(); render(value, viewData, sb); parent.setInnerHTML(sb.toString()); } @Override public Object onBrowserEvent(Element parent, MyData value, Object viewData, NativeEvent event, ValueUpdaterMyData valueUpdater) { String type = event.getType(); if (change.equals(type)) { SelectElement select = parent.getFirstChild().cast(); if( options.get(select.getSelectedIndex()).equalsIgnoreCase(Enabled)) value.setActive(1); else value.setActive(0); System.out.println(value.getName() + - + options.get(select.getSelectedIndex())); // valueUpdater.update(value); } return viewData; } @Override public void render(MyData value, Object viewData, StringBuilder sb) { int selectedIndex = 0; if(value.getActive().equalsIgnoreCase(1)){ selectedIndex = getSelectedIndex(Enabled); }else{ selectedIndex = getSelectedIndex(Disabled); } sb.append(select); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(option selected='selected'); } else { sb.append(option); } sb.append(option); sb.append(/option); } sb.append(/select); } } If you think this was the wrong/not the best way to get an event from a cell, pleas give me a comment. On Jun 22, 1:25 pm, saklig d3andr...@gmail.com wrote: Hi, How does one handle events from cells in a CellTable( specifically a SelectionCell ) ? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Events from SelectionCell in CellTable - GWT 2.1 M1
use the setFieldUpdater(fieldUpdater) on the Column class On Jun 27, 6:28 am, saklig d3andr...@gmail.com wrote: Which class has the addValueUpdateHandler ? On Jun 25, 4:08 pm, Paul Stockley pstockl...@gmail.com wrote: Can't you just add a ValueUpdater handler to see when the selection changes? On Jun 25, 4:27 am, saklig d3andr...@gmail.com wrote: After a couple of tries Ive managed to write something that gets the job done. My example: ListString opts = new ArrayListString(); opts.add(Enabled); opts.add(Disabled); table.addColumn(new IdentityColumnMyData(new ActiveSelectionCell(opts)), Active); private class ActiveSelectionCell implements CellMyData{ private HashMapString, Integer indexForOption = new HashMapString, Integer(); private final ListString options; public ActiveSelectionCell(ListString options) { this.options = new ArrayListString(options); int index = 0; for (String option : options) { indexForOption.put(option, index++); } } @Override public boolean consumesEvents() { return false; } @Override public boolean dependsOnSelection() { return false; } private int getSelectedIndex(String value) { Integer index = indexForOption.get(value); if (index == null) { return -1; } return index.intValue(); } @Override public void setValue(Element parent, MyData value, Object viewData) { StringBuilder sb = new StringBuilder(); render(value, viewData, sb); parent.setInnerHTML(sb.toString()); } @Override public Object onBrowserEvent(Element parent, MyData value, Object viewData, NativeEvent event, ValueUpdaterMyData valueUpdater) { String type = event.getType(); if (change.equals(type)) { SelectElement select = parent.getFirstChild().cast(); if( options.get(select.getSelectedIndex()).equalsIgnoreCase(Enabled)) value.setActive(1); else value.setActive(0); System.out.println(value.getName() + - + options.get(select.getSelectedIndex())); // valueUpdater.update(value); } return viewData; } @Override public void render(MyData value, Object viewData, StringBuilder sb) { int selectedIndex = 0; if(value.getActive().equalsIgnoreCase(1)){ selectedIndex = getSelectedIndex(Enabled); }else{ selectedIndex = getSelectedIndex(Disabled); } sb.append(select); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(option selected='selected'); } else { sb.append(option); } sb.append(option); sb.append(/option); } sb.append(/select); } } If you think this was the wrong/not the best way to get an event from a cell, pleas give me a comment. On Jun 22, 1:25 pm, saklig d3andr...@gmail.com wrote: Hi, How does one handle events from cells in a CellTable( specifically a SelectionCell ) ? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Events from SelectionCell in CellTable - GWT 2.1 M1
After a couple of tries Ive managed to write something that gets the job done. My example: ListString opts = new ArrayListString(); opts.add(Enabled); opts.add(Disabled); table.addColumn(new IdentityColumnMyData(new ActiveSelectionCell(opts)), Active); private class ActiveSelectionCell implements CellMyData{ private HashMapString, Integer indexForOption = new HashMapString, Integer(); private final ListString options; public ActiveSelectionCell(ListString options) { this.options = new ArrayListString(options); int index = 0; for (String option : options) { indexForOption.put(option, index++); } } @Override public boolean consumesEvents() { return false; } @Override public boolean dependsOnSelection() { return false; } private int getSelectedIndex(String value) { Integer index = indexForOption.get(value); if (index == null) { return -1; } return index.intValue(); } @Override public void setValue(Element parent, MyData value, Object viewData) { StringBuilder sb = new StringBuilder(); render(value, viewData, sb); parent.setInnerHTML(sb.toString()); } @Override public Object onBrowserEvent(Element parent, MyData value, Object viewData, NativeEvent event, ValueUpdaterMyData valueUpdater) { String type = event.getType(); if (change.equals(type)) { SelectElement select = parent.getFirstChild().cast(); if( options.get(select.getSelectedIndex()).equalsIgnoreCase(Enabled)) value.setActive(1); else value.setActive(0); System.out.println(value.getName() + - + options.get(select.getSelectedIndex())); //valueUpdater.update(value); } return viewData; } @Override public void render(MyData value, Object viewData, StringBuilder sb) { int selectedIndex = 0; if(value.getActive().equalsIgnoreCase(1)){ selectedIndex = getSelectedIndex(Enabled); }else{ selectedIndex = getSelectedIndex(Disabled); } sb.append(select); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(option selected='selected'); } else { sb.append(option); } sb.append(option); sb.append(/option); } sb.append(/select); } } If you think this was the wrong/not the best way to get an event from a cell, pleas give me a comment. On Jun 22, 1:25 pm, saklig d3andr...@gmail.com wrote: Hi, How does one handle events from cells in a CellTable( specifically a SelectionCell ) ? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: Events from SelectionCell in CellTable - GWT 2.1 M1
Can't you just add a ValueUpdater handler to see when the selection changes? On Jun 25, 4:27 am, saklig d3andr...@gmail.com wrote: After a couple of tries Ive managed to write something that gets the job done. My example: ListString opts = new ArrayListString(); opts.add(Enabled); opts.add(Disabled); table.addColumn(new IdentityColumnMyData(new ActiveSelectionCell(opts)), Active); private class ActiveSelectionCell implements CellMyData{ private HashMapString, Integer indexForOption = new HashMapString, Integer(); private final ListString options; public ActiveSelectionCell(ListString options) { this.options = new ArrayListString(options); int index = 0; for (String option : options) { indexForOption.put(option, index++); } } @Override public boolean consumesEvents() { return false; } @Override public boolean dependsOnSelection() { return false; } private int getSelectedIndex(String value) { Integer index = indexForOption.get(value); if (index == null) { return -1; } return index.intValue(); } @Override public void setValue(Element parent, MyData value, Object viewData) { StringBuilder sb = new StringBuilder(); render(value, viewData, sb); parent.setInnerHTML(sb.toString()); } @Override public Object onBrowserEvent(Element parent, MyData value, Object viewData, NativeEvent event, ValueUpdaterMyData valueUpdater) { String type = event.getType(); if (change.equals(type)) { SelectElement select = parent.getFirstChild().cast(); if( options.get(select.getSelectedIndex()).equalsIgnoreCase(Enabled)) value.setActive(1); else value.setActive(0); System.out.println(value.getName() + - + options.get(select.getSelectedIndex())); // valueUpdater.update(value); } return viewData; } @Override public void render(MyData value, Object viewData, StringBuilder sb) { int selectedIndex = 0; if(value.getActive().equalsIgnoreCase(1)){ selectedIndex = getSelectedIndex(Enabled); }else{ selectedIndex = getSelectedIndex(Disabled); } sb.append(select); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(option selected='selected'); } else { sb.append(option); } sb.append(option); sb.append(/option); } sb.append(/select); } } If you think this was the wrong/not the best way to get an event from a cell, pleas give me a comment. On Jun 22, 1:25 pm, saklig d3andr...@gmail.com wrote: Hi, How does one handle events from cells in a CellTable( specifically a SelectionCell ) ? -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.