struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jones, Dean" <djo...@refco.com>
Subject RE: Request to reserve two hidden field names
Date Tue, 03 Oct 2000 16:11:31 GMT
Rob,

I solved this simply by creating an ActionForm field that was named the same
as the submit button,  and checking it's value in the Action,  a small bit
o'
code samplets follows.   Well,  I guess it's not secure,  but it is a simple
pattern that seems to work and requires no javascript. So, Is there anything
wrong with this ???  This is generally the way everyone used to do this with
Perl/CGI...

Dean S Jones
---------------------------------------

<struts:form action="Order.do" name="orderForm" type="xxx.OrderForm">
	<struts:submit property="sendOrderSubmit">
		<struts:message key="orderForm.sendOrderSubmit.prompt"/>
	</struts:submit>
	<struts:submit property="parkOrderSubmit">
		<struts:message key="orderForm.parkOrderSubmit.prompt"/>
	</struts:submit>
</struts:form>

package xxx;

public final class OrderForm extends ActionForm
{
	private String m_sendOrderSubmit = null;
	private String m_parkOrderSubmit = null;

	public void setSendOrderSubmit(String value)
	{
		m_sendOrderSubmit = value;
		m_parkOrderSubmit = null;
	}
	public void setParkOrderSubmit(String value)
	{
		m_sendOrderSubmit = null;
		m_parkOrderSubmit = value;
	}
}

public class OrderAction extends Action
{
	public ActionForward perform(...)
	{
		// bla bla bla Validate Form and stuff bla bla bla
		// ...

		if(form.getSendOrderSubmit() != null)
		{
			// The Send button was hit...

			return (mapping.findForward("send"));
		}
		if(form.getParkOrderSubmit(0 != null)
		{
			// The Park button was hit...

			return (mapping.findForward("park"));
		}
	}
}
	

Mime
View raw message