Topic: 一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个..

  Print this page

1.一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. Copy to clipboard
Posted by: mengzhihai
Posted on: 2003-04-21 13:21

一个注册,一个登击,一个找回密码三个按钮...
我是在fombean或action中怎样判断用户是击了那个按钮,而针对相应的操作执行相应的action呢!!!

2.Re:一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. [Re: mengzhihai] Copy to clipboard
Posted by: hawker
Posted on: 2003-04-21 14:56

in jsp pages, you define three submit button which are different from their names, and you can use
if(request.getParameter("you_sumbit_button_name") != null)
{
// process you business logic
....
}
just test which submit button is pressed.

3.Re:一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. [Re: mengzhihai] Copy to clipboard
Posted by: gunrose
Posted on: 2003-04-22 08:34

使用button,不要使用submit,在button里写上onclick=A/B/C,就分开了。
而且以后如果button改成图片形式了,也不需要改动什么

4.Re:一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. [Re: mengzhihai] Copy to clipboard
Posted by: mengzhihai
Posted on: 2003-04-22 09:07

我知道用onclick,但是这样子好像只能在第一次用表单的时侯.
比如当提交表单数据有误,再返回表单页,而现在的地址是action的地址,所以再按action的地址去找表单,就找不着了....呵~~~~

5.Re:一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. [Re: mengzhihai] Copy to clipboard
Posted by: floater
Posted on: 2003-04-23 00:21

mengzhihai wrote:
我知道用onclick,但是这样子好像只能在第一次用表单的时侯.
比如当提交表单数据有误,再返回表单页,而现在的地址是action的地址,所以再按action的地址去找表单,就找不着了....呵~~~~

This is very dangerous because you are in a nondeterministic state in your finite state machine. You have to maintain the states when you move from one page to another.

One way to do this is to put some hidden fields and use javascript to change their values accordingly(when you press button A, change the value to A, etc).

6.Re:一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. [Re: mengzhihai] Copy to clipboard
Posted by: softtiger
Posted on: 2003-04-23 14:46

建议先好好看一看struts的书,不要一有问题老是想问人.从DispatchAction继承不就轻松搞定了吗?

7.Re:一个表单有三个按钮,我怎样在formbean判断用户是选择的那一个.. [Re: mengzhihai] Copy to clipboard
Posted by: JasonZhang
Posted on: 2003-04-24 05:20

It is important to be nice to everybody.
What "softtiger" said about subclass the org.apache.struts.actions.DispatchAction class is good idea.
You can find the detail from the book" Programming Jakarta Struts"
By Chuck Cavaness. The section number 5.1.6.3.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923