This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes problem in html:image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in html:image" Watch "problem in html:image" New topic
Author

problem in html:image

shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
i use this html:image tag but there is erro . please solve this i write

<html:form action="userManage.do" method="post">
<html:hidden property="accountId" value="${uList.accountId}"/>
<td>
<html:image src="include/b_drop.png" property="submit" value="Delete" alt="Delete Account"/>

</td>

</html:form>


error is

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


root cause

java.lang.IllegalArgumentException: No bean specified
org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The html:image tag looks OK to me. Since what you've posted is clearly a fragment of the page, it's possible that some other tag on the page other than this one is causing the problem. The exception you're getting usually occurs when you have non-String properties in your ActionForm. Check your ActionForm for non-String types and change them to String.
[ April 12, 2008: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
i am only string variable ?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I'd suggest changing the name of the submit property to something else. I've seen strange things happen because the name "submit" is a javaScript property of a form, and overwriting that name can cause odd behavior.

I'd also try removing the value attribute from your html:image tag and changing the type of the botton's property in your ActionForm to org.apache.struts.util.ImageButtonBean. This is a class that was specifically written to go along with the html:image tag. It has an "isSelected" method you can use to determine if it's been pressed or not. You should also have a different ActionForm property for each button, such as deleteButton, updateButton, insertButton, etc.
[ April 13, 2008: Message edited by: Merrill Higginson ]
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
<html:form action="userManage.do" method="post">
<html:hidden property="accountId" value="${uList.accountId}"/>
<td valign="middle">
<!--html:submit property="submit" value="Delete"/-->
<html:image src="include/images/b_drop.png" property="sub" value="Delete" alt="Delete Account" />
</td>

<c:choose>
<c:when test="${uList.status == '0'}">
<td valign="middle"><html:submit property="sub" value=" Enable"/></td>
</c:when>
<c:when test="${uList.status == '1'}">
<td valign="middle"><html:submit property="sub" value="Disable"/></td>
</c:when>
</c:choose>
</html:form>


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: BeanUtils.populate
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:495)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


root cause

java.lang.IllegalArgumentException: No bean specified
org.apache.commons.beanutils.PropertyUtilsBean.getPropertyDescriptor(PropertyUtilsBean.java:751)
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:937)
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:811)
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:298)
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:493)
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:816)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:203)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.14
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can't have an html:image button and an html:submit button both use the same property. Two submit buttons can share the same property name, but not a submit button and an html:image button. I believe that's what's causing the exception. I'd also suggest you take the advice I gave you in my last post and remove the value attribute from your html:image button. This type of button simply does not work the same as an html:submit button. It must have it's own property, and that property shold be of type ImageButtonBean.
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
thanks but there is problem

how to know which image is selected


please tell me
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
As I mentioned in a previous post, the ImageButtonBean has an isSelected method that will return true if the button was selected and false if it was not.
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
sorry to you i can't understand what to check image is selected

please check my code and tell what is error in this


This is my code in jsp
<html:form action="userManage.do" method="post">
<html:hidden property="accountId" value="${uList.accountId}"/>
<td valign="middle">
<!--html:submit property="submit" value="Delete"/-->
<html:image src="include/images/b_drop.png" property="img" alt="Delete Account"/>
</td>

<c:choose>
<c:when test="${uList.status == '0'}">
<td valign="middle"><html:submit property="sub" value=" Enable"/></td>
</c:when>
<c:when test="${uList.status == '1'}">
<td valign="middle"><html:submit property="sub" value="Disable"/></td>
</c:when>
</c:choose>
</html:form>


This is my action class

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ActionClasses;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import Beans.UserManageBean;
import DAO.BankDAO;
import org.apache.struts.util.ImageButtonBean;

public class UserManageAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

BankDAO pDAO = new BankDAO();
UserManageBean user = (UserManageBean) form;

String login = user.getAccountId();
String submit = user.getSub();
//String img = user.getImg();

ImageButtonBean image = new ImageButtonBean();

boolean ii = image.isSelected();
if(ii){
pDAO.deleteAccount(login);
}

if (submit.trim().equals("Enable")) {
pDAO.setUserStatus(login, "1");
} else if (submit.equals("Disable")) {
pDAO.setUserStatus(login, "0");
} else if (submit.equals("Delete")) {
pDAO.deleteAccount(login);
}
return mapping.findForward("success");
}//execute
}//class

This is bean class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Beans;

import org.apache.struts.action.*;
/**
*
* @author Shahid
*/
public class UserManageBean extends ActionForm {

private String accountId , sub,img;

public String getAccountId() {
return accountId;
}

public void setAccountId(String accountId) {
this.accountId = accountId;
}

public String getSub() {
return sub;
}

public void setSub(String submit) {
this.sub = submit;
}

public String getImg() {
return img;
}

public void setImg(String img) {
this.img = img;
}

}//class

//
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In Action class, change:

To

and change

to

Then, in UserManageBean, change the type of img from String to ImageButtonBean and adjust getters and setters for this change.
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
i change my according to your instruction but still same error i write my code

this is jsp code

<html:form action="userManage.do" method="post">
<html:hidden property="accountId" value="${uList.accountId}"/>
<td valign="middle">
<html:image src="include/images/b_drop.png" property="img" alt="Delete Account"/>
</td>

<c:choose>
<c:when test="${uList.status == '0'}">
<td valign="middle"><html:submit property="sub" value=" Enable"/></td>
</c:when>
<c:when test="${uList.status == '1'}">
<td valign="middle"><html:submit property="sub" value="Disable"/></td>
</c:when>
</c:choose>
</html:form>

this bean code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package Beans;

import org.apache.struts.action.*;
import org.apache.struts.util.ImageButtonBean;
/**
*
* @author Shahid
*/
public class UserManageBean extends ActionForm {

private String accountId , sub;
private ImageButtonBean img;

public String getAccountId() {
return accountId;
}

public void setAccountId(String accountId) {
this.accountId = accountId;
}

public String getSub() {
return sub;
}

public void setSub(String submit) {
this.sub = submit;
}

public ImageButtonBean getImg() {
return img;
}

public void setImg(ImageButtonBean img) {
this.img = img;
}

}//class

this is my action class

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ActionClasses;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import Beans.UserManageBean;
import DAO.BankDAO;
import org.apache.struts.util.ImageButtonBean;

public class UserManageAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

BankDAO pDAO = new BankDAO();
UserManageBean user = (UserManageBean) form;

String login = user.getAccountId();
String submit = user.getSub();

ImageButtonBean image = user.getImg();

if (submit.trim().equals("Enable")) {
pDAO.setUserStatus(login, "1");
} else if (submit.equals("Disable")) {
pDAO.setUserStatus(login, "0");
} else if (image.isSelected()) {
pDAO.deleteAccount(login);
}
return mapping.findForward("success");
}//execute
}//class
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
When you say "same error", do you mean:

java.lang.IllegalArgumentException: No bean specified

? If not, give us the exact error message you're getting. I don't see anything in the code you've shown me that would throw this exception. Are you showing us the entire JSP? I still think there may be something totally unrelated to the code you've posted that may be causing the error.
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
this jsp page has many forms (4-5) and this page is also include in other jsp page which is main page

problem is same as first
Laxmikant Ruikar
Greenhorn

Joined: Nov 29, 2005
Posts: 23
Let me know when you get an error
1) While rendering the JSP page
2) Or after submitting the page

Try to remove your html:image tag for time being, then see what happen
shahidrasul shahid
Ranch Hand

Joined: Jan 28, 2008
Posts: 62
when i click the image button then error receive otherwise no error


when i remove html:image there is no error
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in html:image
 
Similar Threads
file uploading error
execption struts-layout
Problem with Refresh + when doing refresh, not invoking action
Beans.Populate
how to pass object from jsp to action class in struts???