I want to be able to processes similar events with a single Action class. I
know the Struts framework provides both DispatchAction and
LookupDispatchAction. All my events where method=post are invoked with an
input element of type image. The request parameters for such an element are
name.x and name.y with their corresponding values being the respective
coordinates of the image where it was clicked. If I weren't using image
buttons but rather submit buttons, then the LookupDispatchAction is what I
would need. But since I'm using image buttons and not submit buttons,
neither XXXXDispatchAction can handle dispatching to the appropriate
handler. ( Correct me if I'm missing something obvious here)

The logical premise in both DispatchAction and LookupDispatchAction  is a
known request parameter which will contain a value which is either the
explicite method to invoke or is the key to the explicite method to invoke.
Since image buttons parameter values are just x-y coordinates, then they
provide no such information.

A client-side solution would be to use Javascript, to set a particular value
when the image is clicked.

A server-side solution would be to provide a comma delimited list of
possible user gestures (ie. cancel, save, delete) in the parameter attribute
of the action element. A subclass of DispatchAction, call it
ImageButtonDispatchAction, captures and parses those values, and then looks
for the first one that appears as a request parameter name + ".x" . If
found, it invokes the approapriate method.


<action path="/saveSubscription"
            type="org.apache.struts.actions.ImageButtonDispatchAction"
            name="subscriptionForm"
           scope="request"
           input="/subscription.jsp"
       parameter="cancel,save"/>


Is there a more elegant solution for this?


robert


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

Reply via email to