Hi,
I am using struts 2.3.3 from maven.
I am using below code which produces messages for user and password twice.
one is default message showing up from not sure where as below.
username is required
password is required
while in my validate method on action I have messages as:
username mandatory
password mandatory
I read few messages related to duplication and they suggest things like
singleton. Well in my case I have basic example from maven tutorial
artifact and it has below files:
*login.jsp*
%@ page contentType=text/html; charset=UTF-8 %
%@ taglib prefix=s uri=/struts-tags %
html
head
titleSign On/title
/head
body
s:form action=Login
s:textfield key=username/
s:password key=password /
s:submit/
/s:form
/body
/html
*Login.java*
/*
* $Id: Login.java 739661 2009-02-01 00:06:00Z davenewton $
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* License); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package tutorial.example;
public class Login extends ExampleSupport {
@Override
public void validate() {
// TODO Auto-generated method stub
super.validate();
if (isInvalid(getUsername())) addFieldError(username,
username
mandatory);
if (isInvalid(getPassword())) addFieldError(password, password
mandatory);
}
public String execute() throws Exception {
if (isInvalid(getUsername())) return INPUT;
if (isInvalid(getPassword())) return INPUT;
return SUCCESS;
}
private boolean isInvalid(String value) {
return (value == null || value.length() == 0);
}
private String username;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
private String password;
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
*struts.xml actually example.xml*
?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE struts PUBLIC
quot;-//Apache Software Foundation//DTD Struts Configuration
2.3//ENquot;
quot;http://struts.apache.org/dtds/struts-2.3.dtdquot;
struts
package name=example namespace=/example extends=struts-default
action name=HelloWorld class=tutorial.example.HelloWorld
result/example/HelloWorld.jsp/result
/action
action name=Login_* method={1} class=tutorial.example.Login
result name=input/example/Login.jsp/result
result type=redirectActionMenu/result
/action
action name=* class=tutorial.example.ExampleSupport
result/example/{1}.jsp/result
/action
/package
/struts
and I invoke the action http://localhost:8080/tutorial/example/Login.action
Regards,
Miten.
--
View this message in context:
http://struts.1045723.n5.nabble.com/duplicate-error-messages-tp5700112.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