PDA

View Full Version : Viewport bug



kospiotr
19 Oct 2011, 1:44 PM
The following code:


Viewport viewport = new Viewport();
viewport.add(new ContentPanel(), new MarginData(10));
viewport.add(new Button("Button 1"));
RootPanel.get().add(viewport);


is failing with the message and stack:


00:15:59,469 [ERROR] Rebind result 'com.sencha.gxt.theme.base.client.container.ViewportBaseAppearance' has no default (zero argument) constructors.
java.lang.NoSuchMethodException: com.sencha.gxt.theme.base.client.container.ViewportBaseAppearance.<init>()
at java.lang.Class.getConstructor0(Class.java:2721)
at java.lang.Class.getDeclaredConstructor(Class.java:2002)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:463)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.sencha.gxt.widget.core.client.container.Viewport.<init>(Viewport.java:47)

the source is taken from javadoc so I'm not sure what is wrong:
out of date documentation or buggy code... or maybe I miss something.

I use GXT 3.0 dp5

darrellmeyer
20 Oct 2011, 4:32 PM
There is a bug in Viewport. The fix will go out in the next release. As a workaround, use this code:


public class CustomViewport extends SimpleContainer {

private boolean enableScroll;

public CustomViewport() {
monitorWindowResize = true;
setEnableScroll(false);
}

@Override
protected void onWindowResize(int width, int height) {
setPixelSize(width, height);
}

public boolean getEnableScroll() {
return enableScroll;
}

public void setEnableScroll(boolean enableScroll) {
this.enableScroll = enableScroll;
Window.enableScrolling(enableScroll);
}

@Override
protected void onAttach() {
setPixelSize(Window.getClientWidth(), Window.getClientHeight());
super.onAttach();

}

}

kospiotr
20 Oct 2011, 10:23 PM
Your code works fine. Keep it up guys, you're doing a great job!

DarekKay
21 Nov 2011, 6:07 AM
Since I don't know, whether it's a CustomViewPort or ViewPort (or even TextArea) bug, I post it here:


public void onModuleLoad()
{
CustomViewport viewPort = new CustomViewport();
viewPort.add(new TextArea());
RootLayoutPanel.get().add(viewPort);
}

Type some text, then resize your browser window -> the text disappears.

sven
21 Nov 2011, 6:14 AM
This is a known issue with all cells and will be fixed in a future release.

codingismy11to7
8 Jan 2012, 11:19 PM
I ran into the cell resize clearing issue on the latest beta today. Is there any ETA on a fix, or any known workaround?

Oddly enough, if I select all the text and then resize by dragging (although not by clicking a collapse button), I get this exception:


java.lang.NullPointerException: null at com.sencha.gxt.cell.core.client.form.FieldCell.checkViewData(FieldCell.java:253)
at com.sencha.gxt.cell.core.client.form.TextAreaInputCell.render(TextAreaInputCell.java:74)
at com.sencha.gxt.cell.core.client.form.TextAreaInputCell.render(TextAreaInputCell.java:1)
at com.sencha.gxt.widget.core.client.cell.CellComponent.redraw(CellComponent.java:209)
at com.sencha.gxt.widget.core.client.form.Field.redraw(Field.java:274)
at com.sencha.gxt.widget.core.client.form.ValueBaseField.redraw(ValueBaseField.java:233)
at com.sencha.gxt.widget.core.client.form.TextArea.redraw(TextArea.java:52)
at com.sencha.gxt.widget.core.client.cell.CellComponent.onResize(CellComponent.java:312)
at com.sencha.gxt.widget.core.client.Component.setPixelSize(Component.java:840)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.applyLayout(ResizeContainer.java:74)
at com.sencha.gxt.widget.core.client.container.CardLayoutContainer.doLayout(CardLayoutContainer.java:89)
at com.sencha.gxt.widget.core.client.container.ResizeContainer.forceLayout(ResizeContainer.java:46)
at com.sencha.gxt.widget.core.client.container.ResizeContainer$1.execute(ResizeContainer.java:23)
...


Thanks