I recently got into the implementation of a Struts application, which
I've sadly been away from for quite a while.  There's some issues that
I'm rusty on.  I've searched the archive, but I didn't find enough that
addressed all of my issues.  What I have right now actually works, but I
feel like what I had to do to get it to work was sort of weird (other
LUDA sufferers might just be nodding their heads right now).  I'd
appreciate any comments or suggestions on this.  Sorry this is so long.

The part of the application I'm currently working on is an editing view
of a hierarchical object.  There are numerous text fields and select
boxes that the user can edit.  There are operation buttons that apply to
the whole object, and there are buttons that only apply to specific
sub-objects.  I originally tried using normal buttons (html:submit) for
the "whole object" operations, and image&text links for the sub-object
operations.

For one, I wanted the ability to change arbitrary fields (text, select,
etc.) and then execute any of the operation buttons, which would
preserve the changed value of the fields, along with executing the
operation on the button.  I discovered that using links for sub-object
operations makes this difficult, because a normal link would execute the
operation, but not submit the field values.  I suppose it's possible I
could have gotten this working with some funky javascript, but I decided
to change the links to buttons to avoid that problem.

One annoyance I found was that I had to make sure that each button that
corresponded to a particular operation was named differently (the label,
that is) from all other buttons, even if it was obvious from the visual
context that the name could have been shorter.  This is a result of how
LUDA works, and I couldn't find any way around this.

Then, I encountered difficulties using an image button (html:image) with
LUDA.  To cut this short, I ended up with jsp code like this (using
Struts-EL):

  <html:image onclick="setIndex(${status.index});"
              page="/images/delete.gif" property="submitMethod"
              value="deleteThing"/>

(The javascript is to set a hidden form parameter to specify the index
of the list I'm operating on.)

Along with these other two excerpts:

resources.properties:
  sym.deleteThing       = deleteThing

getKeyMethodMap():
  result.put("sym.deleteThing", "deleteThing"); // Find "deleteThing"
method

Again, this works, it's just really weird.  In my archive search, I
noticed a note by Mark Lowe suggesting that you should just be able to
nest a "bean:message" inside the "html:image" to determine the submit
value, but this didn't work.

Related to this, I noticed that the behavior of the HTML "button"
element (type "submit") is different from the "input" element of the
same type.  It has more rational behavior with respect to letting you
control what shows on the button vs. what value is submitted.  This is
specified in HTML 4.0.1, but I have a feeling that it didn't exist
before that version.

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

Reply via email to