Hello

Struts 2 in action is good book to resolve yours questions.

Greeting


----- Original Message ----- From: "Eileen Hurley" <eileen.hur...@rockalltech.com>
To: <user@struts.apache.org>
Sent: Thursday, October 22, 2009 10:07 AM
Subject: Struts 2 Validation issues

All,



I have problems with xml validation and Struts 2 (2.0.14). The
validation as I see it is not displaying the error messages (I extend
ActionSupport). The defaultstack includes the validation interceptor.



I believe the problem is related to my struts.xml configuration and the
interceptor I use but I can't be sure. The only way I can get the
fielderrors displayed on my jsp is to check the fielderors in the method
generate but I thought (like Struts 1) it should never get to the
generate method.  Instead of success redirecting to a jsp if it's a
success I want to go to the previous page which seems to work.



In summary my questions are as follows:

Q1: When do I need to use the execute method?

Q2: I assume I don't need to specify fieldserror in my code
(implementing the ValidationAware should be enough)

Q3: If I need to persist the items for re-display on the input page -
what do I need to do to achieve this?

Q4: Do I need to use the Workflow interceptor?





Any help would be appreciated.

Eileen.



StratifySiteVisits.java

.

.

.

.



public String generate() throws Exception {

Map fieldErrors = getFieldErrors();
           if (fieldErrors != null || fieldErrors.size() > 0 ){

             return INPUT;

           }

......

return "navigationback"



}



Validation xml file:
StratifySiteVisits-stratifySiteVisitsGenerate-validation.xml


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
     "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd";>

<validators>

 <field name="sampleSize">

   <field-validator type="requiredstring">

     <param name="trim">true</param>

     <message>Sample Size is required</message>

   </field-validator>

 </field>

</validators>



Action


Struts.xml



<action name="stratifySiteVisitsGenerate" method="generate"
class="com.cmo.action.sitevisits.stratify.StratifySiteVisits">

     <result
name="input">jsp/sitevisits/stratify/stratifySiteVisitsLoans.jsp</result


     <interceptor-ref name="defaultStack">

          <param name="navigation.action">previousScreen</param>

     </interceptor-ref>

</action>







---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to