Exception handling

2009-11-15 Thread Wojtek

Hi there,
I'd like to find out how the development mechanism of exception handling 
works.
It displays  stacktrace from exception thrown, so it means it has access 
to the Exception object.
I would like to implement similar feature, to display at least the 
message from the exception to the end user.
Could you tell me how to do it or point the name of class shown where 
the exception is thrown in development mode?

BTW. I know how to set internal exception page :)

Regards,
Wojtek

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



Re: Exception handling

2009-11-15 Thread Wojtek

That's exactly what I need. Thanks a lot.
Regards,
Wojtek


Jeremy Thomerson pisze:

In your application:

@Override
public RequestCycle newRequestCycle(Request request, Response response)
{
return new WebRequestCycle(this, (WebRequest) request, response) {
@Override
public Page onRuntimeException(Page page, RuntimeException e) {
return super.onRuntimeException(page, e);
}
};
}


--
Jeremy Thomerson
http://www.wickettraining.com



2009/11/15 Wojtek zabia...@gmail.com

  

Hi there,
I'd like to find out how the development mechanism of exception handling
works.
It displays  stacktrace from exception thrown, so it means it has access to
the Exception object.
I would like to implement similar feature, to display at least the message
from the exception to the end user.
Could you tell me how to do it or point the name of class shown where the
exception is thrown in development mode?
BTW. I know how to set internal exception page :)

Regards,
Wojtek

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





  



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



Re: Updating a Dynamic Image with AJAX (and JFreeChart)

2009-11-14 Thread Wojtek

Hi there,
is JFreeChart your only possible approach? Check out flot integration 
from wicketstuff-core.
It draws nicer charts and you can update datasets sending json object 
and redraw it by js.


Regards,
Wojtek


Swarnim Ranjitkar pisze:

I couldn't override getResourceState of DynamicImageResource as it new Resource 
state uses variable from DynamicImageResource eg format. Instead i copied 
DynamicImageResource class and made my own version of it and modified the 
getResourceState() get method. When I changed the drop down I was expecting it 
to call the geImageData but it wasn't calling it. Could you please advice.
Here is the modified method.
protected synchronized ResourceState getResourceState()
{
return new ResourceState()
{
private byte[] imageData;
private final String contentType = image/ + format;

@Override
public Time lastModifiedTime()
{
if (lastModifiedTime == null)
{
lastModifiedTime = 
DynamicImageResource.this.lastModifiedTime;
if (lastModifiedTime == null)
{
lastModifiedTime = Time.now();
}
}
return lastModifiedTime;
}

@Override
public byte[] getData()
{
// here is what I made the change.
imageData = getImageData();
return imageData;
}

@Override
public String getContentType()
{
return contentType;
}
};
}

From my  Image Class I called the copied version of   in getImageResource() {

return new DynamicImageResource(){


public class TugboatChartImage extends NonCachingImage  {

private int width;
private int height;

public TugboatChartImage(String id, JFreeChart chart, int width, int 
height){
super(id, new Model(chart));
this.width = width;
this.height = height;
}

@Override
protected Resource getImageResource() {
return new DynamicImageResource(){//my copied version of DynamicResouce
@Override
protected byte[] getImageData() {
JFreeChart chart = (JFreeChart)getDefaultModelObject();
return toImageData(chart.createBufferedImage(width, height));
}



};
}

}


  

To: users@wicket.apache.org
From: craig.mcil...@openroadsconsulting.com
Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)
Date: Fri, 13 Nov 2009 23:31:39 -0500

Look at the source of the DynamicImageResource class.  The getResourceState 
method does something like (sorry for the lame pseudocode) 'if image data is 
null then save and return value of getImageData else return the previous image 
data'.  So its gonna call your getImageData() method once and save the value.  
This falls in line with the super class's (DynamicWebResource) javadoc that 
says:

very useful for things you   generate dynamically, but reuse for a while after 
that. If you need resources that stream   directly and are not cached, extend 
WebResource directly and implement Resouce.getResourceStream() yourself.

It has nothing to do with HTTP caching, which it looks like you're trying to 
solve with your headers, but server-side caching.  Anyways... in this case, 
getResourceStream of WebResource ends up calling getResourceState of 
DynamicImageResource.  All you need to do is is override getResourceState (and 
therefore kind of overrides the behavior of getResourceStream) of your 
DynamicImageResource and ensure that it doesn't cache the result of 
getImageData() and you should be set.

Craig
  _  


From: wicketnewuser [mailto:swarn...@hotmail.com]
To: users@wicket.apache.org
Sent: Fri, 13 Nov 2009 20:32:05 -0500
Subject: Re: Updating a Dynamic Image with AJAX (and JFreeChart)


  I have same situation. I'm not able to refresh my image. But if i view the
  image i do get refreshed image
  Here is my code. Based on my dropdownchoice it should make new Jfreechart
  and the image should refresh. I couldn't get it working so i wrapped the
  image with in a span but it still doesn't work. TugboatChartImage extends
  NonCachingImage . Can any one point out what I'm doing wrong
  Chart chart1 = new Chart(this.getString(column1.toString()), Date,
  Dollars);
final String yAxisType = linear;
final int smallChartWidth=400;
final int smallChartHeight=200;
JFreeChart jfChartOne = chart1.render(chartOneCollection, null, yAxisType,
  smallChartWidth, smallChartHeight);


// make an image

final TugboatChartImage imageOne = new TugboatChartImage(chart1image,
  jfChartOne, smallChartWidth, smallChartHeight);
final WebMarkupContainer chart1Span = new
  WebMarkupContainer(chart1Span);
chart1Span.add(imageOne);
add(chart1Span);
  
// draw