You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andreas Kurtz <an...@urz.uni-heidelberg.de> on 2005/11/09 15:11:26 UTC
including error-tiles on validation error / exception
hi folks,
i have some questions on using struts with tiles and the corresponding
error-handling.
we've created a tiles-defintion mainLayout:
<definition name="mainLayout" path="/layout/basicLayout.jsp">
<put name="banner" value="/layout/common/banner.jsp" />
...
<put name="footer" value="/layout/common/footer.jsp" />
</definition>
from which other definitions were derived (e.g. a page displaying a
contact-form):
<definition name="contact" extends="mainLayout">
<put name="content" value="/pages/contact.jsp" />
</definition>
including the following action-mapping (and fitting form-bean):
<action path="/ContactAction"
type="ContactAction" name="ContactForm"
scope="request"
validate="true"
parameter="contact"
input="/Contact.do">
<forward name="success" path="mainLayout" />
<forward name="failure" path="error" />
</action>
we met the following problem:
when a validation-error or an exception appears, the banner-tile in
mainLayout should be replaced with error-banner-tile.
in fact there is the possibility to use forward-directive on failure
(not on validation), but we want to remain on the same input-page
(contact) with just another error-banner-tile included on
validation-error or exception.
is there any handy possibility to solve that problem? or is it the only
way to create a additional error-tile-definition for every page?
thanks for helping.
andy
--
Medizinische Informatik
http://www.mi.uni-heidelberg.de
andreas.kurtz@urz.uni-heidelberg.de
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: including error-tiles on validation error / exception
Posted by Laurie Harper <la...@holoweb.net>.
Andreas Kurtz wrote:
> hi folks,
>
> i have some questions on using struts with tiles and the corresponding
> error-handling.
>
> we've created a tiles-defintion mainLayout:
>
> <definition name="mainLayout" path="/layout/basicLayout.jsp">
> <put name="banner" value="/layout/common/banner.jsp" />
> ...
> <put name="footer" value="/layout/common/footer.jsp" />
> </definition>
>
> from which other definitions were derived (e.g. a page displaying a
> contact-form):
>
> <definition name="contact" extends="mainLayout">
> <put name="content" value="/pages/contact.jsp" />
> </definition>
>
> including the following action-mapping (and fitting form-bean):
>
> <action path="/ContactAction"
> type="ContactAction"
> name="ContactForm"
> scope="request"
> validate="true"
> parameter="contact"
> input="/Contact.do">
> <forward name="success" path="mainLayout" />
> <forward name="failure" path="error" />
> </action>
>
> we met the following problem:
>
> when a validation-error or an exception appears, the banner-tile in
> mainLayout should be replaced with error-banner-tile.
> in fact there is the possibility to use forward-directive on failure
> (not on validation), but we want to remain on the same input-page
> (contact) with just another error-banner-tile included on
> validation-error or exception.
>
> is there any handy possibility to solve that problem? or is it the only
> way to create a additional error-tile-definition for every page?
I don't think there's a way to do that using static definitions in
tiles-defs, but you could include tags in your JSP file to to pull the
appropriate tile in, instead of doing it through tiles-defs -- in other
words, use the <tiles:*/> tags in basicLayout.jsp to include either the
banner-tile or error-banner-tile according to what you need for that
request.
You'd need conditional logic to decide which tile to include. You could
look to see if there are error messages present and switch on that, or
use some other condition specific to your application.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org