You could use 'addFieldError' in your action class for the zipcode field that contains the error. Then use the 'cssErrorClass' attribute in the s:textfield tag to change the display of the 'error' textfield. Each of your textfields will have to have a unique name in order to add the field error.
Eg: addFieldError("zipcode1"); <s:textfield name='zipcode1' cssErrorClass='errorClass' /> The errorClass would have CSS attributes to change the color, etc. On 10/12/09, Alex Siman <aleksandr.si...@gmail.com> wrote: > > Try to add next code: > > <s:set var="zipCodeErrors" value="%{fieldErrors['zipCode[' + > #rowstatus.index + ']']}"/> > <s:textfield ... cssStyle="%{(#zipCodeErrors != null && > #zipCodeErrors.size > 0) ? 'border: 1px solid red;' : ''}" ... /> > > james billa wrote: >> >> Hi, >> >> I have a field called "Preferred Zip codes : ". The user is provided with >> 10 >> textfields for this to enter. >> He may enter 1 or more and submit the form. If any of the zip codes that >> he >> entered is not in my >> database, I need to change the border color of that textfield containing >> incorrect zip code alone to red and >> show the form back to user. >> >> How do I do this using Struts 2.1.6. I already know in my action class >> about >> the incorrect field. In JSP I have >> constructed text fields using <s:iterator> with value as dummy string >> array >> of size 10. Everything looks good. >> >> How to connect the error in action to the field on the screen (Again the >> field is constructed using S:Itertaor>). >> >> Any help on this appreciated. >> >> Here is the code snippet.. >> String[] zipCode = new zipCode[10]; >> >> <s:iterator value="zipCodeList" var="Zcode" status="rowstatus"> >> <td align="center"> >> <s:textfield >> required="true" name="zipCode" id="%{'zipCode[' + >> (#rowstatus.index) + ']'}" >> value="%{Zcode}" cssClass="textbox" >> required="true" >> size="5" theme="simple"/> >> </td> >> <s:if test="((#rowstatus.index + 1) %6) == 0"> >> </tr> >> <tr> >> </s:if> >> >> </s:iterator> >> >> Thanks, >> JB >> >> > > -- > View this message in context: > http://www.nabble.com/Changing-the-border-color-of-a-text-field-tp25861145p25862090.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org