Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Struts
getXXX error?? for XXXX
Ashimashi Kabashi
Ranch Hand
Posts: 84
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am using HashMaps instead of the getXXX and setXXX methods
this is my LoginFormBean
public class LoginFormBean extends org.apache.struts.action.ActionForm { /* private int age; private String platform; private boolean tierView; private boolean tierModel; private boolean tierController; private String name; private String story; private String email; private String gender; */ private HashMap attributeMap = new HashMap(); private Map getMap(){ return attributeMap; } public HashMap getAttributeMap() { return attributeMap; } public void setAttributeMap(HashMap attributeMap) { this.attributeMap = attributeMap; } public void setAttribute(String attributeKey, Object attributeValue){ getMap().put(attributeKey, attributeValue); } public Object getAttribute(String attributeKey){ Object holder = getMap().get(attributeKey); if(holder==null) return ""; return holder; } public LoginFormBean() { super(); // TODO Auto-generated constructor stub } @Override public void reset(ActionMapping mapping,HttpServletRequest request){ setAttribute("tierView",false); setAttribute("tierController",false); } @Override public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if ((String)getAttribute("name") == null || ((String)getAttribute("name")).length() < 1) { errors.add("name", new ActionMessage("error.name.required", "name")); // TODO: add 'error.name.required' key to your resources } if ((String)getAttribute("age") == null || ((String)getAttribute("age")).length() < 1) { errors.add("age", new ActionMessage("error.name.required", "age")); // TODO: add 'error.too.small' key to your resources } /* if (Integer.parseInt((String)getAttribute("age")) < 18) { errors.add("age", new ActionMessage("error.too.small", "age")); // TODO: }*/ if ((String)getAttribute("email") == null || ((String)getAttribute("email")).length() < 1) { errors.add("email", new ActionMessage("error.name.required", "email")); // TODO: add 'error.name.required' key to your resources } if ((String)getAttribute("story") == null || ((String)getAttribute("story")).length() < 1) { errors.add("story", new ActionMessage("error.name.required", "story")); // TODO: add 'error.name.required' key to your resources } return errors; } }
and here is my
jsp
:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Welcome to JavaEdge!</title> </head> <body> <%@ include file="header.jsp" %> <html:form action="login" method="POST" onsubmit="return(validateLogin(this);"> <table border="1"> <thead> <tr> <th colspan="3">Enter Information</th> </tr> </thead> <tbody> <tr> <td><bean:message key="age"/></td> <td><html:text property="attribute(age)"/></td> <td> <html:errors property="attribute(age)"/></td> </tr> <tr> <td>Name</td> <td><html:text property="attribute(name)"/></td> <td> <html:errors property="attribute(name)"/></td> </tr> <tr> <td>Story</td> <td><html:textarea property="attribute(story)"/></td> <td> <html:errors property="attribute(story)"/></td> </tr> <tr> <td>Email</td> <td><html:text property="attribute(email)"/></td> <td> <html:errors property="attribute(email)"/></td> </tr> <tr> <td>Gender</td> <td> <html:radio property="attribute(gender)" value="male" /> Male <html:radio property="attribute(gender)" value="female"/> Female </td> <td></td> </tr> <tr> <td>Platforms (from select values)</td> <td> <html:select property="attribute(platform)"> <html :-o ption value="XML"/> <html :-o ption value="MySQL"/> <html :-o ption value="Struts"/> <html :-o ption value="JSF"/> </html:select> </td> <td> </td> <tr> <td>Tier Experience on</td> <td> <html:checkbox property="attribute(tierView)"/> View<br/> <html:checkbox property="attribute(tierController)"/> Controller<br/> <html:checkbox property="attribute(tierModel)"/> Model<br/> </td> <td> </td> </tr> <%-- --%> </tbody> </table> <html:submit value="submit"/> </html:form> </body> <%@ include file="footer.jsp" %> </html>
Ashimashi Kabashi
Ranch Hand
Posts: 84
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The error message that I am getting is
javax.servlet.jsp.JspException: No getter method for property: "name" of bean: "LoginFormBean"
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
problem in logic:iterate
>html:text < default value
Can i use html:file with other input fields?
how to iterate.
Formatting the Errors
More...