-
22 Jul 2008 7:12 AM #1
ALIGN_RIGHT and JS errors
ALIGN_RIGHT and JS errors
Hi,
I am trying to add a button, label and button to a HorizontalPanel. In such way that the label is centered and the last button right-aligned.
This has always worked well with GWT and GWT-EXT. With GXT however it compiles cleanly but spits out an error at runtime:Code:HorizontalPanel footerPanel = new HorizontalPanel(); footerPanel.setWidth("100%"); footerPanel.add(prevButton); footerPanel.setCellHorizontalAlignment(prevButton, HasHorizontalAlignment.ALIGN_LEFT); footerPanel.add(pagenumLabel); footerPanel.setCellHorizontalAlignment(pagenumLabel, HasHorizontalAlignment.ALIGN_CENTER); footerPanel.add(nextButton); footerPanel.setCellHorizontalAlignment(nextButton, HasHorizontalAlignment.ALIGN_RIGHT);
When I try to use a GXT HorizontalPanel it is supposed to work like this:Code:com.google.gwt.core.client.JavaScriptException: (TypeError): 'children' is null or not an object number: -2146823281 description: 'children' is null or not an object at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:443)
Which compiles cleanly as well, however at runtime:Code:footerPanel.add(prevButton, new TableData("left", "middle")); footerPanel.add(pagenumLabel, new TableData("center", "middle")); footerPanel.add(nextButton, new TableData("right", "middle"));
Which seems to be roughly the same error.Code:com.google.gwt.core.client.JavaScriptException: (Error): Invalid argument. number: -2147024809 description: Invalid argument. at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:443)
Am I doing something wrong? Am I supposed to do alignment another way? Or could it be a bug?
On this board I found one other thread about this issue, which was not resolved.
Thanks!
-
22 Jul 2008 7:33 AM #2
If you include complete test code I will take a look at your use with a GWT HorizontalPanel.
This constructor expects widths not alignment. You need to use the alignment constants.Code:new TableData("left", "middle"));
-
23 Jul 2008 12:10 AM #3
Thanks

That seems to be a mistake in the Javadoc Api then, this is pretty much a copy/paste from the TableData example. Even with the Style.HorizontalAlignment it does not work however - doesnt spawn any errors but does not align either.
Basically the code is as follows:
ThanksCode:private Panel tablePanel; private FlexTable table; private HorizontalPanel footerPanel; private int cols = 0; private TableElement tableElement; [..] public DynamicTable(GWF gwf, TableElement tableElement) { this.gwf = gwf; this.tableElement = tableElement; this.recordsPerPage = tableElement.getItemsPerPage(); // table tablePanel = new ContentPanel(); tablePanel.setHeading(tableElement.getTableTitle()); table = new FlexTable(); tablePanel.add(table); // spacer HorizontalPanel spacer = new HorizontalPanel(); spacer.add(new Label(" ")); spacer.setHeight("25px"); tablePanel.add(spacer); // footer footerPanel = new HorizontalPanel(); footerPanel.setWidth("100%"); footerPanel.add(prevButton); footerPanel.setCellHorizontalAlignment(prevButton, HasHorizontalAlignment.ALIGN_LEFT); footerPanel.add(pagenumLabel); footerPanel.setCellHorizontalAlignment(pagenumLabel, HasHorizontalAlignment.ALIGN_CENTER); footerPanel.add(nextButton); footerPanel.setCellHorizontalAlignment(nextButton, HasHorizontalAlignment.ALIGN_RIGHT); tablePanel.add(footerPanel); table.setWidth("100%"); this.setHeaders(tableElement.getColumnNames()); this.renderToolbar(); initWidget(tablePanel); this.requestData(); } [..]
-
23 Jul 2008 1:19 PM #4


Reply With Quote