0

Refresh images problem

asked 2010-04-14 01:57:56 +0800

bzk gravatar image bzk
3

Hi all,

I got problems with updating images within zkoss. I have a page with rendered images in a groupboxes. these images change according to the information in de database. The page is opened all day to show progression. When the page is opened everything is shown correctly, but after a while the images wont refresh. the page is still active and data is still correct too.

I have 2 functions. one generates a image:

BufferedImage Baan(int iStatus, BufferedImage b, int xBaan, int iBaanToggle,int iBaanNr, int iBatchNr,String sAantal,int iAantalTot,int iAantalPos, int iAantalHaken, int iGeslacht)
{

Graphics2D g2dBaan = b.createGraphics();
g2dBaan.setFont(InfoGr);

Rectangle2D Rechthoek = new Rectangle2D.Double(10,3,120,40);
g2dBaan.setColor(BaanStatus);
g2dBaan.fill(Rechthoek);

g2dBaan.setColor(Color.BLACK);
String sBaanTxt = "Baan " + Integer.toString(iBaanNr);
g2dBaan.drawString(sBaanTxt,20,15);

String soort= "";

g2dBaan.setFont(InfoKl);
String sAantalTot = Integer.toString(iAantalHaken)+ " / " + Integer.toString(iAantalTot);
String sBatchNr = Integer.toString(iBatchNr);
g2dBaan.setColor(Groen);

int iBreete = iAantalPos*4;
if (100 > iBreete ) iBreete = 100;

Rechthoek = new Rectangle2D.Double(xBaan+10,3,iBreete,40);
g2dBaan.fill(Rechthoek);
g2dBaan.setColor(Color.BLACK);

g2dBaan.drawString("batch",xBaan+12,10);
g2dBaan.drawString(sBatchNr,xBaan+12,19);

g2dBaan.drawString(soort,xBaan+45,19);

g2dBaan.drawString("h/p",xBaan+iBreete-20,10);
g2dBaan.drawString(sAantal,xBaan+iBreete-30,19);

g2dBaan.drawString("h/p",83,10);
g2dBaan.drawString(sAantalTot,80,19);

return b;
}

public void Toonalles()
{
Connection conn = null;
try
{
conn = getConnection_NFM_WMS_Koelcel();

Statement s = conn.createStatement ();
s.executeQuery ("SELECT * FROM baandata order by BaanNr");
ResultSet rs = s.getResultSet ();

// Initaliseren van de grid
int[] xB = new int[12];
int[] iBToggle = new int[12];
int[] iBAantalTot = new int[12];
int[] iBHakenTot = new int[12];
BufferedImage[] BufImage = new BufferedImage[12];
Graphics2D[] g2dBaan = new Graphics2D[12];
Rectangle2D Rechthoek = new Rectangle2D.Double(0,0,800,40);
int i=1;
while (12>i)
{
BufImage= new BufferedImage(800, 20, BufferedImage.TYPE_INT_RGB);
g2dBaan = BufImage.createGraphics();
g2dBaan.setColor(NawiBlauw);
g2dBaan.fill(Rechthoek);
xB = 125;
iBToggle = 0;
iBAantalTot = 0;
iBHakenTot = 0;
i++;
}
while (rs.next())
{
int iStatus = rs.getInt("Status");
int iBaanNr = rs.getInt("BaanNr");
int iBatchNr = rs.getInt("BatchNr");
int iAantalPos = rs.getInt("AantalPosities");
int iAantalHaken = rs.getInt("AantalHaken");
int iGeslacht = rs.getInt("Geslacht");
iBAantalTot += rs.getInt("Aantal");
iBHakenTot += rs.getInt("AantalHaken");

String sAantal = rs.getString("AantalHaken") + " / " + rs.getString("Aantal");

if (iBToggle == 1)
{ iBToggle = 0; }
else { iBToggle = 1;}
BufImage = Baan(iStatus,BufImage ,xB, iBToggle, iBaanNr ,iBatchNr, sAantal, iBAantalTot, iAantalPos,iBHakenTot, iGeslacht);
if (iAantalPos*4 > 100)
{
xB+= 5 + iAantalPos*4;
}
else
{
xB+= 105;
}
}
rs.close ();
s.close ();
Baan1.setContent(BufImage[1]);
Baan2.setContent(BufImage[2]);
Baan3.setContent(BufImage[3]);
Baan4.setContent(BufImage[4]);
Baan5.setContent(BufImage[5]);
Baan6.setContent(BufImage[6]);
Baan7.setContent(BufImage[7]);
Baan8.setContent(BufImage[8]);
Baan9.setContent(BufImage[9]);
Baan10.setContent(BufImage[10]);
Baan11.setContent(BufImage[11]);
}
catch (Exception e)
{
System.err.println ("ERROR: "+ e.getMessage());
}
finally
{
if (conn != null)
{
try
{
conn.close ();
}
catch (Exception e) { /* ignore close errors */ }
}
}
}

}


Can someone explain me what I am doing wrong?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2010-04-27 03:23:39 +0800

Cogito gravatar image Cogito
66 1
ZK Team

Hi bzk,

Correct me if I am wrong, but I didn't see any ZK related code in the snippet you pasted. Could you show us your implementation in ZK, for example, what component contained in groupbox (since groupbox is just a container) was set with an image source, and how?

link publish delete flag offensive edit

answered 2010-04-27 05:00:55 +0800

woodyki gravatar image woodyki
168

updated 2010-04-27 05:01:34 +0800

The BufferImage array "BufImage" without operate and object assigned into each element.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2010-04-14 01:57:56 +0800

Seen: 367 times

Last updated: Apr 27 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More