Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-17 Thread Decebal Suiu
Hi Sebastian

I see that in Component.internalBeforeRender() the call of onBeforeRender()
is conditioned by determineVisibility() and this explains all. 

I think it's fine to change the hierarchy in onBeforeRender() ... , this is
even made explicit in the source 
code of MarkupContainer#onBeforeRender()
Sorry, but I don't see explicit that I can modify the hierarchy of my object
in onBeforeRender().

Another question in my mind is: is it ok that call of onInitialize() is not
conditioned by isVisible?

By the way do you know a document, something, that explains the rendering
process?

Best regards,
Decebal



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663065.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-17 Thread Martin Grigorov
Hi,

On Tue, Dec 17, 2013 at 11:21 AM, Decebal Suiu decebal.s...@asf.ro wrote:

 Hi Sebastian

 I see that in Component.internalBeforeRender() the call of onBeforeRender()
 is conditioned by determineVisibility() and this explains all.

 I think it's fine to change the hierarchy in onBeforeRender() ... , this
 is
 even made explicit in the source
 code of MarkupContainer#onBeforeRender()
 Sorry, but I don't see explicit that I can modify the hierarchy of my
 object
 in onBeforeRender().


I've updated the javadoc.



 Another question in my mind is: is it ok that call of onInitialize() is not
 conditioned by isVisible?


Yes.
onInitialize() (called once) and onConfigure() (called for every request)
are called even for invisible components.



 By the way do you know a document, something, that explains the rendering
 process?


I'm not aware of such in the public area.
I do have it in the my training materials.



 Best regards,
 Decebal



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663065.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-17 Thread Serban.Balamaci
I've found it nicely explained here:
http://wicketguide.comsysto.com/guide/chapter6.html#chapter6_4

seems it's a great guide.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663072.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-17 Thread Paul Bors
@Serban,
Careful with the comsysto.com links as there is already a version of the
Wicket Guide at wicket.apache.org/guide.

I think the link you're looking for is:
http://wicket.apache.org/guide/guide/chapter6.html#chapter6_4

Jira tickets for the guide can be logged in Wicket's Jira queue under the
Guide component:
https://issues.apache.org/jira/browse/WICKET/component/12321210


@Decebal,

I use the EmptyPanel instead of setting the visibility to false as the
component tree is smaller :)
I do toggle the EmptyPanel and later replace it with whatever I need in
onBeforeRender() and then re-render the parent component via Ajax.

~ Thank you,
   Paul Bors




On Tue, Dec 17, 2013 at 6:53 AM, Serban.Balamaci thespamtr...@gmail.comwrote:

 I've found it nicely explained here:
 http://wicketguide.comsysto.com/guide/chapter6.html#chapter6_4

 seems it's a great guide.



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663072.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-16 Thread vineet semwal
i think what you need is  onbeforerender() and not oninintialize, before
rendering visibility is determined( if curious check the source in
component#internalbeforer()) ,
also i am assuming when you will create/add 100 labels,you will use a
repeater like dataview/listview which creates and adds items in
onbeforerender so if your repeater is not visible, the items/children (and
your labels) will not be created/rendered ...


On Mon, Dec 16, 2013 at 7:26 PM, Decebal Suiu decebal.s...@asf.ro wrote:

 Hi

 First, the scenario (a  simplified version):
 I have a XPage (extends WebPage) and in the constructor of this page I want
 to add a YPanel (extends Panel) but depending on a condition.

 if (condiiton) {
add(new YPanel(panel));
 } else {
add(new WebMarkupContainer(panel).setVisible(false));
 }

 In fact my scneario is a little complicated, with four children (a CartPage
 that contains EmptyLabel, CartPanel, LoginPanel, CheckputPanel) and a
 compund condition (isEmptyCart, isUserLogged) and in this situation my code
 is verbose and a little spaghetti.

 The code above resolves my scenario but in my opinion is more readable only
 a single line

 add(new YPanel(panel).setVisible(condition));

 The solution with a single line is more readable but it has an impediment.
 For example if in YPanel I want to add 100 labels (hypothetically), I
 created 100 label only to add nothing if the condition is not satisfied :)

 The solution is to have a slim constructor for YPanel and to add the
 children in a method (something like onInitialize) that depends on
 component
 visibility. I want something like I know that this component is invisible
 so don't bother to create the children.

 I know about the request cycle (not in details) and that it's impossible
 for
 now, I know that my issue is a philosophical issue but maybe someone has
 a
 good question.

 Best regards,
 Decebal



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041.html
 Sent from the Users forum mailing list archive at Nabble.com.

 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org




-- 
regards,

Vineet Semwal


Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-16 Thread Decebal Suiu
I tested with:

public class MyPanel extends Panel {

public MyPanel(String id) {
super(id);  
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();

add(new MyLabel(l1, Label 1));
add(new MyLabel(l2, Label 2));
add(new MyLabel(l3, Label 3));
 }

}

in MyPanel, where MyLabel extends Label with the constructor contains and
debug message:

public MyLabel(String id, String label) {
   super(id, label);

System.out.println(MyLabel.MyLabel(): + id);
}

And yes, the MyLabel constructed is not called if MyPanel is not visible.

My impression was that in onBeforeRender I cannot change the hierarchy (add
children).

The 100 children was a random number that show you that my panel contains
many components :)

Thanks,
Decebal




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663045.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: a little question about add(new XComponent(id).setVisible(false))

2013-12-16 Thread Bas Gooren
I think it's fine to change the hierarchy in onBeforeRender(), as long 
as you do it before calling super.onBeforeRender(), since that calls OBR 
on the children of your panel.
And (you gotta love wicket), this is even made explicit in the source 
code of MarkupContainer#onBeforeRender():


/**
 * Called just before a component is rendered.
 * p
 * strongNOTE/strong: If you override this, you *must* call 
super.onBeforeRender() within

 * your implementation.
 *
 * Because this method is responsible for cascading {@link 
#onBeforeRender()} call to its
 * children it is strongly recommended that super call is made at 
the end of the override.

 * /p
 */

Before we had onInitialize, we would use onBeforeRender() and a boolean 
guard variable (boolean initialized) to accomplish the same thing.


Conclusion, it's fine, as long as you call super.onBeforeRender() at the 
end of your method.


Met vriendelijke groet,
Kind regards,

Bas Gooren

schreef Decebal Suiu op 16-12-2013 16:50:

I tested with:

public class MyPanel extends Panel {

public MyPanel(String id) {
super(id);  
}

 @Override
 protected void onBeforeRender() {
super.onBeforeRender();

add(new MyLabel(l1, Label 1));
add(new MyLabel(l2, Label 2));
add(new MyLabel(l3, Label 3));
  }

}

in MyPanel, where MyLabel extends Label with the constructor contains and
debug message:

public MyLabel(String id, String label) {
super(id, label);

System.out.println(MyLabel.MyLabel(): + id);
}

And yes, the MyLabel constructed is not called if MyPanel is not visible.

My impression was that in onBeforeRender I cannot change the hierarchy (add
children).

The 100 children was a random number that show you that my panel contains
many components :)

Thanks,
Decebal




--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/a-little-question-about-add-new-XComponent-id-setVisible-false-tp4663041p4663045.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org