You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Suriyanarayanan, Senthil Kumar" <se...@capitalone.com> on 2001/04/13 00:08:34 UTC

REPOST: How to code and use the html:image tag?

Hello,
	How do you use html:image tag inside my html:tag?
	I need to have two image buttons namely login, forgotPassword. Which
is the right one to use, either the html:image tag or directly use the input
type=image?

	Say for example I define the html:image inside my html:form tag as
..

	<html:form action="/login" focus="userId">
		UserId: <html:text property="userId" size="15"
maxlength="15" /> <br>
		Password: <html:password property="password" size="16"
maxlength="16" /> <br>
		<html:image page="/images/login.gif" alt="Login"
property="loginButton" />
		<html:image page="/images/forgotpassword.gif" alt="Forgot
Password" property="forgotPasswordButton" />
	</html:form>

What methods should I code inside my LoginForm corresponding to those two
buttons? How to code the properties (loginButton, forgotPasswordButton). I'm
more concerned about whether a particular button is clicked rather then
their co-ordinates.


Thanks in advance,
Senthil Kumar.S


 
**************************************************************************
The Information transmitted herewith is sensitive information intended only
for use to the individual or entity to which it is addressed. If the reader
of this message is not the intended recipient, you are hereby notified that
any review, retransmission, dissemination, distribution, copying or other
use of, or taking of any action in reliance upon, this information is
strictly prohibited. If you have received this communication in error,
please contact the sender and delete the material from your computer.

Re: REPOST: How to code and use the html:image tag?

Posted by Ted Husted <hu...@apache.org>.
The property and value for the button is passed as a parameter
(property=value), that you can retrieve from the request context. 

A typical approach would be to give each button the same property but
different values, like 

<html:image page="/images/login.gif" alt="Login" property="login"
value="havePassword" />
<html:image page="/images/forgotpassword.gif" alt="Forgot Password"
property="login" value="forgotPassword" />

Then in the action method, you would use a pattern like 

string loginType = request.getParameter("login") ;
if loginType.equals(""forgotPassword") { forward to forgotPassword page
} 
if loginType.equals("havePassword") { validate password  } 

"Suriyanarayanan, Senthil Kumar" wrote:
> What methods should I code inside my LoginForm corresponding to those two
> buttons? How to code the properties (loginButton, forgotPasswordButton). I'm
> more concerned about whether a particular button is clicked rather then
> their co-ordinates.

Re: REPOST: How to code and use the html:image tag?

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 12 Apr 2001, Suriyanarayanan, Senthil Kumar wrote:

> Hello,
> 	How do you use html:image tag inside my html:tag?
> 	I need to have two image buttons namely login, forgotPassword. Which
> is the right one to use, either the html:image tag or directly use the input
> type=image?
> 
> 	Say for example I define the html:image inside my html:form tag as
> ..
> 
> 	<html:form action="/login" focus="userId">
> 		UserId: <html:text property="userId" size="15"
> maxlength="15" /> <br>
> 		Password: <html:password property="password" size="16"
> maxlength="16" /> <br>
> 		<html:image page="/images/login.gif" alt="Login"
> property="loginButton" />
> 		<html:image page="/images/forgotpassword.gif" alt="Forgot
> Password" property="forgotPasswordButton" />
> 	</html:form>
> 

The documentation for the <html:image> tag talks about how to do this.

Basically, if you us a property name like "forgot" on this tag, the
browser will send two request parameters ("forgot.x" and "forgot.y") with
the X and Y coordinates of where the mouse click occurred on this
image.  To detect which button was pressed, put the following code in your
Action:

  if (request.getParameter("loginButton.x") != null) {
    ... "Login" button was pressed ...
  } else if (request.getParameter("forgotPasswordButton.x") != null) {
    ... "Forgot Password" button was pressed ...
  }

Craig McClanahan