struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alberto Flors <aaflo...@gmail.com>
Subject Re: Struts 2 Buttons
Date Wed, 03 Sep 2008 13:37:05 GMT
Ok, so let's go back for a second and try to understand your question:

You have a form mapped to an action (struts.xml or via annotations) and 
you would like to have a button (one or many) to execute behavior on a 
method within that action instance? Answer: Yes. Add the "method" 
attribute to the "<s:submit>" tag. The method will be triggered as the 
executing method (instead of the default one). Note that the resolved 
HTML (I strongly encouraged you to look at the generated source) simply 
does the magic of telling the Struts2 to generate a button HTML element 
that will submit the form.

If you need a button "X" that is outside of form "Y", and button "X" 
needs to submit form "Y", then such thing could be done with javascript 
only (whereas through struts2 Dojo's plugin or other). Alternatively, a 
JSP can call an action by using the <s:action /> tag. Please refer to 
the http://struts.apache.org/2.x/docs/action.html for a  sample. I still 
yet to see a good use-case for the <s:action /> tag, but I'm sure others 
have found it appropriate.


Roger wrote:
> Is it possible to define a button (<s:input> in such a way that, instead of of

> calling a method in the action defined in the <s:form> tag, it calls a 
> completely different action.method. Is it possible to just add a button that 
> calls an action on the jsp.
> 
> Alternatively, I know I can style a link to look like a button with css, but 
> I'd rather have a button if at all possible
> 
> Regards 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 

-- 
--
Alberto
http://www.linkedin.com/in/aflores


Mime
View raw message