PDA

View Full Version : Button and Toolbar



fother
20 Aug 2009, 2:02 PM
in runtime execution I need DONT render the button.. but return one exception...



final Button example = new Button("xpto") {
@Override
public void render(final Element target) {

boolean userHaveAccess = false;

rendered = userHaveAccess;
}
};

final ToolBar toolbar = new ToolBar();
toolbar.add(example);

RootPanel.get().add(toolbar);


any ideia how to solve this?



[ERROR] Unable to load module entry point xpto (see associated exception for details)
java.lang.AssertionError: Method must be called after the component is rendered
at com.extjs.gxt.ui.client.widget.Component.assertAfterRender(Component.java:1339)
at com.extjs.gxt.ui.client.widget.Component.el(Component.java:393)
at com.extjs.gxt.ui.client.widget.layout.ToolBarLayout.onLayout(ToolBarLayout.java:288)
at com.extjs.gxt.ui.client.widget.Layout.layout(Layout.java:96)
at com.extjs.gxt.ui.client.widget.Container.doLayout(Container.java:348)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:444)
at com.extjs.gxt.ui.client.widget.Container.layout(Container.java:427)
at com.extjs.gxt.ui.client.widget.toolbar.ToolBar.layout(ToolBar.java:171)
at com.extjs.gxt.ui.client.widget.Container.onAttach(Container.java:455)
at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:393)
at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:86)
at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:326)
at com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:343)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6.access$300(BrowserWidgetIE6.java:37)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad(BrowserWidgetIE6.java:77)
at com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke(BrowserWidgetIE6.java:161)
at com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:294)
at com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:194)
at org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:117)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
at com.google.gwt.dev.SwtHostedModeBase.processEvents(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)

yuriy128
20 Aug 2009, 4:38 PM
If i understood your problem, all you need it to hide the button in the toolbar. There is no need to
override the render method. just

final Button example = new Button("xpto") ;
example.setVisible(false);
final ToolBar toolbar = new ToolBar();
toolbar.add(example);
RootPanel.get().add(toolbar);

Arno.Nyhm
21 Aug 2009, 2:43 AM
if you look at the java code you see this for your the rendered. and it looks like it is a internal value.


/**
* True if this component has been rendered. Read-only.
*/
protected boolean rendered;


and if you look through the java code of Component then you see changing this value makes no sense...

fother
21 Aug 2009, 7:03 AM
If i understood your problem, all you need it to hide the button in the toolbar. There is no need to
override the render method. just

final Button example = new Button("xpto") ;
example.setVisible(false);
final ToolBar toolbar = new ToolBar();
toolbar.add(example);
RootPanel.get().add(toolbar);


I need hide in run time.. to solve this I overwrite the method afterRender.. and verify if the user have permission.. if dont have.. hide the button.. this work fine.. I would like dont render and after hide.. but dont find a solution..

sven
21 Aug 2009, 8:24 AM
If you dont want to render something, just dont add it. But you cant just override some methods that are important.

fother
21 Aug 2009, 8:47 AM
yes.. debugging I discover this.. and for this moment.. the unique way to do this.. its render and hide..

Arno.Nyhm
24 Aug 2009, 12:12 AM
other possible way: hide it via css.