Forums Register Login

Use of static classes

+Pie Number of slices to send: Send
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

+Pie Number of slices to send: Send
 

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
I'm gonna teach you a lesson! Start by looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 936 times.
Similar Threads
Scroll ........i need help
dynamic HTML
ideas wanted on making this custom JTable cell renderer more efficient
jtabbedpane is a pain in the butt; how do I place labels and move them around?
Cannot make a static reference to the non-static field
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 03:46:17.