PDA

View Full Version : LayoutContainer hide() - potencial bug



fother
22 Jan 2009, 3:52 AM
public void onModuleLoad() {

final TextField<String> text1 = new TextField<String>();
TextField<String> text2 = new TextField<String>();

final LayoutContainer container = new LayoutContainer(new FormLayout());
container.add(text1);
container.hide();

LayoutContainer container2 = new LayoutContainer(new FormLayout());
container2.add(text2);

Button x = new Button("xx");
x.addSelectionListener(new SelectionListener<ComponentEvent>() {

@Override
public void componentSelected(ComponentEvent ce) {

System.out.println(container.isVisible());
System.out.println(text1.isVisible());

}

});

LayoutContainer main = new LayoutContainer();
main.add(container);
main.add(container2);
main.add(x);

RootPanel.get().add(main);

}


when the method hide() is called, the attribute visible of the container received false, ok, but the other components that was added in the container, not received false..

sven
22 Jan 2009, 5:25 AM
You cannot really call this a bug. It uses El.isVisible to check if the component element is visible. As the childelements dont have the attribute set to hide them, it return true.

But in your application logic you should know that if you hide a parent, that the children are also hidden.

sven
22 Jan 2009, 5:27 AM
Also what you want if you call show on the textfield? Should the textfield showup in the hidden form?

fother
22 Jan 2009, 7:15 AM
if the parent object is not visible their children should also not be .. I'm talking about the value of the variable of the children .. to hide a child .. arrow him visible equals false .. it's easy .. ;)

the problem that I have is that I need get the instance of field.. and use..




private myMethod(TextField field) {
if (field.isVisible) {
doSomething();
}
}

sven
22 Jan 2009, 8:32 AM
arrow him visible equals false

That isnt easy as you said. Also have you read what i said?

fother
22 Jan 2009, 9:06 AM
the translator is not good.. sorry..

do you have any idea the how to solve this?

because the method will be recursive.. and wont a great idea..

sven
22 Jan 2009, 9:14 AM
check for the formpanel.

Or: What are you trying to do that you can only do it if it is visible?

fother
22 Jan 2009, 9:19 AM
I will pass to parameter the formPanel and the field..change what I asked.. return serious problem, one I mentioned above, and other problem as performece, etc... so forget this :D

sven
22 Jan 2009, 9:27 AM
I havent understood anything you juse wrote

fother
22 Jan 2009, 9:32 AM
aeuihfuahefhaefiohaefhaoiefhie forget

sven
27 Jan 2009, 5:00 AM
We did the change.

fother
27 Jan 2009, 5:09 AM
using recursive method?

sven
27 Jan 2009, 5:13 AM
It is already in the SVN and will be in the next release. Check it out and you will see.

fother
27 Jan 2009, 5:23 AM
you can not discuss the code?