This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Arrays" Watch "Arrays" New topic
Author

Arrays

Naveen R R
Greenhorn

Joined: May 04, 2001
Posts: 20
Could anyone please tell me how to correct the following error?
Type mismatch: cannot convert from java.lang.String to security.DeptRoleBean
Code:
public class DeptRoleBean {
private java.lang.String roleId;
----
----
----getter/setter methods----
}
public class OfficeUserBean {
private DeptRoleBean[] deptRole;
-----
----getter/setter methods----
}
public class SecurityTest extends HttpServlet {
private Connection connection = null;
-----
public void performTask(HttpServletRequest req, HttpServletResponse res) {
try {
String roleId = req.getParameter("txtRole_Id");
---------
---------
OfficeUserBean user = new OfficeUserBean();
DeptRoleBean[] deptRole = new DeptRoleBean[5];
deptRole[0] = roleId; //Error
-----
user.setDeptRole(deptRole);
Thanks,
Naveen
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12756
    
    5
"
Could anyone please tell me how to correct the following error?
Type mismatch: cannot convert from java.lang.String to security.DeptRoleBean
"
The error message is telling you exactly what is wrong. You are trying to put a String into an array of DeptRoleBean reference.
k b
Greenhorn

Joined: Feb 01, 2001
Posts: 22
DeptRoleBean[] deptRole = new DeptRoleBean[5];
deptRole[0] = roleId; //Error
This may Help:--
DeptRole tmp = new DeptRole();
tmp.setRoleId(roleID);
deptRole[0] = tmp;
k b
Greenhorn

Joined: Feb 01, 2001
Posts: 22
DeptRoleBean[] deptRole = new DeptRoleBean[5];
deptRole[0] = roleId; //Error
This may Help:--
DeptRole tmp = new DeptRole();
tmp.setRoleId(roleID);
deptRole[0] = tmp;
Naveen R R
Greenhorn

Joined: May 04, 2001
Posts: 20
Thanks, k b. It works now.
Naveen
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Arrays
 
Similar Threads
form:options tag cause error : Bean property is not readable or has an invalid getter method
Getter / Setter inheritance
issue with Xdocler Ant Task
Switch Statement and a String
Inheritance and private variables