Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 59050 invoked from network); 26 Jun 2008 02:15:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Jun 2008 02:15:09 -0000 Received: (qmail 37740 invoked by uid 500); 26 Jun 2008 02:15:01 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 37710 invoked by uid 500); 26 Jun 2008 02:15:01 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 37699 invoked by uid 99); 26 Jun 2008 02:15:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jun 2008 19:15:01 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bobfuller30004@hotmail.com designates 65.54.246.154 as permitted sender) Received: from [65.54.246.154] (HELO bay0-omc2-s18.bay0.hotmail.com) (65.54.246.154) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Jun 2008 02:14:09 +0000 Received: from BAY125-W47 ([65.55.130.82]) by bay0-omc2-s18.bay0.hotmail.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 25 Jun 2008 19:14:28 -0700 Message-ID: X-Originating-IP: [63.224.248.213] From: bob fuller To: Subject: Struts 2 - Repopulate controls when validation fails Date: Thu, 26 Jun 2008 02:14:28 +0000 Importance: Normal Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginalArrivalTime: 26 Jun 2008 02:14:28.0423 (UTC) FILETIME=[5CBC2570:01C8D732] X-Virus-Checked: Checked by ClamAV on apache.org I'm following the "How do we repopulate controls when validation fails" FAQ= located at... http://struts.apache.org/2.x/docs/how-do-we-repopulate-controls-when-valida= tion-fails.html Of the two methods it suggests I am trying to use the 'action tag' method. = Using the simple example from the FAQ works fine, but once I move beyond th= e simple and try to drop my "Languages" control inside the tag of another = action I have problems. Here's my pseudo JSP (note MyAction)... MyAction implements validateable and I am validating foo0 and foo1 inside t= he validate() method. Here's my validate() code... public void validate() { if (foo0 =3D=3D null || foo0.length() =3D=3D 0) addFieldError("foo0", "Foo0 is required"); else foo0 =3D foo0 + " VALIDATED"; if (foo1 =3D=3D null || foo1.length() =3D=3D 0) addFieldError("foo1", "Foo1 is required"); else foo1 =3D foo1 + " VALIDATED"; =09 } The important thing to note about my validation code is that when the valid= ation succeeds the data entered by the user is updated with the word "VALID= ATED". This may seem like an odd thing to do, but it's part of the requirem= ents of the project I'm working on. Visiting http://localhost/MyAction/myAction_input.action works great. The p= age draws, foo0 is empty, the languages control has languages to choose fro= m, foo1 is empty, the submit button appears. Submitting the form is when I = get into problems. Here are three submit paths and their results... 1. foo0 is empty, foo1 is empty. click submit. RESULT - foo0 is empty. foo1= is empty. SUCCESS! 2. foo0 =3D 'A', foo1 is empty. click submit. RESULT - page redraws. foo0 = =3D 'A VALIDATED'. foo1 is empty. SUCCESS! 3. foo0 is empty, foo1 =3D 'A'. click submit. RESULT - page redraws. foo0 i= s empty. foo1 =3D 'A'. FAIL! - foo1 should say 'A VALIDATED' For some reason MyAction.setFoo1() is being invoked *again* after I set foo= 1 to 'A VALIDATED' in my validate() code. Why is that happening? I know it = has something to do with the Languages control that appears before the foo1= text field, because when I remove the Languages control everything works a= s expected. Anyone have any ideas about what the Languages control is doing that is cau= sing my foo1 field to get reset to the original submit value? I'd really li= ke to be able to use the 'action tags' approach for repopulating controls, = but 'dropping wherever', as suggested in the FAQ (see link above), does not= seem to be as easy as it sounds. Thanks. =20 _________________________________________________________________ The other season of giving begins 6/24/08. Check out the i=92m Talkathon. http://www.imtalkathon.com?source=3DTXT_EML_WLH_SeasonOfGiving= --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org