Hi Olivier,
I simple way to achieve this is to have a (abstract) #onError method:
public abstract class MyModel extends
LoadableDetachableModel<List<MyObject>>
{
private static final long serialVersionUID = 1L;
private static final Logger LOG =
LoggerFactory.getLogger(DashboardModel.class);
public MyModel()
{
}
@Override
protected List<MyObject> load()
{
List<MyObject> list = new ArrayList<MyObject>();
try
{
//TODO fill list;
}
catch (TheException e)
{
this.error(e.getMessage(), e);
}
return list;
}
private void error(String message, Exception e)
{
LOG.error(message, e);
this.onError(message);
}
protected abstract void onError(String message);
}
In MyPage
private MyModel newMyModel()
{
return new MyModel() {
private static final long serialVersionUID = 1L;
@Override
protected void onError(String message)
{
MyPage.this.error(message);
}
};
}
Hope this helps,
Sebastien.
On Wed, Jan 22, 2014 at 2:07 PM, Oliver B. Fischer <[email protected]>wrote:
> I have implementation of LoadableDetachableModel which might throw an
> exception in load(). Unfortunately this exception might be thrown while
> rendering the page.
>
> Currently I handle the exception with an AbstractRequestCycleListener
> added to the application itself.
>
> But don't like it because I don't want to add an
> AbstractRequestCycleListener for each possible exception.
>
> It is possible to handle specific exceptions page local? I tried to add a
> custom Behaviour implementation to my page but the onException() method was
> never called.
>
> Any idea how to handle such exceptions locally?
>
> Oliver
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>