I am using the following code to have different submit buttons for my form. The problem is that if I change the value of the Value attribute of each of the submit buttons I have to change the Java code too as if conditions are based on these values.
I am looking for an alternative solution to avoid this problem, so back-end and front-end would be independent.
JSP
<s:form name="myform" method="POST" action="myformActions">
.....
<input id="sub1Btn" type="submit" name="action" value="mysubmit1"/>
<input id="sub2Btn" type="submit" name="action" value="mysubmit2"/>
</s:form>
Java
{
....
private String action;
....
public void myformActions(){
if(action.equalsIgnoreCase("mysubmit1") //if I change the value need to change this as well
{
do whatever is required to fulfill the request of mysubmit1 ...
}
if(action.equalsIgnoreCase("mysubmit2") //if I change the value need to change this as well
{
do whatever is required to fulfill the request of mysubmit2 ...
}
}
}