struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Crossley <jcross...@ifleet.com>
Subject Re: how to use an images for submit, cancel button etc
Date Fri, 22 Feb 2002 21:20:37 GMT
I don't think you need the onclick events for <html:image> tags.  I
*think* they're all going to submit your form anyway.  So in your
action, you'll need to look at the request to see which button the
user pressed.  Image inputs are tricky though, because instead of just
their name (or value, I can't remember which), you get the X/Y
coordinate of the mouse click.  So your snippet becomes:

<!-- JSP Snippet-->
<html:image property="submit" pageKey="button.save" border="0"/>
<html:image property="cancel" pageKey="button.cancel" border="0"/>
<html:image onclick="javascript:reset" pageKey="button.reset" border="0"/>
<!-- End 'o snippet -->

And your action class will have stuff like this:

  if (request.getParameter("submit.x") != null) {
      ... do submit stuff ...
  }
  if (request.getParameter("cancel.x") != null) {
      ... do cancel stuff ...
  }

Because "reset" is a client-side function, you still need the
javascript for that.  Of course, you could just as easily do it in the
action, but it wouldn't be a "true" html reset because of the server
hit. 

-- Jim

KM <kris7077@yahoo.com> writes:

> Thanks for the tip Mattos, However javascript is not
> something the end client likes in this case, so trying
> to minimise using javascript. Any clue as to why the
> code I posted is not working?
> 
> Thanks for your time
> 
> KM
> --- "Mattos, John" <jmattos@Indemand.com> wrote:
> > Could you do the following...
> > 
> > <!-- JSP Snippet-->
> > <html:image onclick="javascript:submit();"
> > src="../images/onion.gif"
> > border="0"/>
> > 
> > <html:image onclick="../whereIWasBefore.jsp"
> > src="../images/onionCancel.gif"
> > border="0"/>
> > 
> > <html:image onclick="javascript:reset();return
> > false;"
> > src="../images/onionReset.gif" border="0"/>
> > <!-- End 'o snippet -->
> > 
> > 
> > Reset and submit work fine, but you need to
> > implement the cancel to do
> > whatever you need it to do.
> > 
> > Is that overly simplistic?
> > 
> > John Mattos
> > Sr. Developer and Architect
> > iNDEMAND
> > 345 Hudson St. 16th Floor
> > New York, New York
> > 10014
> > 
> > -----Original Message-----
> > From: KM [mailto:kris7077@yahoo.com]
> > Sent: Friday, February 22, 2002 10:27 AM
> > To: Struts Users Mailing List
> > Subject: how to use an images for submit, cancel
> > button etc 
> > 
> > 
> > Hi
> > 
> > I am trying to develop a page where the user has to
> > select options from a drop down box and either
> > clicks
> > submit or cancel. The submit and cancel options are
> > images instead of a button
> > 
> > Following is my code
> > 
> > 
> > <tr>
> >     <td align="right">
> >       <logic:equal name="subscriptionForm"
> > property="action"
> >                   scope="request" value="Create">
> >         <html:submit>
> >           <bean:message key="button.save"/>
> >         </html:submit>
> >       </logic:equal>
> >       <logic:equal name="subscriptionForm"
> > property="action"
> >                   scope="request" value="Delete">
> >         <html:submit>
> >           <bean:message key="button.confirm"/>
> >         </html:submit>
> >       </logic:equal>
> >       <logic:equal name="subscriptionForm"
> > property="action"
> >                   scope="request" value="Edit">
> >         <html:submit>
> >           <bean:message key="button.save"/>
> >         </html:submit>
> >       </logic:equal>
> >     </td>
> >     <td align="left">
> >       <logic:notEqual name="subscriptionForm"
> > property="action"
> >                      scope="request" value="Delete">
> >         <html:reset>
> >           <bean:message key="button.reset"/>
> >         </html:reset>
> >       </logic:notEqual>
> >       &nbsp;
> >       <html:cancel>
> >         <bean:message key="button.cancel"/>
> >       </html:cancel>
> >     </td>
> >   </tr>
> > 
> > here instead of the save, reset, cancel buttons I
> > would like to user save.gif, reset.gif, cancel.gif
> > etc
> > .How to set up struts to use this.. 
> > 
> > Any tips on how to do this is appreciated
> > 
> > KM
> > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Yahoo! Sports - Coverage of the 2002 Olympic Games
> > http://sports.yahoo.com
> > 
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:struts-user-help@jakarta.apache.org>
> > 
> > --
> > To unsubscribe, e-mail:  
> > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:struts-user-help@jakarta.apache.org>
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Sports - Coverage of the 2002 Olympic Games
> http://sports.yahoo.com
> 
> --
> To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message