You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jobiwan11 <ja...@gmail.com> on 2010/04/30 01:48:48 UTC

Error out in middle of page without filling in remaining components

Let's say you encounter an error halfway through the constructor of a page,
and you want to display error("error message") and then return without
processing rest of components?  It doesn't seem like this is possible in
wicket because it makes you fill in all components or else it barfs.
Am I wrong, or is there a way to do this in wicket?
Thanks,
-jim
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Error-out-in-middle-of-page-without-filling-in-remaining-components-tp2076364p2076364.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Error out in middle of page without filling in remaining components

Posted by Jeremy Thomerson <je...@wickettraining.com>.
you would have to fill in the component hierarchy.  i suppose you could fill
the rest of the components as invisible webmarkupcontainers, but this sounds
very cumbersome.  My typical mode of operation for this sort of thing is to
do this:

getSession().error(your error)
throw new
RestartResponseAtInterceptPageException(SomeOtherPageWhichIsTypicallyMyHomePage.class)

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



On Thu, Apr 29, 2010 at 6:48 PM, jobiwan11 <ja...@gmail.com> wrote:

>
> Let's say you encounter an error halfway through the constructor of a page,
> and you want to display error("error message") and then return without
> processing rest of components?  It doesn't seem like this is possible in
> wicket because it makes you fill in all components or else it barfs.
> Am I wrong, or is there a way to do this in wicket?
> Thanks,
> -jim
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Error-out-in-middle-of-page-without-filling-in-remaining-components-tp2076364p2076364.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

SV: Error out in middle of page without filling in remaining components

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> Let's say you encounter an error halfway through the constructor of a
> page,
> and you want to display error("error message") and then return without
> processing rest of components?  It doesn't seem like this is possible
> in
> wicket because it makes you fill in all components or else it barfs.
> Am I wrong, or is there a way to do this in wicket?

1) Ideally, a constructor does NOTHING other than
   - validate arguments, and throw necessary exception if they are wrong
   - set properties (no side-effects) that will be used by other "business" methods later

In Wicket, Swing etc., the latter also covers setting up component hierarchies. So actual errors should only appear later, e.g. as a consequence of a LDM failing to connect to a database at render time.

2) If that is not an option, the way to interrupt a constructor is the same way as for any other method, throw and exception. For instance a WicketRuntimeException.

- Tor Iver


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