You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rubens <ru...@hotmail.com> on 2008/01/24 09:00:50 UTC

[S2] fieldError - highlight input field using "simple" theme?

I have a form with multiple input fields, and I am using the "simple" theme. 
Is it possible to determine (maybe using <s:if..>) when a given field fails
validation? I already tried hasFieldErrors(); however, hasFieldErrors() does
not allow me to distinguish which field on the form fails.

Here is what I want:

  <s:form method="POST" action="login_doLogin" validate="true"
cssClass="homeLoginForm">
    <fieldset>
      <s:actionerror />

      <label for="loginId">
        <s:text name="label.loginId" />
      </label>
      <s:if test="<field loginId is okay -- what do I put here???">
        <s:textfield required="true" id="loginId" name="loginId" size="25"
maxlength="100"  />
     </s:if>
     <s:else>
       <s:textfield required="true" id="loginId" name="loginId" size="25"
maxlength="100"  cssClass="error"  />
     </s:else>
     <s:fielderror name="loginId" >
        <s:param>loginId</s:param>
      </s:fielderror>

      <label for="password">
        <s:text name="label.password" />
      </label>
      <s:if test="<field password is okay -- what do I put here???">
        <s:password required="true" id="password" name="password" size="25"
maxlength="10" showPassword="true" />
      </s:if>
      <s:else>
        <s:password required="true" id="password" name="password" size="25"
maxlength="10" showPassword="true" cssClass="error" />
      </s:else>
      <s:fielderror>
        <s:param>password</s:param>
      </s:fielderror>

      <s:submit key="button.signIn" type="submit" />

    </fieldset>
  </s:form>

-- 
View this message in context: http://www.nabble.com/-S2--fieldError---highlight-input-field-using-%22simple%22-theme--tp15060201p15060201.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] fieldError - highlight input field using "simple" theme?

Posted by Dave Newton <ne...@yahoo.com>.
            <s:if test="getFieldErrors().get('name') != null">

I'd probably urge you to modify an existing template or create your own,
though.

d.

--- Rubens <ru...@hotmail.com> wrote:

> 
> I have a form with multiple input fields, and I am using the "simple"
> theme. 
> Is it possible to determine (maybe using <s:if..>) when a given field fails
> validation? I already tried hasFieldErrors(); however, hasFieldErrors()
> does
> not allow me to distinguish which field on the form fails.
> 
> Here is what I want:
> 
>   <s:form method="POST" action="login_doLogin" validate="true"
> cssClass="homeLoginForm">
>     <fieldset>
>       <s:actionerror />
> 
>       <label for="loginId">
>         <s:text name="label.loginId" />
>       </label>
>       <s:if test="<field loginId is okay -- what do I put here???">
>         <s:textfield required="true" id="loginId" name="loginId" size="25"
> maxlength="100"  />
>      </s:if>
>      <s:else>
>        <s:textfield required="true" id="loginId" name="loginId" size="25"
> maxlength="100"  cssClass="error"  />
>      </s:else>
>      <s:fielderror name="loginId" >
>         <s:param>loginId</s:param>
>       </s:fielderror>
> 
>       <label for="password">
>         <s:text name="label.password" />
>       </label>
>       <s:if test="<field password is okay -- what do I put here???">
>         <s:password required="true" id="password" name="password" size="25"
> maxlength="10" showPassword="true" />
>       </s:if>
>       <s:else>
>         <s:password required="true" id="password" name="password" size="25"
> maxlength="10" showPassword="true" cssClass="error" />
>       </s:else>
>       <s:fielderror>
>         <s:param>password</s:param>
>       </s:fielderror>
> 
>       <s:submit key="button.signIn" type="submit" />
> 
>     </fieldset>
>   </s:form>
> 
> -- 
> View this message in context:
>
http://www.nabble.com/-S2--fieldError---highlight-input-field-using-%22simple%22-theme--tp15060201p15060201.html
> Sent from the Struts - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


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