struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <>
Subject Re: Validator framework hijacks requests! :(
Date Sun, 13 Nov 2005 01:24:37 GMT
The trick is to only include validation on the data processing actions, 
not on the pre-display actions (i.e. use validate="false" on your 
preCreate action mapping, and only put validate="true" on the action you 
submit the form to). Then set the 'input' attribute for your validating 
actions to point to the pre-population action (so when validation fails, 
Struts forwards to preCreate, not directly to the JSP).

You don't need to use session scope for anything if you don't want to, 
you just have to make sure that you always display your JSP via your 
preCreate action.

If that doesn't make sense, post your action mappings from 
struts-config.xml so we can see how you have things setup.


Raghu Kanchustambham wrote:
> I think I can explain it now.
>  I hit the action servlet first invoking preCreate function. This function
> populates various lists of beans needed for dropdowns and put these lists in
> the request object and forward to a JSP. The JSP reads these lists and
> displays the dropdowns. So far so good!
>  preCreate --->request object populated with lists ---> JSP reads from
> request for dropdown lists
>  Now... enter the Validation framework! I think it is hijacking this series!
>  preCreate ---> request populated with lists ---> Validator framework --->
>  Now the jump from Validator framework to JSP means that all request scope
> objects (the lists) are lost! :(
>  How should I architect ? Should I make these lists session scope? I somehow
> dont like to make them session scope, because they are really request scope!
>  Can someone comment on my explanation / help me with a solution ??
>   Thanks much.
> Regards,
> Raghu
>  On 11/12/05, Martin Gainty <> wrote:
>>I didnt see the contents E.G. <tag> </tag> for your c.tld ??
>>----- Original Message -----
>>From: "Raghu Kanchustambham" <>
>>To: "Struts Users Mailing List" <>
>>Sent: Saturday, November 12, 2005 10:37 AM
>>Subject: Re: Fw: Validator framework introduces errors
>>Hi Martin,
>>I do something like:
>>before invoking the jsp.
>>The strange part is, the minute i remove validation.xml from the validator
>>path, effectively removing the validation framework, every thing works
>>fine! Just cant explain it ! :(
>>Thanks again in advance to anyone who can explain this!
>>Please find the StudentEnquiry.jsp attached.
>><%@ page import="
>><%@ page language="java" %>
>><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
>><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
>><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
>><%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
>><%@ taglib uri="/WEB-INF/struts-layout.tld" prefix="layout" %>
>><title>Student Enquiry</title>
>><link rel="stylesheet" type="text/css" href="../mystyle.css" />
>><SCRIPT>function set(target) {document.forms
>><h2>Student Enquiry</h2>
>><c:set var="operationVar">
>><%= request.getParameter("nextOperation")%>
>><c:set var="readOnlyForm"> false </c:set>
>><c:if test="${operationVar=='null' || operationVar=='ok'}"> <!-- view
>>have a Next operation -->
>><c:set var="readOnlyForm"> true </c:set>
>><html:form action=""
>><input type="hidden" name="operation"
>><table width="100%">
>><td rowspan="2">
>><%@include file="StudentDemographics.jsp"%>
>><layout:grid cols="2">
>><layout:select property="enquiryCentreId" size="${selectBoxSize}"
>>key="Enquiry Centre">
>><layout:options collection ="centreList" property="id" labelName="name" />
>><layout:select property="enquiryCourseId" size="${selectBoxSize}"
>>key="Enquiry Course">
>><layout:optionsCollection name="courseList" value="id" label="name"/>
>><td align="center">
>><html:submit>${operationVar} </html:submit>
>>On 11/12/05, Martin Gainty <> wrote:
>>>I did'nt see the (StudentEnquiry.jsp) jsp page which references
>>>I also dont see the code for centreList bean?
>>>----- Original Message -----
>>>From: "Raghu Kanchustambham" <>
>>>To: "Struts Users Mailing List" <>
>>>Sent: Saturday, November 12, 2005 9:40 AM
>>>Subject: Validator framework introduces errors
>>>The minute I introduced Validator framework in my application .....
>>>it started giving me the following error when I accessed the JSP ....
>>>centreList is used as a parameter for the dropdown. The minute I remove
>>>validation.xml from the path... the application runs fine again! :(
>>>very strange and i am not able to explain this behavior .. can someone
>>>Thanks much in advance.
>>>javax.servlet.jsp.JspException: Cannot find bean centreList in any scope
>>>My validation.xml (very simple one):
>>><!DOCTYPE form-validation PUBLIC
>>>"-//Apache Software Foundation//DTD Commons Validator Rules
>>>Configuration 1.0//EN"
>>><form name="studentEnquiryForm">
>>><field property="studentEnquiry.firstName" depends="required">
>>><arg0 key="firstName.mandatory"/>

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message