Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Use of static classes

 
sony vijay
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using ZK Ajax Framework and am using Java code to control the components. The idea is to create two labels dynamically with two different values "Label 1" and "Label 2" and append them to two different components i.e. vlayout1 and vlayout2. But, when I try this code, a label is attached to each of the vlayout but the value of both the labels is "Label 2". I am not sure what's wrong, how do I fix this such that the values of labels are created dynamically?

I am not sure if the question is appropriate in this forum but I think the issue is with my Java code (perhaps the way I am using the static class) and not something very specific to ZK. It would be great if someone helps me figure this out. Please see the simplified version of my code below:


TestComposer.java


TestComponent.java


IncludeBuilder.java


testlabel.zul


testcomposer.zul


Thank You,
Sony

 
Winston Gutkowski
Bartender
Pie
Posts: 10422
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sony vijay wrote:But, when I try this code, a label is attached to each of the vlayout but the value of both the labels is "Label 2". I am not sure what's wrong, how do I fix this such that the values of labels are created dynamically?

I wouldn't stake my life on it, but I certainly don't like the look of
static String value;
in your TestComponent class. Why is it static?

If you truly want the class to be static (and I'm not at all sure you do) then you should include a private default constructor.

Winston
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic