Advertisement
Guest User

Untitled

a guest
May 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DOMImplStandard.java:125 Uncaught TypeError: Cannot read property 'contains' of nullisOrHasChild_1_g$ @ DOMImplStandard.java:125$isOrHasChild_0_g$ @ Node.java:280onBrowserEvent_17_g$ @ ActionCell.java:87fireEventToCell_0_g$ @ CellList.java:360onBrowserEvent2_1_g$ @ CellList.java:453onBrowserEvent_3_g$ @ AbstractHasData.java:738dispatchEventImpl_0_g$ @ DOM.java:1480dispatchEvent_4_g$ @ DOM.java:1419dispatchEvent_6_g$ @ DOMImplStandard.java:317apply_0_g$ @ Impl.java:247entry0_0_g$ @ Impl.java:306(anonymous function) @ Impl.java:72
  2.  
  3.  
  4. The idea is to add a button inside a cell to delete that cell. The cell and the button should do 2 different things, and it works right now as expected but it keeps giving this nullpointer. Also the button should be visible only when the cell is selected.
  5. I created my own ActionCell, a Delegate for the button click, SingleSelectionModel for the CellList.
  6. class MyActionCell<T> extends ActionCell<String> {
  7.     static String selectedSelf = "";
  8.     public MyActionCell(String text,
  9.             com.google.gwt.cell.client.ActionCell.Delegate<String> delegate) {
  10.         super(text, delegate);
  11.         // TODO Auto-generated constructor stub
  12.     }
  13.  
  14.     @Override
  15.     public void render(Context context, String value, SafeHtmlBuilder sb) {
  16.         if(value==null)return;
  17.         Window.alert("Rendering: " +value);
  18.         SafeHtml title = new SafeHtmlBuilder().appendEscaped(value)
  19.                 .toSafeHtml();
  20.         sb.append(title);
  21.         if (selectedSelf.contentEquals(value)) {
  22.             SafeHtml html = new SafeHtmlBuilder()
  23.                     .appendHtmlConstant(
  24.                             "<button type=\"button\" tabindex=\"-1\">")
  25.                     .appendEscaped(value)
  26.                     .appendHtmlConstant("</button>").toSafeHtml();
  27.             sb.append(html);
  28.         }
  29.        
  30.     }
  31.    
  32.     public static void setSelected(String selected){
  33.         selectedSelf = selected;
  34.     }
  35. }
  36.  
  37.     private final Delegate<String> delegate = new Delegate<String>(){
  38.  
  39.         @Override
  40.         public void execute(String clickedPack) {
  41.             if(clickedPack!=null){
  42.             Window.alert("CLicked: "
  43.                     +clickedPack);
  44.             }
  45.         }
  46.        
  47.     };
  48. MyActionCell<String> ac = new MyActionCell<String>("name",delegate);
  49.     final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>();
  50.  
  51. selectionModel
  52.         .addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
  53.             public void onSelectionChange(
  54.                     SelectionChangeEvent event) {
  55.                 String selected = selectionModel
  56.                         .getSelectedObject();
  57.                
  58.                 Window.alert(selected);
  59.                 if (selected != null) {
  60.                     //selectionModel.getSelectedObject().setSelected(selected);
  61.                     MyActionCell.setSelected(selected);
  62.                     selectedPackage = selected;
  63.                     updatePackageHolderMiddle();
  64.                 }
  65.             }
  66.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement