You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mattos, John" <jm...@Indemand.com> on 2002/02/13 17:31:26 UTC

RE: HTML / Struts Help - addendum to summary.

I like that solution.

I Think I'll alter my solution so that I'm doing it this way. Originally, I
was concerned about getting back "Process Suspends" or some other strange
string from 

String getBtnProcess() ( a method on the ActionForm class) within the
Action.perform() method, but then I realized I have access to the message
resources, and that's where I'm getting that "Process Suspends" label
anyway, so why not just compare them.

I can therefore just do something like the following:

// Action.perform() snippet follows:
MessageResources application = actionServlet.getResources();
String thingToCompare =
application.getProperty(button.button.processSuspends);

I can then compare the results of getBtnProcess() with thingToCompare and do
whatever I need to do.

Good catch, thanks

John

John Mattos
Sr. Developer and Architect
iNDEMAND
345 Hudson St. 16th Floor
New York, New York
10014
-----Original Message-----
From: Keith [mailto:keithbaconstruts@yahoo.com]
Sent: Wednesday, February 13, 2002 11:17 AM
To: Struts Users Mailing List
Subject: RE: HTML / Struts Help


I think the design of struts is that you should have get/setters in your
form
beans for the button parameters rather than look at the request parms
directly.

in form bean ================================
	boolean createButton;
	public void setCreateButton(String createButtonParm) {
		createButton = true;
	}
	public boolean isCreateButton() {
		return createButton;
	}
====
in form bean reset have 
               createButton = false;
======
Then in your action code you can test
		if (formBean.isCreateButton()) 
======
hope that helps
K.
--- "Andres Marcel (KASO 211)" <ma...@csfs.com> wrote:
> Hi John
> 
> You can use the <html:image> tag and set the property to a value.
> Then in the action, you are able to find out, which button was presed like
> this :
> 
> // find out if the create button was clicked
> Enumeration enum = request.getParameterNames();
> int clickedButton = 0;
> for(int idx = 0; enum.hasMoreElements() & clickedButton == 0; idx++) {
> 	String paramName = (String)enum.nextElement();
> 	if(paramName.startsWith("VALUE-OF-PROPERTY-NAME")) {
> 		// what ever you want to do
> 	}
> }
> 
> 
> Marcel
> 
> -----Original Message-----
> From: Mattos, John [mailto:jmattos@Indemand.com]
> Sent: Wednesday, February 13, 2002 4:12 PM
> To: 'struts-user@jakarta.apache.org'
> Subject: HTML / Struts Help
> 
> 
> Hi.
> 
> I have a form that can be submitted by three different buttons, for
example
> the buttons read
> 
> (Button Labels)
> Process
> View by Org
> View by Product
> 
> What I want to do is in the Action Class handling the submission, find out
> which button was pressed, and act accordingly, whether it's an
actionForward
> (in the case of the "view" options) or kicking off another process (as
will
> be done by the "process" button)
> 
> So, how can I figure out what button was pressed in that Action class? Is
> there a way to do that?
> 
> John Mattos
> Sr. Developer and Architect
> iNDEMAND
> 345 Hudson St. 16th Floor
> New York, New York
> 10014
> 
> 
> 
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
> 
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
> 


=====


__________________________________________________
Do You Yahoo!?
Send FREE Valentine eCards with Yahoo! Greetings!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>