Hi all,

I have a bit of a problem grasping how to implement a seemingly simple
thing with struts. What I want to do is have a JSP page listing items
each with its own Delete or Edit button, like this:

        Chocolate       |Delete|  |Edit|     (index 0)
        Bananas         |Delete|  |Edit|        "   1
        Chips           |Delete|  |Edit|        "   2

Both buttons should be images, which leads me to use the
<html:image>-Tag. Now when one of these buttons gets clicked, I would
ideally have "value" attributes set containing the index, so that I can
differentiate on the server which button has been clicked. That is
actually how I implemented it at first, and it works nicely under
Mozilla.

Unfortunately, IE does not send the "value" attribute's content, but
only the deleteButton.x and deleteButton.y (or editButton.x/y) values
indicating where a particular button has been clicked.

Now I thought, "Ahh, that's what the indexed property on html:image is
for! Using it ensures that the index gets transferred as part of the
name of the button!" So I changed my form bean to contain one
"editButtons" and one "deleteButtons" definition, both of type
HtmlButton[]. The HtmlButton class simply accepts either x or y or a
value, and assumes the button has been pressed if at least one of these
is set, a state that can be queried via the pressed() method. [1]

Unfortunately, all I get when clicking on one of the buttons is a
ServletException in BeanUtils.populate, caused by an
ArrayIndexOutOfBoundsException [2].

Is the approach completely wrong, or is there some way to set the length
of the Arrays? I'm at a loss here and would really appreciate some help.

Cheers,
Thomas

[1] This is actually a class taken from here:
        http://j2ee.lagnada.com/struts/html-buttons.htm

[2] javax.servlet.ServletException: BeanUtils.populate
        at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
        at 
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
        [...]
    root cause:
    java.lang.ArrayIndexOutOfBoundsException
        at java.lang.reflect.Array.get(Native Method)
        at org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:296)
        at 
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:475)
        at 
org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:429)
        [...]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to