You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johnson nickel <sa...@elogic.co.in> on 2008/02/07 14:40:33 UTC

Multiple submit buttons in a single JSP

Hi all,

      In my JSP, i have three submit buttons, i want to know which button
user has clicked.

 I tried from this site, 
http://struts.apache.org/2.x/docs/html-form-buttons-howto.html 
http://struts.apache.org/2.x/docs/html-form-buttons-howto.html  
It's not working. 

            Give me some ideas,  i have added my code,


      public String execute() {
        if (buttonOnePressed) {
            message = "You pressed the first button";
           Save();
         
        } else if (buttonTwoPressed) {
            Update();
            message = "You pressed the second button";
        } 

        else if (buttonThreePressed) {
           Show();
            message = "You pressed the second button";
        } 
        else {
            return ERROR;
        }
        return SUCCESS;
    }

 In My Struts.xml file,

<action name="user_details2" class="com.user_details">
            <result  name="input">/JSP/user_details.jsp</result>  
			<result name="success">/JSP/user_details.jsp</result>
			<result name="error">/JSP/user_details.jsp</result>
			
		</action>

In Jsp,

 <input type="submit" name="buttonOnePressed" value="Save"/> 
<input type="submit" name="buttonTwoPressed" value="Update"/> 
<input type="submit" name="buttonThreePressed" value="Show"/> 
-- 
View this message in context: http://www.nabble.com/Multiple-submit-buttons-in-a-single-JSP-tp15334087p15334087.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Multiple submit buttons in a single JSP

Posted by Lukasz Lenart <lu...@googlemail.com>.
Hi,

You can use
<s:submit value="Save" method="save"/>
<s:submit value="Update" method="update"/>
<s:submit value="Show" method="show"/>

and Action class with three methods, the same like execute()

http://struts.apache.org/2.x/docs/submit.html


Regards
--
Lukasz

http://www.linkedin.com/in/lukaszlenart

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