You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Anandkumar Chandran <an...@verchaska.com> on 2004/02/06 12:21:19 UTC
URGENT!!! -- Exception Handling using CallBack
Hi forum,
I'm a newbie and got a good hold on tapestry implementation. I'm working on a
customized exception handling mechanism.
Scenario:
1. Using a mapper for each Page with corresponding exception or error page.
2. Processing the request using the listener method. If any exception occurs,
I would like to take the user to the specified error page or exception page
automatically without any special code going in for exception handling.
i.e I would like to hide the error handling mechanism from the developers.(It
might reduce the learning curve & development time).
I ran over the Callback mechanism and got an idea for working around this
exception handling. But I need to clear certain doubts before proceeding with
it.
1. To my knowledge when the CallBack is used, it persists the page... Correct
me if I'm wrong.
2. If it persists, then my methodology will store all the pages and will clog
the server. How to remove the callback persisted page, if there is no
exception raised.
3. What will be the performance hit by this method.
I would appreciate If any other methodology for generic exception control is
shared.:))
Very urgent..
Regards,
@nand
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: URGENT!!! -- Exception Handling
Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
This sounds like an issue with your backend. Tapestry does not, can not, know about your backend ...
just about JavaBeans properties.
The PageCallback does just store the name of the page.
Any persistent page properties will be restored (in the later request, when the callback is
utilized).
There's this thing call transactions :-)
Seriously, if you have a complicated series of operations, you want to use the Command pattern (see
Gang of Four) within a transaction. You might want to create your own ICallback implementation that
can store the list of Commands to execute.
Can't really help you beyond that without more details about your app.
--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components
http://howardlewisship.com
> -----Original Message-----
> From: Anandkumar Chandran [mailto:anand@verchaska.com]
> Sent: Monday, February 09, 2004 2:04 AM
> To: Tapestry users
> Subject: URGENT!!! -- Exception Handling
>
>
> Hi
>
> I was working out on an assumption that the callback
> functionality persisits
> the page object with all the embedded properties in it. But
> it seems like the
> callback persists only the Page name .. Is my finiding
> correct ..?? I couldnt
> get a pointer on this.
>
> Anyway, what I'm trying to do is always a pain in all the
> application, i.e a
> generic exception handler mechanism.
>
> I'm running out of options in this case. This is simple to
> handle pages which
> does not have a preloaded data in that page. But not in pages
> with data from
> DB, e.g A Registration confirmation page which has first half
> page filled
> with the registration information, the second half left open
> for inputing the
> confirmation details. And when I submit and some error
> occurs, I need to get
> back to the same registration confirmation page with first half page
> information retrieved from DB and the second half with user
> input data.
>
> I think this isn't possible without making a DB call in the
> registration
> confirmation page load.
>
> !st option is I could use session for each cycle to store the
> previous page
> information. But problem is
> 1. clogging user session
> 2. No updated data in case of partial updation and then
> exception occurs (i.e
> Multiple delete function where half get deleted and half
> could not get
> deleted 'cos of data reference)
>
> Any light on this is appreciated... I think this is universal
> problem .. if
> this could be handled in tapestry itself It would be of gr8 relief.
>
> Thanx and Regards,
> @nand
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
URGENT!!! -- Exception Handling
Posted by Anandkumar Chandran <an...@verchaska.com>.
Hi
I was working out on an assumption that the callback functionality persisits
the page object with all the embedded properties in it. But it seems like the
callback persists only the Page name .. Is my finiding correct ..?? I couldnt
get a pointer on this.
Anyway, what I'm trying to do is always a pain in all the application, i.e a
generic exception handler mechanism.
I'm running out of options in this case. This is simple to handle pages which
does not have a preloaded data in that page. But not in pages with data from
DB, e.g A Registration confirmation page which has first half page filled
with the registration information, the second half left open for inputing the
confirmation details. And when I submit and some error occurs, I need to get
back to the same registration confirmation page with first half page
information retrieved from DB and the second half with user input data.
I think this isn't possible without making a DB call in the registration
confirmation page load.
!st option is I could use session for each cycle to store the previous page
information. But problem is
1. clogging user session
2. No updated data in case of partial updation and then exception occurs (i.e
Multiple delete function where half get deleted and half could not get
deleted 'cos of data reference)
Any light on this is appreciated... I think this is universal problem .. if
this could be handled in tapestry itself It would be of gr8 relief.
Thanx and Regards,
@nand
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: URGENT!!! -- Exception Handling using CallBack
Posted by Richard Kirby <rb...@capdm.com>.
Anandkumar Chandran wrote:
>BINGO!!!!! That was an excellent piece ..
>
>You did get my exact requirement. This is what exactly I have done already and
>I feel good to see my code out there ..:))
>
>But you have stopped at a point where exactly my problem begins ..:).
>
>Probably I understand that for every user action you have to do some action
>using the listener method and on the page load you do another action.
>
>This basically splits the biz service layer into two actions for each user
>action.
>
>What I try to do is one biz layer call for each user action and manipulate the
>output of biz service during the next page rendering.
>
>If I have to do this I need to give a biz service layer call to handle the
>exception page logics.
>
>Do I make myself clear pal ..??
>
>Anyway I'm glad to see prompt replies ..:)
>
>Regards,
>@nand
>
>
Not sure I understand this, but I think what you are wanting to do is
set the exception page up with some biz layer data. In which case:
public abstract BaseFormPage extends BasePage
{
/**
* Developers implement this method in their code.
*/
protected abstract doWork(IRequestCycle cycle);
public void doSubmit(IRequestCycle cycle) {
try {
doWork(cycle);
cycle.setPage(lookUpNextPage(cycle));
} catch (Exception e) {
SomeErrorPage page = lookUpErrorPage(cycle);
page.someBizLayerRelatedMethod(bizLayerDataObject);
cycle.setPage(page);
}
}
}
Essentially, once you have hold of a Page object for the page you want
to send back to the user, you can invoke methods on it to set its state
to whatever you require, before it is rendered (which happens on the
listener method finishing, and the cycle.setPage call telling Tapestry
which page to render).
Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: URGENT!!! -- Exception Handling using CallBack
Posted by Anandkumar Chandran <an...@verchaska.com>.
BINGO!!!!! That was an excellent piece ..
You did get my exact requirement. This is what exactly I have done already and
I feel good to see my code out there ..:))
But you have stopped at a point where exactly my problem begins ..:).
Probably I understand that for every user action you have to do some action
using the listener method and on the page load you do another action.
This basically splits the biz service layer into two actions for each user
action.
What I try to do is one biz layer call for each user action and manipulate the
output of biz service during the next page rendering.
If I have to do this I need to give a biz service layer call to handle the
exception page logics.
Do I make myself clear pal ..??
Anyway I'm glad to see prompt replies ..:)
Regards,
@nand
On Friday 06 February 2004 19:16, Richard Kirby wrote:
> Anandkumar Chandran wrote:
> >Thanx for the prompt reply ..:)
> >
> >I got the usage of the callback functionality. But my requirement is
> > something different from what you have explained in the first half of
> > your reply.
> >
> >I'll try to gv the exact scenario step by step:
> >1. 1st Page -- > Registration page
> >2. 2nd Page --> Registration Confirmation Details Page
> >3. 3rd Page --> Registration Pre Mail View Page
> >
> >Action:
> >1. input in Registration page. submit and validate.
> >2 . Error ( Registration information already found) . If Error then
> > activate the same Registration page else activate the Registration
> > Confirmation Details Page. ( Developer writes the navigation by
> > hardcoding in the listener method).
> >
> >Requirement:
> >A common controller which takes care of handling the navigation
> > automatically to the next page ( incase of error next page is error page)
> > which is retrieved from the Page-NextPage-ErrorPage Mapper.
> >
> >The developer is devoid of writing the exception/error handling code
> >explicitly. It should be handled by the controller automatically when once
> >implemented.
> >
> >I plan to persist the current page everytime I do any action and if
> > detects error then use the callback otherwise delete the persisted page
> > in the same cycle..???!!!! ( This is where I'm stuck .. is it right ..??
> > How can I delete the callback persisted page instance .?? )
> >
> >Hope I made my requirement clear. Any suggesions ..??
> >
> >
> >Regards,
> >Anand
>
> You can delete a persisted page by using IRequestCycle.discardPage("page
> name").
>
> Tapestry provides the common controller, so I am not sure how you plan
> to replace it yourself. I would suggest providing your developers with a
> base class that implements a public void doSubmit(IRequestCycle cycle)
> method, that all their forms will point to. It will then invoke an
> abstract method which the developers implement to do the specific work,
> and your doSubmit method can then call the abstract method inside a
> try/catch and do whatever is necessary:
>
> public abstract BaseFormPage extends BasePage
> {
> /**
> * Developers implement this method in their code.
> */
> protected abstract doWork(IRequestCycle cycle);
>
> public void doSubmit(IRequestCycle cycle) {
> try {
> doWork(cycle);
> cycle.setPage(lookUpNextPage(cycle));
> } catch (Exception e) {
> cycle.setPage(lookUpErrorPage(cycle));
> }
> }
> }
>
> Does this give you some ideas?
>
> Richard.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: URGENT!!! -- Exception Handling using CallBack
Posted by Richard Kirby <rb...@capdm.com>.
Anandkumar Chandran wrote:
>Thanx for the prompt reply ..:)
>
>I got the usage of the callback functionality. But my requirement is something
>different from what you have explained in the first half of your reply.
>
>I'll try to gv the exact scenario step by step:
>1. 1st Page -- > Registration page
>2. 2nd Page --> Registration Confirmation Details Page
>3. 3rd Page --> Registration Pre Mail View Page
>
>Action:
>1. input in Registration page. submit and validate.
>2 . Error ( Registration information already found) . If Error then activate
>the same Registration page else activate the Registration Confirmation
>Details Page. ( Developer writes the navigation by hardcoding in the listener
>method).
>
>Requirement:
>A common controller which takes care of handling the navigation automatically
>to the next page ( incase of error next page is error page) which is
>retrieved from the Page-NextPage-ErrorPage Mapper.
>
>The developer is devoid of writing the exception/error handling code
>explicitly. It should be handled by the controller automatically when once
>implemented.
>
>I plan to persist the current page everytime I do any action and if detects
>error then use the callback otherwise delete the persisted page in the same
>cycle..???!!!! ( This is where I'm stuck .. is it right ..?? How can I delete
>the callback persisted page instance .?? )
>
>Hope I made my requirement clear. Any suggesions ..??
>
>
>Regards,
>Anand
>
>
You can delete a persisted page by using IRequestCycle.discardPage("page
name").
Tapestry provides the common controller, so I am not sure how you plan
to replace it yourself. I would suggest providing your developers with a
base class that implements a public void doSubmit(IRequestCycle cycle)
method, that all their forms will point to. It will then invoke an
abstract method which the developers implement to do the specific work,
and your doSubmit method can then call the abstract method inside a
try/catch and do whatever is necessary:
public abstract BaseFormPage extends BasePage
{
/**
* Developers implement this method in their code.
*/
protected abstract doWork(IRequestCycle cycle);
public void doSubmit(IRequestCycle cycle) {
try {
doWork(cycle);
cycle.setPage(lookUpNextPage(cycle));
} catch (Exception e) {
cycle.setPage(lookUpErrorPage(cycle));
}
}
}
Does this give you some ideas?
Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: URGENT!!! -- Exception Handling using CallBack
Posted by Anandkumar Chandran <an...@verchaska.com>.
Thanx for the prompt reply ..:)
I got the usage of the callback functionality. But my requirement is something
different from what you have explained in the first half of your reply.
I'll try to gv the exact scenario step by step:
1. 1st Page -- > Registration page
2. 2nd Page --> Registration Confirmation Details Page
3. 3rd Page --> Registration Pre Mail View Page
Action:
1. input in Registration page. submit and validate.
2 . Error ( Registration information already found) . If Error then activate
the same Registration page else activate the Registration Confirmation
Details Page. ( Developer writes the navigation by hardcoding in the listener
method).
Requirement:
A common controller which takes care of handling the navigation automatically
to the next page ( incase of error next page is error page) which is
retrieved from the Page-NextPage-ErrorPage Mapper.
The developer is devoid of writing the exception/error handling code
explicitly. It should be handled by the controller automatically when once
implemented.
I plan to persist the current page everytime I do any action and if detects
error then use the callback otherwise delete the persisted page in the same
cycle..???!!!! ( This is where I'm stuck .. is it right ..?? How can I delete
the callback persisted page instance .?? )
Hope I made my requirement clear. Any suggesions ..??
Regards,
Anand
On Friday 06 February 2004 17:00, Richard Kirby wrote:
> Anandkumar Chandran wrote:
> >Hi forum,
> >
> >I'm a newbie and got a good hold on tapestry implementation. I'm working
> > on a customized exception handling mechanism.
> >
> >Scenario:
> >1. Using a mapper for each Page with corresponding exception or error
> > page. 2. Processing the request using the listener method. If any
> > exception occurs, I would like to take the user to the specified error
> > page or exception page automatically without any special code going in
> > for exception handling. i.e I would like to hide the error handling
> > mechanism from the developers.(It might reduce the learning curve &
> > development time).
> >
> >I ran over the Callback mechanism and got an idea for working around this
> >exception handling. But I need to clear certain doubts before proceeding
> > with it.
> >1. To my knowledge when the CallBack is used, it persists the page...
> > Correct me if I'm wrong.
> >2. If it persists, then my methodology will store all the pages and will
> > clog the server. How to remove the callback persisted page, if there is
> > no exception raised.
> >3. What will be the performance hit by this method.
> >
> >I would appreciate If any other methodology for generic exception control
> > is shared.:))
> >
> >Very urgent..
> >
> >Regards,
> >@nand
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
> You can specify your own Exception page in your .application file, with
> the name "Exception", which will override the default Tapestry Exception
> page. Then your code for your Exception page can do any specific
> exception handling you require.
>
> Callback is probably not what you want. It is used to encapsulate the
> state of a page, so that at a later point, another page can use the
> callback to effectively redirect back to the saved state of the page
> saved. Very useful for wizards that need to "callout" to another wizard
> temporarily.
>
> Hope this helps
>
> Richard.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: URGENT!!! -- Exception Handling using CallBack
Posted by Richard Kirby <rb...@capdm.com>.
Anandkumar Chandran wrote:
>Hi forum,
>
>I'm a newbie and got a good hold on tapestry implementation. I'm working on a
>customized exception handling mechanism.
>
>Scenario:
>1. Using a mapper for each Page with corresponding exception or error page.
>2. Processing the request using the listener method. If any exception occurs,
>I would like to take the user to the specified error page or exception page
>automatically without any special code going in for exception handling.
>i.e I would like to hide the error handling mechanism from the developers.(It
>might reduce the learning curve & development time).
>
>I ran over the Callback mechanism and got an idea for working around this
>exception handling. But I need to clear certain doubts before proceeding with
>it.
>1. To my knowledge when the CallBack is used, it persists the page... Correct
>me if I'm wrong.
>2. If it persists, then my methodology will store all the pages and will clog
>the server. How to remove the callback persisted page, if there is no
>exception raised.
>3. What will be the performance hit by this method.
>
>I would appreciate If any other methodology for generic exception control is
>shared.:))
>
>Very urgent..
>
>Regards,
>@nand
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
You can specify your own Exception page in your .application file, with
the name "Exception", which will override the default Tapestry Exception
page. Then your code for your Exception page can do any specific
exception handling you require.
Callback is probably not what you want. It is used to encapsulate the
state of a page, so that at a later point, another page can use the
callback to effectively redirect back to the saved state of the page
saved. Very useful for wizards that need to "callout" to another wizard
temporarily.
Hope this helps
Richard.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org