struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris <christal...@yahoo.fr>
Subject Re: 2.3.16.3 Color in error message ( Authenticate Login )
Date Wed, 04 Jun 2014 20:18:25 GMT

Hello,
Thank You, 
I found also the <s:head /> tag in the  http://struts.apache.org/development/2.x/docs/form-validation.html

Styling The Error Messages
The Struts 2 s:head tag can be used to provide CSS that includes a style 
for the error message. Add <s:head /> to register.jsp before the closing HTML </head>
tag. 

Regards,

Chris



Le Mercredi 4 juin 2014 20h37, Martin Gainty <mgainty@hotmail.com> a écrit :
 



stylesheet.css:

.errClass {
    font-family: Verdana, Helvetica, Garamond, sans-serif;
    /* font-size: 0.7em; */
    background-color: red;
    border: 1px solid #afafaf;
    position: absolute;
    z-index: 1000;
    overflow: auto;
    cursor: default;
}
public void validate() 
{
      if (userName.length() != 0 && password.length() != 0 && !(AuthenticateUser(userName,
password))) 
      {
       org.apache.struts2.views.jsp.ui.TextFieldTag tag = new org.apache.struts2.views.jsp.ui.TextFieldTag();
        tag.setPageContext(pageContext);
        tag.setId("myId");
        tag.setLabel("mylabel");
        tag.setName("foo");
        tag.setValue("bar");
        tag.setTitle("mytitle");
        tag.setCssErrorClass("errclass");

        testAction.addFieldError("foo", "bar error message");
     }
} //end validate

Bon Chance,
Martin 
_________________


> Date: Wed, 4 Jun 2014 17:13:28 +0100
> From: christalkto@yahoo.fr
> Subject: 2.3.16.3 Color in error message ( Authenticate Login ) 
> To: user@struts.apache.org
> 
> Hello, 
> 
> 
> I don't find in the strutsexamples ( 6 form_validation, 7 message_ressource...etc) where
I could write red color when error message is displayed in loginForm.jsp
> 
> 
> First the validator LoginAction-validation.xml works fine with required fields.
> 
> 
> Then the authentication with LoginAction works or not. 
> 
> 
> But I would like to write red error when the authentication fails.
> 
> ...
>     public void validate() {
>         if (userName.length() != 0 && password.length() != 0 && !(AuthenticateUser(userName,
password))) {
>             addFieldError("userName", " The Identification has failed"); 
>         }
>     }
> 
> When the Authenticate fails, the message works with "The Identification has failed" ,
but the color is not red in the loginForm.jsp...
> 
> 
> Regards
> 
> Chris
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message